Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JK BMS and TTL FTDI #257

Open
preussal opened this issue Sep 5, 2022 · 4 comments
Open

JK BMS and TTL FTDI #257

preussal opened this issue Sep 5, 2022 · 4 comments

Comments

@preussal
Copy link
Contributor

preussal commented Sep 5, 2022

BMS queries work with Bluetooth.
But unfortunately not over TTL 232

BMS 1

jkbms -p C8:47:8C:E2:90:FA -n Battery-1 -P JK02 -c getInfo


Command: getInfo - BLE Device Information inquiry
------------------------------------------------------------
Parameter                     	Value           Unit
header                        	55aaeb90       	    
record_type                   	03             	    
record_counter                	118            	    
device_model                  	JK-B2A24S15P   	    
hardware_version              	10.XW          	    
software_version              	10.08          	    
up_time                       	39D6H30M0S     	    
power-on_times                	16             	    
device_name                   	Battery-1      	    
device_passcode               	1234           	    
manufacturing_date            	220726         	    
serial_number                 	2042102267     	    
passcode                      	0000           	    
user_data                     	Battery #1a    	 

BMS 2

jkbms -p C8:47:8C:E1:E7:30 -n Battery-2 -P JK02 -c getInfo

Command: getInfo - BLE Device Information inquiry
------------------------------------------------------------
Parameter                     	Value           Unit
header                        	55aaeb90       	    
record_type                   	03             	    
record_counter                	122            	    
device_model                  	JK-B2A24S20P   	    
hardware_version              	10.XW          	    
software_version              	10.07          	    
up_time                       	36D7H15M0S     	    
power-on_times                	23             	    
device_name                   	Battery-2      	    
device_passcode               	1234           	    
manufacturing_date            	220713         	    
serial_number                 	2012601265     	    
passcode                      	0000           	    
user_data                     	Battery #2a    	  

BMS 1

jkbms -p /dev/ttyUSB1 -P JK232 -n Battery-1 -b 115200 -D

