|
|
@@ -30,7 +30,7 @@ class AppTest:
|
|
|
resp = self.serial_port.request(self.module, self.sensor, (CMD_PARAM),[])
|
|
|
|
|
|
def cmd_sensor_cnt(self):
|
|
|
- resp = self.serial_port.request(self.module, 0, CMD_SENSOR_CNT,[])
|
|
|
+ resp = self.serial_port.request(self.module, 0, CMD_SENSOR_CNT,[])
|
|
|
return resp[3]
|
|
|
|
|
|
def cmd_sensor_type(self, index):
|
|
|
@@ -50,16 +50,20 @@ class AppTest:
|
|
|
|
|
|
def cmd_sensor_get_data(self, index):
|
|
|
resp = self.serial_port.request(self.module, index, CMD_DATA,[])
|
|
|
- h = resp[5] * 256 + resp[4]
|
|
|
+ if len(resp)>1:
|
|
|
+ h = resp[5] * 256 + resp[4]
|
|
|
# print(hex(h))
|
|
|
- return h/4096*3.3
|
|
|
+ return h/4096*3.3
|
|
|
+ return 0
|
|
|
|
|
|
def cmd_sensor_get_data_all(self, cnt):
|
|
|
resp = self.serial_port.request(self.module, 0, CMD_DATA,[])
|
|
|
- for i in range(cnt):
|
|
|
- sen = resp[3+3*i]
|
|
|
- h = resp[5+3*i] * 256 + resp[4+3*i]
|
|
|
- print("FSR",sen,":\t", h/4096.0*3.3)
|
|
|
+ # print(resp)
|
|
|
+ if len(resp)>1:
|
|
|
+ for i in range(cnt):
|
|
|
+ sen = resp[3+3*i]
|
|
|
+ h = resp[5+3*i] * 256 + resp[4+3*i]
|
|
|
+ print("FSR",sen,":\t", h/4096.0*3.3)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -93,41 +97,41 @@ if __name__ == "__main__":
|
|
|
app.cmd_module_start()
|
|
|
|
|
|
pocet = app.cmd_sensor_cnt()
|
|
|
-
|
|
|
+ print("pocet senzorov=", pocet)
|
|
|
app.cmd_sensor_get_data_all(pocet)
|
|
|
|
|
|
-
|
|
|
+ # quit()
|
|
|
for i in range(pocet):
|
|
|
d=app.cmd_sensor_get_data(i+1)
|
|
|
print("Data", i+1, ":\t", d)
|
|
|
|
|
|
|
|
|
- #time.sleep(1)
|
|
|
+ time.sleep(1)
|
|
|
app.cmd_module_stop()
|
|
|
|
|
|
|
|
|
|
|
|
- # print("Sensor type")
|
|
|
- # for i in range(pocet):
|
|
|
- # print(app.cmd_sensor_type(i+1))
|
|
|
- # print("Sensors type")
|
|
|
- # print(app.cmd_sensors_type(pocet))
|
|
|
- # par = app.cmd_sensor_get_params(1)
|
|
|
- # print(par)
|
|
|
+ print("Sensor type")
|
|
|
+ for i in range(pocet):
|
|
|
+ print(app.cmd_sensor_type(i+1))
|
|
|
+ print("Sensors type")
|
|
|
+ print(app.cmd_sensors_type(pocet))
|
|
|
+ par = app.cmd_sensor_get_params(1)
|
|
|
+ print(par)
|
|
|
|
|
|
|
|
|
- # r=app.cmd_module_info(0xE1)
|
|
|
- # print('NAME:' , r)
|
|
|
- # r=app.cmd_module_info(0xE2)
|
|
|
- # print('TYPE', r)
|
|
|
+ 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(0xE4)
|
|
|
+ print('FW', r)
|
|
|
|
|
|
- # r=app.cmd_module_info(0xE5)
|
|
|
- # print('HW', r)
|
|
|
+ r=app.cmd_module_info(0xE5)
|
|
|
+ print('HW', r)
|
|
|
|
|
|
- # r=app.cmd_module_info(0xE3)
|
|
|
- # print("UUID", r)
|
|
|
+ r=app.cmd_module_info(0xE3)
|
|
|
+ print("UUID", r)
|
|
|
app.finish()
|
|
|
|