sshoecraft / jbdtool

JBD BMS Linux utility
BSD 3-Clause "New" or "Revised" License
46 stars 10 forks source link

No answer on command #9

Open WoeMat opened 2 years ago

WoeMat commented 2 years ago

Hi there. I'm also working on my powerwall and I'm also using some JBD BMS (mine have firmware version 22). I could compile an install jbdtools and if I use the serial connector I can also read data from the BMS but somehow it is not being displayed.

If I read the datat with the -r -a options I get everything on screen.

jbdtool -t serial:/dev/ttyUSB0,9600 -d 9
main.c(829) main: transport: 0x7e9167e4, target: 0x7e9167eb
main.c(855) main: transport: serial
module.c(51) mybmm_load_module: NOT found.
module.c(72) mybmm_load_module: init: 0x26298
module.c(79) mybmm_load_module: adding module: serial
main.c(858) main: tp: 0x3f60c
module.c(45) mybmm_load_module: mp->name: serial, mp->type: 2
module.c(51) mybmm_load_module: NOT found.
module.c(72) mybmm_load_module: init: 0x1ab8c
module.c(79) mybmm_load_module: adding module: jbd
main.c(861) main: cp: 0x3f564
jbd.c(416) jbd_new: transport: serial
jbd.c(425) jbd_new: pp->target: /dev/ttyUSB0, pp->opts: 9600
serial.c(99) serial_new: target: /dev/ttyUSB0
serial.c(160) serial_new: target: /dev/ttyUSB0, speed: 9600, data: 8, parity: N, stop: 1, vmin: 0, vtime: 5
main.c(878) main: p: 0x7e9167ef, target: 0x7e9167eb
main.c(880) main: lockfile: /tmp/ttyUSB0.lock
main.c(882) main: lockfd: 3
main.c(889) main: charge: -1, discharge: -1
main.c(912) main: reset: 0
main.c(928) main: mqtt: (nil)
main.c(978) main: outfp: 0x1a6190
jbd.c(436) jbd_open: opening...
serial.c(256) serial_open: target: /dev/ttyUSB0
serial.c(264) serial_open: path: /dev/ttyUSB0
serial.c(171) set_interface_attribs: fd: 4, speed: 9600, data: 8, parity: 0, stop: 1, vmin: 0, vtime: 5
jbd_info.c(289) jbd_get_info: transport: serial
jbd.c(296) jbd_rw: action: a5, reg: 3, data: 0x7e915b60, datasz: 256
jbd.c(95) jbd_cmd: action: a5, reg: 3, data: 0x7e915b60, len: 0
jbd.c(37) jbd_crc: len: 2
jbd.c(38) jbd_crc: crc: 0
jbd.c(40) jbd_crc: crc: fffd
jbd.c(110) jbd_cmd: returning: 7
cmd(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(303) jbd_rw: retries: 5
jbd.c(308) jbd_rw: writing...
serial.c(465) serial_write: buf: 0x7e915a0c, buflen: 7
serial.c(471) serial_write: bytes: 7
TO DEVICE(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(310) jbd_rw: bytes: 7
serial.c(381) serial_read: buf: 0x7e91590c, buflen: 256
serial.c(448) serial_read: returning: 0
jbd.c(313) jbd_rw: bytes: 0
jbd.c(49) jbd_verify: len: 0
jbd.c(303) jbd_rw: retries: 4
jbd.c(308) jbd_rw: writing...
serial.c(465) serial_write: buf: 0x7e915a0c, buflen: 7
serial.c(471) serial_write: bytes: 7
TO DEVICE(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(310) jbd_rw: bytes: 7
serial.c(381) serial_read: buf: 0x7e91590c, buflen: 256
FROM DEVICE(16):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00 00 2C 64    ...........p..,d
serial.c(448) serial_read: returning: 16
jbd.c(313) jbd_rw: bytes: 16
jbd.c(49) jbd_verify: len: 16
verify(16):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00 00 2C 64    ...........p..,d
jbd.c(55) jbd_verify: start bit: dd
jbd.c(58) jbd_verify: register: 3, wanted: 3
jbd.c(61) jbd_verify: status: 0
jbd.c(66) jbd_verify: data_length: 27, len - 7: 9
jbd.c(303) jbd_rw: retries: 3
jbd.c(308) jbd_rw: writing...
serial.c(465) serial_write: buf: 0x7e915a0c, buflen: 7
serial.c(471) serial_write: bytes: 7
TO DEVICE(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(310) jbd_rw: bytes: 7
serial.c(381) serial_read: buf: 0x7e91590c, buflen: 256
FROM DEVICE(12):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70                ...........p
serial.c(448) serial_read: returning: 12
jbd.c(313) jbd_rw: bytes: 12
jbd.c(49) jbd_verify: len: 12
verify(12):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70                ...........p
jbd.c(55) jbd_verify: start bit: dd
jbd.c(58) jbd_verify: register: 3, wanted: 3
jbd.c(61) jbd_verify: status: 0
jbd.c(66) jbd_verify: data_length: 27, len - 7: 5
jbd.c(303) jbd_rw: retries: 2
jbd.c(308) jbd_rw: writing...
serial.c(465) serial_write: buf: 0x7e915a0c, buflen: 7
serial.c(471) serial_write: bytes: 7
TO DEVICE(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(310) jbd_rw: bytes: 7
serial.c(381) serial_read: buf: 0x7e91590c, buflen: 256
FROM DEVICE(13):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00             ...........p.
serial.c(448) serial_read: returning: 13
jbd.c(313) jbd_rw: bytes: 13
jbd.c(49) jbd_verify: len: 13
verify(13):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00             ...........p.
jbd.c(55) jbd_verify: start bit: dd
jbd.c(58) jbd_verify: register: 3, wanted: 3
jbd.c(61) jbd_verify: status: 0
jbd.c(66) jbd_verify: data_length: 27, len - 7: 6
jbd.c(303) jbd_rw: retries: 1
jbd.c(308) jbd_rw: writing...
serial.c(465) serial_write: buf: 0x7e915a0c, buflen: 7
serial.c(471) serial_write: bytes: 7
TO DEVICE(7):
0000: DD A5 03 00 FF FD 77                               ......w
jbd.c(310) jbd_rw: bytes: 7
serial.c(381) serial_read: buf: 0x7e91590c, buflen: 256
FROM DEVICE(13):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00             ...........p.
serial.c(448) serial_read: returning: 13
jbd.c(313) jbd_rw: bytes: 13
jbd.c(49) jbd_verify: len: 13
verify(13):
0000: DD 03 00 1B 10 E1 00 00 0A 13 17 70 00             ...........p.
jbd.c(55) jbd_verify: start bit: dd
jbd.c(58) jbd_verify: register: 3, wanted: 3
jbd.c(61) jbd_verify: status: 0
jbd.c(66) jbd_verify: data_length: 27, len - 7: 6
jbd.c(303) jbd_rw: retries: 0
jbd.c(305) jbd_rw: returning: -1
serial.c(485) serial_close: fd: 4
main.c(1272) main: unlocking target
sshoecraft commented 2 years ago

just looking at request/response it seems like its not reading enough data (the data length being sent back from the device is 27 (1B hex) yet only 6 bytes (of data) were read (short read) and no checksum bytes.

Check and re-check your serial connection - you definitely need ground and cross TX/RX.

WoeMat commented 2 years ago

Yes, that's exactly whats wondering me. Can I somehow change the serial timeout settings? Maybe the software stops reading because it takes too long. I also have Node-Red running on that Pi and if I send the command there I recieve the complete Answer without changing anything on the Hardware. grafik

sshoecraft commented 2 years ago

That definitely looks like the correct data being returned. What settings are you using in node-red?

You can set the serial params when specifying the device:

-t serial:(device), baud rate, data bits, parity, stop bits, vmin, vtime

baud = 1200 to 4000000 data bits = 8 parity = N)one, E)ven, O)dd stop bits = 1 to 8 vmin = 0-9999 vtime = 0-9999

VMIN Minimum number of characters for noncanonical read VTIME Timeout in deciseconds for noncanonical read

for example: jbdtool -t serial:/dev/ttyS0,9600,8,N,1,0,15

sshoecraft commented 2 years ago

If all else fails, you can modify serial.c, line 415 and 416:

from: tv.tv_usec = 500000; tv.tv_sec = 0;

to: tv.tv_usec = 0; tv.tv_sec = 1;

and see if that works. I just looked at the serial code ... its kind of messy.

sshoecraft commented 1 year ago

did this work for you?