2022-09-05 19:37:43,915:INFO:__init__:main@227: Solar Device Command Utility, version: 0.13.2
2022-09-05 19:37:43,916:DEBUG:__init__:main@241: MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffffa0547520>, _isConnected=False)
2022-09-05 19:37:43,916:DEBUG:__init__:main@243: udp port 5555
2022-09-05 19:37:43,916:DEBUG:__init__:main@245: Using Postgres None
2022-09-05 19:37:43,917:DEBUG:__init__:main@248: Using Mongo None with mppsolar
2022-09-05 19:37:43,917:INFO:__init__:main@350: Creating device "Battery-1" (type: "jkbms") on port "/dev/ttyUSB1 (porttype=None)" using protocol "JK232"
2022-09-05 19:37:43,936:DEBUG:__init__:main@354: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2022-09-05 19:37:43,936:DEBUG:device:__init__@33: __init__ args ()
2022-09-05 19:37:43,936:DEBUG:device:__init__@34: __init__ kwargs {'name': 'Battery-1', 'port': '/dev/ttyUSB1', 'protocol': 'JK232', 'baud': 115200, 'porttype': None, 'mqtt_broker': MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffffa0547520>, _isConnected=False), 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2022-09-05 19:37:43,937:DEBUG:__init__:get_port_type@65: port matches ttyusb
2022-09-05 19:37:43,937:INFO:__init__:get_port@107: Using serialio for communications
2022-09-05 19:37:43,997:DEBUG:__init__:get_protocol@12: Protocol JK232
2022-09-05 19:37:44,033:DEBUG:device:__init__@38: __init__ name Battery-1, port <mppsolar.inout.serialio.SerialIO object at 0xffff9fb89c30>, protocol <mppsolar.protocols.jk232.jk232 object at 0xffff9fb89ba0>
2022-09-05 19:37:44,033:DEBUG:__init__:main@403: Commands [(<mppsolar.devices.jkbms.jkbms object at 0xffff9fb89d50>, '', '', 'screen', None, None)]
2022-09-05 19:37:44,033:INFO:__init__:main@408: Looping 1 commands
2022-09-05 19:37:44,034:INFO:__init__:main@418: Getting results from device: jkbms device - name: Battery-1, port: <mppsolar.inout.serialio.SerialIO object at 0xffff9fb89c30>, protocol: <mppsolar.protocols.jk232.jk232 object at 0xffff9fb89ba0> for command: , tag: , outputs: screen
2022-09-05 19:37:44,034:INFO:device:run_command@274: Running command 
2022-09-05 19:37:44,034:INFO:jk232:get_full_command@82: Using protocol b'JK232' with 1 commands
2022-09-05 19:37:44,034:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:37:44,035:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:37:44,035:DEBUG:jk232:get_full_command@99: cmd with start bit: bytearray(b'\xdd\x00\x00\x00\x00\x00\x00')
2022-09-05 19:37:44,035:DEBUG:jk232:get_full_command@121: cmd with crc: bytearray(b'\xdd\xa5\x03\x00\xff\xfdw')
2022-09-05 19:37:44,035:INFO:device:run_command@303: full command bytearray(b'\xdd\xa5\x03\x00\xff\xfdw') for command getBalancerData
2022-09-05 19:37:44,036:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:37:44,036:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:37:44,036:DEBUG:serialio:send_and_receive@19: port /dev/ttyUSB1, baudrate 115200
2022-09-05 19:37:44,044:DEBUG:serialio:send_and_receive@22: Executing command via serialio...
2022-09-05 19:37:45,146:DEBUG:serialio:send_and_receive@30: serial response was: b''
2022-09-05 19:37:45,151:DEBUG:device:run_command@322: Send and Receive Response b''
2022-09-05 19:37:45,151:INFO:abstractprotocol:decode@196: response passed to decode: b''
2022-09-05 19:37:45,151:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:37:45,152:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:37:45,152:INFO:abstractprotocol:decode@236: Processing response of type POSITIONAL
2022-09-05 19:37:45,152:DEBUG:jk232:get_responses@149: get_responses: responses [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-05 19:37:45,153:DEBUG:abstractprotocol:decode@240: trimmed and split responses: [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-05 19:37:45,153:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:37:45,153:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Start Byte', '']
2022-09-05 19:37:45,153:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Start Byte, raw_value b''
2022-09-05 19:37:45,154:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:37:45,155:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:37:45,155:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:37:45,155:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Command Code', '']
2022-09-05 19:37:45,155:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Command Code, raw_value b''
2022-09-05 19:37:45,156:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:37:45,156:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:37:45,157:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:37:45,157:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Status', '']
2022-09-05 19:37:45,157:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Status, raw_value b''
2022-09-05 19:37:45,158:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:37:45,158:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:37:45,158:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:37:45,159:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Int', 1, 'Data Length', '']
2022-09-05 19:37:45,159:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Int for data_name: Data Length, raw_value b''
2022-09-05 19:37:45,159:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Int(raw_value)
Traceback (most recent call last):
  File "/root/venv/mppsolar/bin/jkbms", line 8, in <module>
    sys.exit(main())
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/__init__.py", line 421, in main
    results = _device.run_command(command=_command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/devices/device.py", line 340, in run_command
    decoded_response = self._protocol.decode(raw_response, command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 460, in decode
    data_name, value, data_units = self.process_response(
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 177, in process_response
    r = eval(format_string)
  File "<string>", line 1, in <module>
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/protocol_helpers.py", line 95, in Hex2Int
    answer = hexString[0]
IndexError: index out of range

BMS 2

jkbms -p /dev/ttyUSB2 -P JK232 -n Battery-2 -b 115200 -D

2022-09-05 19:38:54,136:INFO:__init__:main@227: Solar Device Command Utility, version: 0.13.2
2022-09-05 19:38:54,136:DEBUG:__init__:main@241: MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffff8cf67520>, _isConnected=False)
2022-09-05 19:38:54,137:DEBUG:__init__:main@243: udp port 5555
2022-09-05 19:38:54,137:DEBUG:__init__:main@245: Using Postgres None
2022-09-05 19:38:54,137:DEBUG:__init__:main@248: Using Mongo None with mppsolar
2022-09-05 19:38:54,137:INFO:__init__:main@350: Creating device "Battery-2" (type: "jkbms") on port "/dev/ttyUSB2 (porttype=None)" using protocol "JK232"
2022-09-05 19:38:54,142:DEBUG:__init__:main@354: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2022-09-05 19:38:54,142:DEBUG:device:__init__@33: __init__ args ()
2022-09-05 19:38:54,142:DEBUG:device:__init__@34: __init__ kwargs {'name': 'Battery-2', 'port': '/dev/ttyUSB2', 'protocol': 'JK232', 'baud': 115200, 'porttype': None, 'mqtt_broker': MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffff8cf67520>, _isConnected=False), 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2022-09-05 19:38:54,142:DEBUG:__init__:get_port_type@65: port matches ttyusb
2022-09-05 19:38:54,142:INFO:__init__:get_port@107: Using serialio for communications
2022-09-05 19:38:54,151:DEBUG:__init__:get_protocol@12: Protocol JK232
2022-09-05 19:38:54,155:DEBUG:device:__init__@38: __init__ name Battery-2, port <mppsolar.inout.serialio.SerialIO object at 0xffff8c5a9c30>, protocol <mppsolar.protocols.jk232.jk232 object at 0xffff8c5a9ba0>
2022-09-05 19:38:54,155:DEBUG:__init__:main@403: Commands [(<mppsolar.devices.jkbms.jkbms object at 0xffff8c5a9d50>, '', '', 'screen', None, None)]
2022-09-05 19:38:54,155:INFO:__init__:main@408: Looping 1 commands
2022-09-05 19:38:54,155:INFO:__init__:main@418: Getting results from device: jkbms device - name: Battery-2, port: <mppsolar.inout.serialio.SerialIO object at 0xffff8c5a9c30>, protocol: <mppsolar.protocols.jk232.jk232 object at 0xffff8c5a9ba0> for command: , tag: , outputs: screen
2022-09-05 19:38:54,155:INFO:device:run_command@274: Running command 
2022-09-05 19:38:54,156:INFO:jk232:get_full_command@82: Using protocol b'JK232' with 1 commands
2022-09-05 19:38:54,156:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:38:54,156:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:38:54,156:DEBUG:jk232:get_full_command@99: cmd with start bit: bytearray(b'\xdd\x00\x00\x00\x00\x00\x00')
2022-09-05 19:38:54,156:DEBUG:jk232:get_full_command@121: cmd with crc: bytearray(b'\xdd\xa5\x03\x00\xff\xfdw')
2022-09-05 19:38:54,156:INFO:device:run_command@303: full command bytearray(b'\xdd\xa5\x03\x00\xff\xfdw') for command getBalancerData
2022-09-05 19:38:54,156:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:38:54,156:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:38:54,157:DEBUG:serialio:send_and_receive@19: port /dev/ttyUSB2, baudrate 115200
2022-09-05 19:38:54,164:DEBUG:serialio:send_and_receive@22: Executing command via serialio...
2022-09-05 19:38:55,266:DEBUG:serialio:send_and_receive@30: serial response was: b''
2022-09-05 19:38:55,271:DEBUG:device:run_command@322: Send and Receive Response b''
2022-09-05 19:38:55,272:INFO:abstractprotocol:decode@196: response passed to decode: b''
2022-09-05 19:38:55,272:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-05 19:38:55,272:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK232'
2022-09-05 19:38:55,272:INFO:abstractprotocol:decode@236: Processing response of type POSITIONAL
2022-09-05 19:38:55,273:DEBUG:jk232:get_responses@149: get_responses: responses [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-05 19:38:55,273:DEBUG:abstractprotocol:decode@240: trimmed and split responses: [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-05 19:38:55,273:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:38:55,274:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Start Byte', '']
2022-09-05 19:38:55,274:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Start Byte, raw_value b''
2022-09-05 19:38:55,274:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:38:55,275:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:38:55,275:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:38:55,276:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Command Code', '']
2022-09-05 19:38:55,276:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Command Code, raw_value b''
2022-09-05 19:38:55,276:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:38:55,277:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:38:55,277:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:38:55,277:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Status', '']
2022-09-05 19:38:55,278:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Status, raw_value b''
2022-09-05 19:38:55,278:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-05 19:38:55,278:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-05 19:38:55,279:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-05 19:38:55,279:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Int', 1, 'Data Length', '']
2022-09-05 19:38:55,279:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Int for data_name: Data Length, raw_value b''
2022-09-05 19:38:55,279:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Int(raw_value)
Traceback (most recent call last):
  File "/root/venv/mppsolar/bin/jkbms", line 8, in <module>
    sys.exit(main())
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/__init__.py", line 421, in main
    results = _device.run_command(command=_command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/devices/device.py", line 340, in run_command
    decoded_response = self._protocol.decode(raw_response, command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 460, in decode
    data_name, value, data_units = self.process_response(
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 177, in process_response
    r = eval(format_string)
  File "<string>", line 1, in <module>
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/protocol_helpers.py", line 95, in Hex2Int
    answer = hexString[0]
IndexError: index out of range

Then I found a script at https://github.com/purplealien/jk-bms_grafana. with which I at least get data from a BMS.

And here is a simple python script what a command sends and also gets something back.

BMS 2

4e
57
00
13
00
00
00
00
06
03
00
00
00
00
00
00
68
01
29
sending command: 4e5700130000000006030000000000006800000129
wrote 21 bytes
Got response: b'NW\x01!\x00\x00\x00\x00\x06\x00\x01y0\x01\x0c\xee\x02\x0c\xf0\x03\x0c\xf3\x04\x0c\xf1\x05\x0c\xf1\x06\x0c\xf0\x07\x0c\xef\x08\x0c\xf0\t\x0c\xf1\n'
Got response: b'\x0c\xf1\x0b\x0c\xef\x0c\x0c\xf0\r\x0c\xf0\x0e\x0c\xeb\x0f\x0c\xf0\x10\x0c\xf1\x80\x00"\x81\x00 \x82\x00\x1f\x83\x14\xb3\x84\x02\xdf\x85F\x86\x02\x87\x00\t\x89\x00\x00\n'
Got response: b'\x00\x8a\x00\x10\x8b\x00\x00\x8c\x00\x03\x8e\x16\x80\x8f\x0f\xf0\x90\x0e\x10\x91\r\xde\x92\x00\x05\x93\t\xf6\x94\n'
Got response: b'Z\x95\x00\x05\x96\x01,\x97\x00\x96\x98\x01,\x99\x00\x96\x9a\x00\x1e\x9b\rH\x9c\x00\x05\x9d\x01\x9e\x00Z\x9f\x00F\xa0\x00d\xa1\x00d\xa2\x00\x14\xa3\x00F\xa4\x00F\xa5\x00\x01\xa6\x00\x05\xa7\xff\xec\xa8\xff\xf6\xa9\x10\xaa\x00\x00\x01\x18\xab\x01\xac\x01\xad\x04\x1a\xae\x01\xaf\x01\xb0\x00\n'
Got response: b'\xb1\x14\xb219qwert79\x00\xb3\x00\xb4Battery \xb52207\xb6\x00\x00\xce\x00\xb710.XW_S10.07___\xb8\x00\xb9\x00\x00\x01\x00\xbaBattery #2\x00\x00Battery-2 \x00\x00\xc0\x01\x00\x00\x00\x00h\x00\x00V\xf3'

Then I disconnected the two BMS and measured the resistance between TX and RX.
With the BMS 1, ~ 2.5 Mega Ohm
With the BMS 2, ~ 60 Kilos ohm

Unfortunately I didn't find any information about it. But I think that hardware has a problem with BMS 1.

@syssi
Copy link
Contributor

syssi commented Sep 5, 2022

Please use -P JK485 instead of -P JK232.

@preussal
Copy link
Contributor Author

preussal commented Sep 6, 2022

BMS 1 maybe with Hardware failure

jkbms -p /dev/ttyUSB1 -P JK485 -n Battery-1 -b 115200 -D

2022-09-06 12:47:13,065:INFO:__init__:main@227: Solar Device Command Utility, version: 0.13.2
2022-09-06 12:47:13,065:DEBUG:__init__:main@241: MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffff81ab7520>, _isConnected=False)
2022-09-06 12:47:13,066:DEBUG:__init__:main@243: udp port 5555
2022-09-06 12:47:13,066:DEBUG:__init__:main@245: Using Postgres None
2022-09-06 12:47:13,066:DEBUG:__init__:main@248: Using Mongo None with mppsolar
2022-09-06 12:47:13,066:INFO:__init__:main@350: Creating device "Battery-1" (type: "jkbms") on port "/dev/ttyUSB1 (porttype=None)" using protocol "JK485"
2022-09-06 12:47:13,073:DEBUG:__init__:main@354: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2022-09-06 12:47:13,073:DEBUG:device:__init__@33: __init__ args ()
2022-09-06 12:47:13,073:DEBUG:device:__init__@34: __init__ kwargs {'name': 'Battery-1', 'port': '/dev/ttyUSB1', 'protocol': 'JK485', 'baud': 115200, 'porttype': None, 'mqtt_broker': MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffff81ab7520>, _isConnected=False), 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2022-09-06 12:47:13,074:DEBUG:__init__:get_port_type@65: port matches ttyusb
2022-09-06 12:47:13,074:INFO:__init__:get_port@107: Using serialio for communications
2022-09-06 12:47:13,084:DEBUG:__init__:get_protocol@12: Protocol JK485
2022-09-06 12:47:13,090:DEBUG:device:__init__@38: __init__ name Battery-1, port <mppsolar.inout.serialio.SerialIO object at 0xffff810f9c30>, protocol <mppsolar.protocols.jk485.jk485 object at 0xffff810f9ba0>
2022-09-06 12:47:13,090:DEBUG:__init__:main@403: Commands [(<mppsolar.devices.jkbms.jkbms object at 0xffff810f9d50>, '', '', 'screen', None, None)]
2022-09-06 12:47:13,090:INFO:__init__:main@408: Looping 1 commands
2022-09-06 12:47:13,090:INFO:__init__:main@418: Getting results from device: jkbms device - name: Battery-1, port: <mppsolar.inout.serialio.SerialIO object at 0xffff810f9c30>, protocol: <mppsolar.protocols.jk485.jk485 object at 0xffff810f9ba0> for command: , tag: , outputs: screen
2022-09-06 12:47:13,091:INFO:device:run_command@274: Running command 
2022-09-06 12:47:13,091:INFO:jk485:get_full_command@97: Using protocol b'JK485' with 1 commands
2022-09-06 12:47:13,091:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:47:13,091:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:47:13,091:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:47:13,092:DEBUG:jk485:get_full_command@111: cmd with header: bytearray(b'U\xaa\x00\x00\x00\x00\x00')
2022-09-06 12:47:13,092:DEBUG:jk485:get_full_command@114: cmd with header + slave address: bytearray(b'U\xaa\x01\x00\x00\x00\x00')
2022-09-06 12:47:13,092:DEBUG:jk485:get_full_command@119: cmd with command code and frame data: bytearray(b'U\xaa\x01\xff\x00\x00\x00')
2022-09-06 12:47:13,092:DEBUG:jk485:get_full_command@122: cmd with crc: bytearray(b'U\xaa\x01\xff\x00\x00\xff')
2022-09-06 12:47:13,092:INFO:device:run_command@303: full command bytearray(b'U\xaa\x01\xff\x00\x00\xff') for command getBalancerData
2022-09-06 12:47:13,092:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:47:13,093:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:47:13,093:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:47:13,093:DEBUG:serialio:send_and_receive@19: port /dev/ttyUSB1, baudrate 115200
2022-09-06 12:47:13,100:DEBUG:serialio:send_and_receive@22: Executing command via serialio...
2022-09-06 12:47:14,203:DEBUG:serialio:send_and_receive@30: serial response was: b''
2022-09-06 12:47:14,207:DEBUG:device:run_command@322: Send and Receive Response b''
2022-09-06 12:47:14,207:INFO:abstractprotocol:decode@196: response passed to decode: b''
2022-09-06 12:47:14,207:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:47:14,208:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:47:14,208:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:47:14,208:INFO:abstractprotocol:decode@236: Processing response of type POSITIONAL
2022-09-06 12:47:14,208:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 2, 'Header', '']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Slave Address', '']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Command Code', '']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Number of Cells', '']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Highest Cell', '']
2022-09-06 12:47:14,209:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Lowest Cell', '']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Charging / Discharging', '']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Alarm - todo', '']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Difference', 'V']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Current', 'A']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Trigger Voltage', 'V']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Max Balance Current', 'A']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Balance On / Off', '']
2022-09-06 12:47:14,210:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Set Number of Cells', '']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell01', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell02', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell03', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell04', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell05', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell06', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell07', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell08', 'V']
2022-09-06 12:47:14,211:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell09', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell10', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell11', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell12', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell13', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell14', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell15', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell16', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell17', 'V']
2022-09-06 12:47:14,212:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell18', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell19', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell20', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell21', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell22', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell23', 'V']
2022-09-06 12:47:14,213:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell24', 'V']
2022-09-06 12:47:14,214:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short', 2, 'Temperature', '°C']
2022-09-06 12:47:14,214:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Checksum', '']
2022-09-06 12:47:14,214:DEBUG:abstractprotocol:decode@240: trimmed and split responses: [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-06 12:47:14,214:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,214:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 2, 'Header', '']
2022-09-06 12:47:14,214:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Header, raw_value b''
2022-09-06 12:47:14,215:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:14,215:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:14,215:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,216:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Slave Address', '']
2022-09-06 12:47:14,216:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Slave Address, raw_value b''
2022-09-06 12:47:14,216:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:14,216:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:14,216:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,217:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Command Code', '']
2022-09-06 12:47:14,217:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Command Code, raw_value b''
2022-09-06 12:47:14,217:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:14,217:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:14,218:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,218:DEBUG:abstractprotocol:decode@431: Got defn ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2022-09-06 12:47:14,218:DEBUG:abstractprotocol:process_response@102: Got template r/100 for Total Battery Voltage b''
2022-09-06 12:47:14,218:DEBUG:abstractprotocol:process_response@103: Processing data_type: BigHex2Short for data_name: Total Battery Voltage, raw_value b''
2022-09-06 12:47:14,218:DEBUG:abstractprotocol:process_response@175: Processing format string BigHex2Short(raw_value)
2022-09-06 12:47:14,219:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2022-09-06 12:47:14,219:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,219:DEBUG:abstractprotocol:decode@431: Got defn ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2022-09-06 12:47:14,219:DEBUG:abstractprotocol:process_response@102: Got template r/1000 for Average Cell Voltage b''
2022-09-06 12:47:14,220:DEBUG:abstractprotocol:process_response@103: Processing data_type: BigHex2Short for data_name: Average Cell Voltage, raw_value b''
2022-09-06 12:47:14,220:DEBUG:abstractprotocol:process_response@175: Processing format string BigHex2Short(raw_value)
2022-09-06 12:47:14,220:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2022-09-06 12:47:14,220:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:14,221:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Int', 1, 'Number of Cells', '']
2022-09-06 12:47:14,221:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Int for data_name: Number of Cells, raw_value b''
2022-09-06 12:47:14,221:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Int(raw_value)
Traceback (most recent call last):
  File "/root/venv/mppsolar/bin/jkbms", line 8, in <module>
    sys.exit(main())
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/__init__.py", line 421, in main
    results = _device.run_command(command=_command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/devices/device.py", line 340, in run_command
    decoded_response = self._protocol.decode(raw_response, command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 460, in decode
    data_name, value, data_units = self.process_response(
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 177, in process_response
    r = eval(format_string)
  File "<string>", line 1, in <module>
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/protocol_helpers.py", line 95, in Hex2Int
    answer = hexString[0]
IndexError: index out of range

BMS 2
jkbms -p /dev/ttyUSB2 -P JK485 -n Battery-2 -b 115200 -D

2022-09-06 12:46:59,466:INFO:__init__:main@227: Solar Device Command Utility, version: 0.13.2
2022-09-06 12:46:59,466:DEBUG:__init__:main@241: MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffffb5387520>, _isConnected=False)
2022-09-06 12:46:59,467:DEBUG:__init__:main@243: udp port 5555
2022-09-06 12:46:59,467:DEBUG:__init__:main@245: Using Postgres None
2022-09-06 12:46:59,467:DEBUG:__init__:main@248: Using Mongo None with mppsolar
2022-09-06 12:46:59,467:INFO:__init__:main@350: Creating device "Battery-2" (type: "jkbms") on port "/dev/ttyUSB2 (porttype=None)" using protocol "JK485"
2022-09-06 12:46:59,493:DEBUG:__init__:main@354: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2022-09-06 12:46:59,494:DEBUG:device:__init__@33: __init__ args ()
2022-09-06 12:46:59,494:DEBUG:device:__init__@34: __init__ kwargs {'name': 'Battery-2', 'port': '/dev/ttyUSB2', 'protocol': 'JK485', 'baud': 115200, 'porttype': None, 'mqtt_broker': MqttBroker(name='localhost', port=1883, username=None, password=None, results_topic='jkbms', mqttc=<paho.mqtt.client.Client object at 0xffffb5387520>, _isConnected=False), 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2022-09-06 12:46:59,494:DEBUG:__init__:get_port_type@65: port matches ttyusb
2022-09-06 12:46:59,494:INFO:__init__:get_port@107: Using serialio for communications
2022-09-06 12:46:59,566:DEBUG:__init__:get_protocol@12: Protocol JK485
2022-09-06 12:46:59,721:DEBUG:device:__init__@38: __init__ name Battery-2, port <mppsolar.inout.serialio.SerialIO object at 0xffffb49c9c30>, protocol <mppsolar.protocols.jk485.jk485 object at 0xffffb49c9ba0>
2022-09-06 12:46:59,722:DEBUG:__init__:main@403: Commands [(<mppsolar.devices.jkbms.jkbms object at 0xffffb49c9d50>, '', '', 'screen', None, None)]
2022-09-06 12:46:59,722:INFO:__init__:main@408: Looping 1 commands
2022-09-06 12:46:59,722:INFO:__init__:main@418: Getting results from device: jkbms device - name: Battery-2, port: <mppsolar.inout.serialio.SerialIO object at 0xffffb49c9c30>, protocol: <mppsolar.protocols.jk485.jk485 object at 0xffffb49c9ba0> for command: , tag: , outputs: screen
2022-09-06 12:46:59,723:INFO:device:run_command@274: Running command 
2022-09-06 12:46:59,723:INFO:jk485:get_full_command@97: Using protocol b'JK485' with 1 commands
2022-09-06 12:46:59,723:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:46:59,723:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:46:59,724:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:46:59,724:DEBUG:jk485:get_full_command@111: cmd with header: bytearray(b'U\xaa\x00\x00\x00\x00\x00')
2022-09-06 12:46:59,724:DEBUG:jk485:get_full_command@114: cmd with header + slave address: bytearray(b'U\xaa\x01\x00\x00\x00\x00')
2022-09-06 12:46:59,725:DEBUG:jk485:get_full_command@119: cmd with command code and frame data: bytearray(b'U\xaa\x01\xff\x00\x00\x00')
2022-09-06 12:46:59,725:DEBUG:jk485:get_full_command@122: cmd with crc: bytearray(b'U\xaa\x01\xff\x00\x00\xff')
2022-09-06 12:46:59,725:INFO:device:run_command@303: full command bytearray(b'U\xaa\x01\xff\x00\x00\xff') for command getBalancerData
2022-09-06 12:46:59,725:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:46:59,725:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:46:59,725:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:46:59,726:DEBUG:serialio:send_and_receive@19: port /dev/ttyUSB2, baudrate 115200
2022-09-06 12:46:59,733:DEBUG:serialio:send_and_receive@22: Executing command via serialio...
2022-09-06 12:47:00,836:DEBUG:serialio:send_and_receive@30: serial response was: b''
2022-09-06 12:47:00,840:DEBUG:device:run_command@322: Send and Receive Response b''
2022-09-06 12:47:00,842:INFO:abstractprotocol:decode@196: response passed to decode: b''
2022-09-06 12:47:00,842:DEBUG:jkabstractprotocol:get_command_defn@106: get_command_defn for: getBalancerData
2022-09-06 12:47:00,843:DEBUG:abstractprotocol:get_command_defn@60: Processing command 'getBalancerData'
2022-09-06 12:47:00,843:DEBUG:abstractprotocol:get_command_defn@62: Found command getBalancerData in protocol b'JK485'
2022-09-06 12:47:00,843:INFO:abstractprotocol:decode@236: Processing response of type POSITIONAL
2022-09-06 12:47:00,843:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 2, 'Header', '']
2022-09-06 12:47:00,844:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Slave Address', '']
2022-09-06 12:47:00,844:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Command Code', '']
2022-09-06 12:47:00,844:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2022-09-06 12:47:00,845:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2022-09-06 12:47:00,845:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Number of Cells', '']
2022-09-06 12:47:00,845:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Highest Cell', '']
2022-09-06 12:47:00,845:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Lowest Cell', '']
2022-09-06 12:47:00,846:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Charging / Discharging', '']
2022-09-06 12:47:00,846:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Alarm - todo', '']
2022-09-06 12:47:00,846:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Difference', 'V']
2022-09-06 12:47:00,846:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Current', 'A']
2022-09-06 12:47:00,847:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Trigger Voltage', 'V']
2022-09-06 12:47:00,847:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Max Balance Current', 'A']
2022-09-06 12:47:00,847:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Balance On / Off', '']
2022-09-06 12:47:00,847:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Int', 1, 'Set Number of Cells', '']
2022-09-06 12:47:00,847:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell01', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell02', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell03', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell04', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell05', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell06', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell07', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell08', 'V']
2022-09-06 12:47:00,848:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell09', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell10', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell11', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell12', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell13', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell14', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell15', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell16', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell17', 'V']
2022-09-06 12:47:00,849:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell18', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell19', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell20', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell21', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell22', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell23', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell24', 'V']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['BigHex2Short', 2, 'Temperature', '°C']
2022-09-06 12:47:00,850:DEBUG:jkabstractprotocol:get_responses@131: Got defn: ['Hex2Str', 1, 'Checksum', '']
2022-09-06 12:47:00,850:DEBUG:abstractprotocol:decode@240: trimmed and split responses: [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2022-09-06 12:47:00,851:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,851:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 2, 'Header', '']
2022-09-06 12:47:00,851:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Header, raw_value b''
2022-09-06 12:47:00,851:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:00,851:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:00,851:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Slave Address', '']
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Slave Address, raw_value b''
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:00,852:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Str', 1, 'Command Code', '']
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Str for data_name: Command Code, raw_value b''
2022-09-06 12:47:00,852:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Str(raw_value)
2022-09-06 12:47:00,853:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to 
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:decode@431: Got defn ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:process_response@102: Got template r/100 for Total Battery Voltage b''
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:process_response@103: Processing data_type: BigHex2Short for data_name: Total Battery Voltage, raw_value b''
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:process_response@175: Processing format string BigHex2Short(raw_value)
2022-09-06 12:47:00,853:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2022-09-06 12:47:00,853:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:decode@431: Got defn ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:process_response@102: Got template r/1000 for Average Cell Voltage b''
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:process_response@103: Processing data_type: BigHex2Short for data_name: Average Cell Voltage, raw_value b''
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:process_response@175: Processing format string BigHex2Short(raw_value)
2022-09-06 12:47:00,854:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:decode@409: Processing POSITIONAL type responses
2022-09-06 12:47:00,854:DEBUG:abstractprotocol:decode@431: Got defn ['Hex2Int', 1, 'Number of Cells', '']
2022-09-06 12:47:00,855:DEBUG:abstractprotocol:process_response@103: Processing data_type: Hex2Int for data_name: Number of Cells, raw_value b''
2022-09-06 12:47:00,855:DEBUG:abstractprotocol:process_response@175: Processing format string Hex2Int(raw_value)
Traceback (most recent call last):
  File "/root/venv/mppsolar/bin/jkbms", line 8, in <module>
    sys.exit(main())
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/__init__.py", line 421, in main
    results = _device.run_command(command=_command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/devices/device.py", line 340, in run_command
    decoded_response = self._protocol.decode(raw_response, command)
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 460, in decode
    data_name, value, data_units = self.process_response(
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/abstractprotocol.py", line 177, in process_response
    r = eval(format_string)
  File "<string>", line 1, in <module>
  File "/root/venv/mppsolar/src/mppsolar/mppsolar/protocols/protocol_helpers.py", line 95, in Hex2Int
    answer = hexString[0]
IndexError: index out of range

@sw25481
Copy link

sw25481 commented May 14, 2023

Lot of threads on this same subject. I have a working setup with SolarEdge and the symple Python script from this site https://github.com/fah/jk-bms with the config

bms = serial.Serial('/dev/ttyUSB1')
bms.baudrate = 115200
bms.timeout  = 0.2

but I get

jkbms -p /dev/ttyUSB1 -P JK485 -b 115200 -D

2023-05-14 21:58:10,627:INFO:init:main@214: Solar Device Command Utility, version: 0.15.57
2023-05-14 21:58:10,630:DEBUG:mqttbrokerc:init@29: mqttbroker config: {'name': 'localhost', 'port': 1883, 'user': None, 'pass': None}
2023-05-14 21:58:10,635:DEBUG:init:main@239: MqttBroker name: localhost, port: 1883, user: None
2023-05-14 21:58:10,639:DEBUG:init:main@241: udp port 5555
2023-05-14 21:58:10,644:DEBUG:init:main@243: Using Postgres None
2023-05-14 21:58:10,649:DEBUG:init:main@246: Using Mongo None with mppsolar
2023-05-14 21:58:10,653:INFO:init:main@347: Creating device "unnamed" (type: "jkbms") on port "/dev/ttyUSB1 (porttype=None)" using protocol "JK485"
2023-05-14 21:58:10,688:DEBUG:init:main@351: device_class <class 'mppsolar.devices.jkbms.jkbms'>
2023-05-14 21:58:10,691:DEBUG:device:init@33: init args ()
2023-05-14 21:58:10,696:DEBUG:device:init@34: init kwargs {'name': 'unnamed', 'port': '/dev/ttyUSB1', 'protocol': 'JK485', 'baud': 115200, 'porttype': None, 'mqtt_broker': <mppsolar.libs.mqttbrokerc.MqttBroker object at 0xb5cfff58>, 'udp_port': '5555', 'mongo_url': None, 'mongo_db': 'mppsolar'}
2023-05-14 21:58:10,700:DEBUG:init:get_port_type@73: port matches ttyusb
2023-05-14 21:58:10,705:INFO:init:get_port@121: Using serialio for communications
2023-05-14 21:58:10,755:DEBUG:init:get_protocol@13: Protocol JK485
2023-05-14 21:58:11,620:DEBUG:device:init@38: init name unnamed, port <mppsolar.inout.serialio.SerialIO object at 0xb5cfffa0>, protocol JKBMS RS485 serial communication protocol handler
2023-05-14 21:58:11,623:DEBUG:init:main@402: Commands [(<mppsolar.devices.jkbms.jkbms object at 0xb5cfff70>, '', '', 'screen', None, None)]
2023-05-14 21:58:11,626:INFO:init:main@407: Looping 1 commands
2023-05-14 21:58:11,629:INFO:init:main@417: Getting results from device: jkbms device - name: unnamed, port: <mppsolar.inout.serialio.SerialIO object at 0xb5cfffa0>, protocol: JKBMS RS485 serial communication protocol handler for command: , tag: , outputs: screen
2023-05-14 21:58:11,635:INFO:device:run_command@50: Running command
2023-05-14 21:58:11,640:INFO:jk485:get_full_command@100: Using protocol b'JK485' with 1 commands
2023-05-14 21:58:11,644:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getBalancerData
2023-05-14 21:58:11,648:DEBUG:abstractprotocol:get_command_defn@65: Processing command 'getBalancerData'
2023-05-14 21:58:11,654:DEBUG:abstractprotocol:get_command_defn@67: Found command getBalancerData in protocol b'JK485'
2023-05-14 21:58:11,659:DEBUG:jk485:get_full_command@114: cmd with header: bytearray(b'U\xaa\x00\x00\x00\x00\x00')
2023-05-14 21:58:11,663:DEBUG:jk485:get_full_command@117: cmd with header + slave address: bytearray(b'U\xaa\x01\x00\x00\x00\x00')
2023-05-14 21:58:11,667:DEBUG:jk485:get_full_command@122: cmd with command code and frame data: bytearray(b'U\xaa\x01\xff\x00\x00\x00')
2023-05-14 21:58:11,672:DEBUG:jk485:get_full_command@125: cmd with crc: bytearray(b'U\xaa\x01\xff\x00\x00\xff')
2023-05-14 21:58:11,676:INFO:device:run_command@78: full command bytearray(b'U\xaa\x01\xff\x00\x00\xff') for command getBalancerData
2023-05-14 21:58:11,680:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getBalancerData
2023-05-14 21:58:11,685:DEBUG:abstractprotocol:get_command_defn@65: Processing command 'getBalancerData'
2023-05-14 21:58:11,689:DEBUG:abstractprotocol:get_command_defn@67: Found command getBalancerData in protocol b'JK485'
2023-05-14 21:58:11,694:DEBUG:serialio:send_and_receive@19: port /dev/ttyUSB1, baudrate 115200
2023-05-14 21:58:11,703:DEBUG:serialio:send_and_receive@22: Executing command via serialio...
2023-05-14 21:58:12,811:DEBUG:serialio:send_and_receive@30: serial response was: b''
2023-05-14 21:58:12,820:DEBUG:device:run_command@95: Send and Receive Response b''
2023-05-14 21:58:12,826:INFO:abstractprotocol:decode@224: response passed to decode: b''
2023-05-14 21:58:12,832:DEBUG:jkabstractprotocol:get_command_defn@105: get_command_defn for: getBalancerData
2023-05-14 21:58:12,838:DEBUG:abstractprotocol:get_command_defn@65: Processing command 'getBalancerData'
2023-05-14 21:58:12,844:DEBUG:abstractprotocol:get_command_defn@67: Found command getBalancerData in protocol b'JK485'
2023-05-14 21:58:12,850:INFO:abstractprotocol:decode@268: Processing response of type POSITIONAL
2023-05-14 21:58:12,855:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 2, 'Header', '']
2023-05-14 21:58:12,862:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Slave Address', '']
2023-05-14 21:58:12,868:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Command Code', '']
2023-05-14 21:58:12,874:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2023-05-14 21:58:12,880:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2023-05-14 21:58:12,886:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Int', 1, 'Number of Cells', '']
2023-05-14 21:58:12,892:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Int', 1, 'Highest Cell', '']
2023-05-14 21:58:12,899:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Int', 1, 'Lowest Cell', '']
2023-05-14 21:58:12,905:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Charging / Discharging', '']
2023-05-14 21:58:12,911:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Alarm - todo', '']
2023-05-14 21:58:12,917:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Difference', 'V']
2023-05-14 21:58:12,923:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Current', 'A']
2023-05-14 21:58:12,927:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Balance Trigger Voltage', 'V']
2023-05-14 21:58:12,932:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Max Balance Current', 'A']
2023-05-14 21:58:12,936:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Balance On / Off', '']
2023-05-14 21:58:12,941:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Int', 1, 'Set Number of Cells', '']
2023-05-14 21:58:12,945:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell01', 'V']
2023-05-14 21:58:12,950:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell02', 'V']
2023-05-14 21:58:12,954:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell03', 'V']
2023-05-14 21:58:12,957:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell04', 'V']
2023-05-14 21:58:12,962:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell05', 'V']
2023-05-14 21:58:12,966:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell06', 'V']
2023-05-14 21:58:12,970:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell07', 'V']
2023-05-14 21:58:12,975:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell08', 'V']
2023-05-14 21:58:12,979:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell09', 'V']
2023-05-14 21:58:12,984:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell10', 'V']
2023-05-14 21:58:12,987:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell11', 'V']
2023-05-14 21:58:12,992:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell12', 'V']
2023-05-14 21:58:12,996:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell13', 'V']
2023-05-14 21:58:13,001:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell14', 'V']
2023-05-14 21:58:13,005:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell15', 'V']
2023-05-14 21:58:13,010:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell16', 'V']
2023-05-14 21:58:13,014:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell17', 'V']
2023-05-14 21:58:13,018:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell18', 'V']
2023-05-14 21:58:13,022:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell19', 'V']
2023-05-14 21:58:13,027:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell20', 'V']
2023-05-14 21:58:13,031:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell21', 'V']
2023-05-14 21:58:13,035:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell22', 'V']
2023-05-14 21:58:13,040:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell23', 'V']
2023-05-14 21:58:13,044:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short:r/1000', 2, 'Voltage Cell24', 'V']
2023-05-14 21:58:13,048:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['BigHex2Short', 2, 'Temperature', '°C']
2023-05-14 21:58:13,053:DEBUG:jkabstractprotocol:get_responses@127: Got defn: ['Hex2Str', 1, 'Checksum', '']
2023-05-14 21:58:13,057:DEBUG:abstractprotocol:decode@272: trimmed and split responses: [b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']
2023-05-14 21:58:13,061:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,066:DEBUG:abstractprotocol:decode@499: Got defn ['Hex2Str', 2, 'Header', '']
2023-05-14 21:58:13,070:DEBUG:abstractprotocol:process_response@112: Processing data_type: Hex2Str for data_name: Header, raw_value b''
2023-05-14 21:58:13,074:DEBUG:abstractprotocol:process_response@201: Processing format string Hex2Str(raw_value)
2023-05-14 21:58:13,080:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to
2023-05-14 21:58:13,084:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,088:DEBUG:abstractprotocol:decode@499: Got defn ['Hex2Str', 1, 'Slave Address', '']
2023-05-14 21:58:13,093:DEBUG:abstractprotocol:process_response@112: Processing data_type: Hex2Str for data_name: Slave Address, raw_value b''
2023-05-14 21:58:13,097:DEBUG:abstractprotocol:process_response@201: Processing format string Hex2Str(raw_value)
2023-05-14 21:58:13,102:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to
2023-05-14 21:58:13,106:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,110:DEBUG:abstractprotocol:decode@499: Got defn ['Hex2Str', 1, 'Command Code', '']
2023-05-14 21:58:13,115:DEBUG:abstractprotocol:process_response@112: Processing data_type: Hex2Str for data_name: Command Code, raw_value b''
2023-05-14 21:58:13,119:DEBUG:abstractprotocol:process_response@201: Processing format string Hex2Str(raw_value)
2023-05-14 21:58:13,124:DEBUG:protocol_helpers:Hex2Str@109: Hex b'' decoded to
2023-05-14 21:58:13,128:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,132:DEBUG:abstractprotocol:decode@499: Got defn ['BigHex2Short:r/100', 2, 'Total Battery Voltage', 'V']
2023-05-14 21:58:13,136:DEBUG:abstractprotocol:process_response@111: Got template r/100 for Total Battery Voltage b''
2023-05-14 21:58:13,140:DEBUG:abstractprotocol:process_response@112: Processing data_type: BigHex2Short for data_name: Total Battery Voltage, raw_value b''
2023-05-14 21:58:13,144:DEBUG:abstractprotocol:process_response@201: Processing format string BigHex2Short(raw_value)
2023-05-14 21:58:13,149:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2023-05-14 21:58:13,154:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,159:DEBUG:abstractprotocol:decode@499: Got defn ['BigHex2Short:r/1000', 2, 'Average Cell Voltage', 'V']
2023-05-14 21:58:13,162:DEBUG:abstractprotocol:process_response@111: Got template r/1000 for Average Cell Voltage b''
2023-05-14 21:58:13,167:DEBUG:abstractprotocol:process_response@112: Processing data_type: BigHex2Short for data_name: Average Cell Voltage, raw_value b''
2023-05-14 21:58:13,171:DEBUG:abstractprotocol:process_response@201: Processing format string BigHex2Short(raw_value)
2023-05-14 21:58:13,177:INFO:protocol_helpers:BigHex2Short@148: Hex encoded value must be 2 bytes long. Was 0 length
2023-05-14 21:58:13,181:DEBUG:abstractprotocol:decode@472: Processing POSITIONAL type responses
2023-05-14 21:58:13,185:DEBUG:abstractprotocol:decode@499: Got defn ['Hex2Int', 1, 'Number of Cells', '']
2023-05-14 21:58:13,189:DEBUG:abstractprotocol:process_response@112: Processing data_type: Hex2Int for data_name: Number of Cells, raw_value b''
2023-05-14 21:58:13,194:DEBUG:abstractprotocol:process_response@201: Processing format string Hex2Int(raw_value)
Traceback (most recent call last):
File "/usr/local/bin/jkbms", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/dist-packages/mppsolar/init.py", line 420, in main
results = _device.run_command(command=_command)
File "/usr/local/lib/python3.9/dist-packages/mppsolar/devices/device.py", line 112, in run_command
decoded_response = self._protocol.decode(raw_response, command)
File "/usr/local/lib/python3.9/dist-packages/mppsolar/protocols/abstractprotocol.py", line 532, in decode
processed_responses = self.process_response(
File "/usr/local/lib/python3.9/dist-packages/mppsolar/protocols/abstractprotocol.py", line 203, in process_response
r = eval(format_string)
File "", line 1, in
File "/usr/local/lib/python3.9/dist-packages/mppsolar/protocols/protocol_helpers.py", line 95, in Hex2Int
answer = hexString[0]
IndexError: index out of range

@jblance jblance removed this from the 0.20 release - jkbms serial milestone Jun 23, 2023
@lukolszewski
Copy link
Contributor

Same here. "jkbms -p XX:XX:XX:XX:XX -P JK02_32 -I -c getCellData" reads fine via bluetooth. but no combination of protocol use works with the serial port. At the same time sending byte strings like '4E 57 00 13 00 00 00 00 06 03 00 00 00 00 00 00 68 00 00 01 29' returns all the data (at 115200 baud).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

5 participants