P2UWaterJiangXi/app/UWater_Frame/UWater_frame_func_ReplyShen...

58 lines
1.7 KiB
C

#include "UWater_frame_app.h"
#include "UWater_rtcc_app.h"
#include "UWater_lcd_app.h"
#include "UWater_gp22_app.h"
#include "UWater_pt_app.h"
#include "UWater_frame_func_ReplyWT.h"
#include "UWater_encryption_driver.h"
#include "UWater_DataTools_App.h"
#include "UWater_uart_driver.h"
#include "UWater_eeprom_driver.h"
#include "UWater_frame_func_ReplyShenYang.h"
#if PRODUCT_SY
//解商河水务规约
u8 crack_frame_SHTCP(u16 frame_lenth,u8 *frame_buffer)//
{
u16 tmp_i = 0;
u16 tmp_j = 0;
u8 tmp_check = 0;
for (tmp_i = 0; tmp_i < frame_lenth; tmp_i++)
{
if (FM_HEAD_MARK == *(frame_buffer + tmp_i))
{
if ((MET_TYPE_TCP == *(s_frame_rcv_buf + tmp_i + 1))&&(1 == s_frame_flag.data_sourse))
{
s_frame_struct.met_type = MET_TYPE_TCP;
s_frame_struct.head_site = tmp_i; //记录帧头
s_frame_struct.len = *(s_frame_rcv_buf + tmp_i + 10);//数据长度
s_frame_struct.end_site = s_frame_struct.head_site + 10 + s_frame_struct.len + 2;
s_frame_struct.check_len = s_frame_struct.end_site - s_frame_struct.head_site - 1;
if(FM_END_MARK == *(s_frame_rcv_buf + s_frame_struct.end_site))
{
//计算校验和
tmp_check = 0;
for (tmp_j = s_frame_struct.head_site; tmp_j < (s_frame_struct.end_site - 1); tmp_j++)
{
tmp_check += *(s_frame_rcv_buf + tmp_j);
}
if (tmp_check == *(s_frame_rcv_buf + s_frame_struct.end_site - 1))
{
s_frame_struct.ctrl = *(s_frame_rcv_buf + s_frame_struct.head_site + 9);
s_frame_struct.DI0 = *(s_frame_rcv_buf + s_frame_struct.head_site + 11);
s_frame_struct.DI1 = *(s_frame_rcv_buf + s_frame_struct.head_site + 12);
return SUCCESS_IES;
}
}
}
}
}
return ERROR_IES;
}
#endif