河北水利局项目
This commit is contained in:
117
hb/dl485pro.c
Normal file
117
hb/dl485pro.c
Normal file
@@ -0,0 +1,117 @@
|
||||
#include "uart.h"
|
||||
#include "addr.h"
|
||||
#include "debug_printf.h"
|
||||
#include "bl24c512.h"
|
||||
#include "WaterMetermanager.h"
|
||||
#include "Led.h"
|
||||
#include "keywd.h"
|
||||
#include "update.h"
|
||||
#include "Flash.h"
|
||||
#include "PHY.h"
|
||||
#include "rtc_ext.h"
|
||||
|
||||
//读地址
|
||||
void pro_645_97_read_addr(u8 *outBuf, u16 *outLen)
|
||||
{
|
||||
//FE FE FE FE 68 99 99 99 99 99 99 68 01 02 43 C3 6F 16
|
||||
// 68 06 88 10 40 06 00 68 81 06 43 C0 31 48 03 23 04 00 41 06 00 68 81 06 43 C3 33 C5 CC 33 B6 16
|
||||
outBuf[0] = 0x68;
|
||||
outBuf[1] = 0x99;
|
||||
outBuf[2] = 0x99;
|
||||
outBuf[3] = 0x99;
|
||||
outBuf[4] = 0x99;
|
||||
outBuf[5] = 0x99;
|
||||
outBuf[6] = 0x99;
|
||||
outBuf[7] = 0x68;
|
||||
outBuf[8] = 0x01;
|
||||
outBuf[9] = 0x02;
|
||||
outBuf[10] = 0x43;
|
||||
outBuf[11] = 0xC3;
|
||||
outBuf[12] = GetSum(outBuf,12);
|
||||
outBuf[13] = 0x16;
|
||||
*outLen = 14;
|
||||
}
|
||||
|
||||
bool pro_645_97_recv_addr(u8 *inbuf, u16 len, u8 *addr)
|
||||
{
|
||||
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
//68 06 88 10 40 06 00 68 81 06 43 C3 33 48 33 33 22 16
|
||||
|
||||
if(inbuf[0] == 0x68 && inbuf[7] == 0x68 && inbuf[8] == 0x81)
|
||||
{
|
||||
if(inbuf[16] == GetSum(inbuf,16))
|
||||
{
|
||||
addr[0] = inbuf[1];
|
||||
addr[1] = inbuf[2];
|
||||
addr[2] = inbuf[3];
|
||||
addr[3] = inbuf[4];
|
||||
addr[4] = inbuf[5];
|
||||
addr[5] = inbuf[6];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//读数据
|
||||
void pro_645_97_read_data(u8 *addr,u8 *outBuf, u16 *outLen)
|
||||
{
|
||||
//FE FE FE FE 68 06 88 10 40 06 00 68 01 02 43 C3 BD 16
|
||||
//68 06 88 10 40 06 00 68 81 06 43 C3 33 48 33 33 22 16
|
||||
//水表数据是15
|
||||
outBuf[0] = 0x68;
|
||||
outBuf[1] = addr[0];
|
||||
outBuf[2] = addr[1];
|
||||
outBuf[3] = addr[2];
|
||||
outBuf[4] = addr[3];
|
||||
outBuf[5] = addr[4];
|
||||
outBuf[6] = addr[5];
|
||||
outBuf[7] = 0x68;
|
||||
outBuf[8] = 0x01;
|
||||
outBuf[9] = 0x02;
|
||||
outBuf[10] = 0x43;
|
||||
outBuf[11] = 0xC3;
|
||||
outBuf[12] = GetSum(outBuf,12);
|
||||
outBuf[13] = 0x16;
|
||||
|
||||
*outLen = 14;
|
||||
|
||||
}
|
||||
|
||||
bool pro_645_97_recv_data(u8 *inbuf, u16 len, u8 *inID, u8 *out_datas, u8 *out_status)
|
||||
{
|
||||
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
//68 06 88 10 40 06 00 68 81 06 43 C3 33 48 33 33 22 16
|
||||
|
||||
if(inbuf[0] == 0x68 && inbuf[7] == 0x68 && inbuf[8] == 0x81)
|
||||
{
|
||||
if(inbuf[16] == GetSum(inbuf,16))
|
||||
{
|
||||
if(0 == memcmp(&inbuf[1],inID,5))
|
||||
{
|
||||
out_datas[0] = 0x2C;
|
||||
out_datas[1] = inbuf[12]-0x33;
|
||||
out_datas[2] = inbuf[13]-0x33;
|
||||
out_datas[3] = inbuf[14]-0x33;
|
||||
out_datas[4] = inbuf[15]-0x33;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
//读地址
|
||||
FE FE FE FE 68 99 99 99 99 99 99 68 01 02 43 C3 6F 16
|
||||
68 06 88 10 40 06 00 68 81 06 43 C0 31 48 03 23 04 00 41 06 00 68 81 06 43 C3 33 C5 CC 33 B6 16
|
||||
|
||||
|
||||
//读水表数据
|
||||
FE FE FE FE 68 06 88 10 40 06 00 68 01 02 43 C3 BD 16
|
||||
68 06 88 10 40 06 00 68 81 06 43 C3 33 48 33 33 22 16
|
||||
水表数据是15
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user