Просмотр исходного кода

fix write sn&read sn error

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 5 лет назад
Родитель
Сommit
93853a4b8f
3 измененных файлов с 6 добавлено и 3 удалено
  1. 1 2
      Application/app/nv_storage.c
  2. 4 0
      Application/app/protocol_old.c
  3. 1 1
      Project/SP700.uvoptx

+ 1 - 2
Application/app/nv_storage.c

@@ -24,7 +24,6 @@ int nv_save_sn(uint8_t *sn, int len){
 	memcpy(sn_info.sn, sn, len);
 	sn_info.len = len;
 	sn_info.crc = shark_crc16_update(0, (const u8 *)sn_info.sn, len);
-	 
 	return AT24CXX_Write(SN_ADDR, (uint8_t *)&sn_info, sizeof(sn_info));
 }
 
@@ -37,7 +36,7 @@ int nv_read_sn(uint8_t *sn, int len){
 	if (AT24CXX_Read(SN_ADDR, (uint8_t *)&sn_info, sizeof(sn_info)) < 0) {
 		return -1;
 	}
-	if (len > sizeof(sn_info.sn)){
+	if (sn_info.len > sizeof(sn_info.sn)){
 		return -1;
 	}
 	uint16_t crc = shark_crc16_update(0, (const u8 *)sn_info.sn, sn_info.len);

+ 4 - 0
Application/app/protocol_old.c

@@ -135,6 +135,10 @@ static int protocol_old_process_binary(uart_enum_t uart_no, uint8_t *data, int l
 		}else {
 			result = 0;
 		}
+	}else if (operate == OP_WRITE_SN){
+		if (data[8] == 1) {
+			result = nv_save_sn(&data[9], 18) <= 0?1:0;
+		}
 	}
 	uint8_t response_data[256];
 	uint16_t response_len = get_response_data(response_data, operate, result);

+ 1 - 1
Project/SP700.uvoptx

@@ -135,7 +135,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
-          <Name>d</Name>
+          <Name></Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>