|
@@ -33,7 +33,7 @@
|
|
|
#define FAIL -1
|
|
|
|
|
|
struct Address Addr={0x01,0x02,0x03,0x04,0xFF};
|
|
|
-struct Command Cmd={0x01,0x02,0x0a,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
|
|
|
+struct Command Cmd={0x01,0x02,0x0a,0x83,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
|
|
|
|
|
|
int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
|
|
|
{
|
|
@@ -231,6 +231,49 @@ unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *S
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname)
|
|
|
+{
|
|
|
+ unsigned char result = FAIL;
|
|
|
+ unsigned char tx[21] = {0xaa, 0x00, targetAddr, Cmd.config_Model_Name, 0x0E, 0x00,
|
|
|
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
+ unsigned char rx[512];
|
|
|
+ unsigned char chksum = 0x00;
|
|
|
+
|
|
|
+ memcpy(tx + 6, modelname, 14);
|
|
|
+
|
|
|
+ for(int idx = 0; idx<(tx[4] | tx[5]<<8);idx++)
|
|
|
+ chksum ^= tx[6+idx];
|
|
|
+ tx[20] = chksum;
|
|
|
+
|
|
|
+// for(int i = 0; i < 21; i++)
|
|
|
+// printf ("tx = %x \n", tx[i]);
|
|
|
+ unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
|
|
|
+// for(int i = 0; i < len; i++)
|
|
|
+// printf ("rx = %x \n", rx[i]);
|
|
|
+ if(len > 6)
|
|
|
+ {
|
|
|
+ if (len < 6+(rx[4] | rx[5]<<8))
|
|
|
+ return result;
|
|
|
+
|
|
|
+ chksum = 0x00;
|
|
|
+ for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
|
|
|
+ {
|
|
|
+ chksum ^= rx[6+idx];
|
|
|
+ }
|
|
|
+
|
|
|
+ if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
|
|
|
+ (rx[2] == tx[1]) &&
|
|
|
+ (rx[1] == tx[2]) &&
|
|
|
+ (rx[3] == tx[3]) &&
|
|
|
+ rx[6] == PASS)
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
|
|
|
{
|
|
|
unsigned char result = FAIL;
|