Browse Source

add CMD_INFO

Juraj Ďuďák 2 years ago
parent
commit
52fe7cc19e
6 changed files with 34 additions and 3 deletions
  1. 1 0
      Core/Src/app_dummy.c
  2. 1 0
      Core/Src/main.c
  3. 1 1
      Modules/nbus
  4. 1 1
      Modules/one-wire-memory
  5. 28 0
      test/app.py
  6. 2 1
      test/comm.py

+ 1 - 0
Core/Src/app_dummy.c

@@ -59,6 +59,7 @@ uint8_t dummy_getData(uint8_t sensor_index, uint8_t *data){
             data[i] = ((uint8_t*)&dummy_data)[i+(sensor_index-1)*8];
             data[4+i] = ((uint8_t*)&dummy_data)[4+i+(sensor_index-1)*8];
     }
+
 	return 8;
 }
 

+ 1 - 0
Core/Src/main.c

@@ -123,6 +123,7 @@ int main(void)
   Ec20_MemoryDriver *memory = getEc20MemoryDriver();
   memory->init(ONE_WIRE_GPIO_Port, ONE_WIRE_Pin);
 
+
   nBusAppInterface_t *dummy = getDummyDriver();
   nbus_init(&periph, dummy);
   nbus_init_app(periph.adc, NULL);

+ 1 - 1
Modules/nbus

@@ -1 +1 @@
-Subproject commit b13977df57be5ab7ee9d7690b3a810df5d9eb94c
+Subproject commit 93290cf1273272823d9cda2e1a324eeb57bade93

+ 1 - 1
Modules/one-wire-memory

@@ -1 +1 @@
-Subproject commit bcf9b4fc07df3800ed43aee717bffb73334834ce
+Subproject commit 47ae5d8fc2a309bf9ecf94970020e6403856dfc7

+ 28 - 0
test/app.py

@@ -52,6 +52,20 @@ class AppTest:
         resp = self.serial_port.request(self.module, index, CMD_DATA,[])
         return resp
 
+    def cmd_module_info(self, param):
+        resp = self.serial_port.request(self.module, 0, CMD_INFO,[param])
+        if param == 0xE3:
+            data=0
+            for i in range(4):
+                data=data+resp[i+3]*pow(256,i)
+            return hex(data)
+
+        l = len(resp)
+        data=""
+        for i in range(l-4):
+            data=data+chr(resp[i+3])
+        return data
+
 if __name__ == "__main__":
     
     app = AppTest(0x05, 0x0)
@@ -70,5 +84,19 @@ if __name__ == "__main__":
     print(par)
     app.cmd_sensor_get_data(1)
     app.cmd_sensor_get_data(2)
+    
+    r=app.cmd_module_info(0xE1)
+    print('NAME:' , r)    
+    r=app.cmd_module_info(0xE2)
+    print('TYPE', r)
+        
+    r=app.cmd_module_info(0xE4)
+    print('FW', r)
+
+    r=app.cmd_module_info(0xE5) 
+    print('HW', r)
+    
+    r=app.cmd_module_info(0xE3)    
+    print("UUID", r)
     app.finish()
 

+ 2 - 1
test/comm.py

@@ -10,7 +10,7 @@ GET = 0x00
 MODULE_ADDR = 0x05
 
 
-CMD_VERSION = 0x00
+
 CMD_ECHO = 0x01
 CMD_STOP = 0x02
 CMD_START = 0x03
@@ -24,6 +24,7 @@ CMD_STORE = 0x0A
 CMD_DATA = 0x0B
 CMD_SYNC = 0x0C
 CMD_SENSOR_TYPE = 0x0D
+CMD_INFO = 0x0E
 
 crc8x_table = [
         0x00,0x07,0x0E,0x09,0x1C,0x1B,0x12,0x15,0x38,0x3F,0x36,0x31,0x24,0x23,0x2A,0x2D,