spacemanspiff2007 / SmlLib

A library for the SML (Smart Message Language) protocol
GNU General Public License v3.0
27 stars 9 forks source link

ValueError: Last Entry is not <EndofSmlMsg>! Something went wrong! #1

Closed TheYttrium closed 3 years ago

TheYttrium commented 3 years ago

Hello, Thanks for your work.

I get the following error message:

[2021-05-30 14:27:00,675] [sml.device.ttyUSB0 ] ERROR | Traceback (most recent call last): [2021-05-30 14:27:00,676] [sml.device.ttyUSB0 ] ERROR | File "/home/pi/.local/lib/python3.9/site-packages/sml2mqtt/sml_device.py", line 81, in read [2021-05-30 14:27:00,676] [sml.device.ttyUSB0 ] ERROR | for obj in frame.parse_frame(): [2021-05-30 14:27:00,677] [sml.device.ttyUSB0 ] ERROR | File "/home/pi/.local/lib/python3.9/site-packages/smllib/sml_frame.py", line 114, in parse_frame [2021-05-30 14:27:00,678] [sml.device.ttyUSB0 ] ERROR | raise ValueError(f'Last Entry is not {EndofSmlMsg}! Something went wrong!') [2021-05-30 14:27:00,679] [sml.device.ttyUSB0 ] ERROR | ValueError: Last Entry is not ! Something went wrong!

My Data is

b'v\x04\x00\x00\x01b\x00b\x00re\x00\x00\x01\x01v\x01\x01\x07\x00\x00\x02\xdaTM\x0b\n\x01HLY\x02\x00\x04$\xa0\x01\x01c~h\x00v\x04\x00\x00\x02b\x00b\x00re\x00\x00\x07\x01w\x01\x0b\n\x01HLY\x02\x00\x04$\xa0\x01\x01\xf1\x04w\x07\x01\x00`2\x01\x01\x01\x01\x01\x01\x04HLY\x01w\x07\x01\x00`\x01\x00\xff\x01\x01\x01\x01\x0b\n\x01HLY\x02\x00\x04$\xa0\x01w\x07\x01\x00\x01\x08\x00\xffe\x00\x1c\x81\x04e\x02\xdaTMb\x1eR\xffe\x02\xad\x94T\x01w\x07\x01\x00\x02\x08\x00\xffe\x00\x1c\x81\x04e\x02\xdaTMb\x1eR\xffb\x00\x01w\x07\x01\x00\x10\x07\x00\xff\x01\x01b\x1bR\x00S\x00\x9d\x01w\x07\x01\x00 \x07\x00\xff\x01\x01b#R\xffc\t*\x01w\x07\x01\x004\x07\x00\xff\x01\x01b#R\xffc\t&\x01w\x07\x01\x00H\x07\x00\xff\x01\x01b#R\xffc\t-\x01w\x07\x01\x00\x1f\x07\x00\xff\x01\x01b!R\xfeb*\x01w\x07\x01\x003\x07\x00\xff\x01\x01b!R\xfebW\x01w\x07\x01\x00G\x07\x00\xff\x01\x01b!R\xfebF\x01w\x07\x01\x00Q\x07\x01\xff\x01\x01b\x08R\x00b\xf0\x01w\x07\x01\x00Q\x07\x02\xff\x01\x01b\x08R\x00bx\x01w\x07\x01\x00Q\x07\x04\xff\x01\x01b\x08R\x00c\x01\x14\x01w\x07\x01\x00Q\x07\x0f\xff\x01\x01b\x08R\x00c\x018\x01w\x07\x01\x00Q\x07\x1a\xff\x01\x01b\x08R\x00c\x01\x1e\x01w\x07\x01\x00\x0e\x07\x00\xff\x01\x01b,R\xffc\x01\xf4\x01w\x07\x01\x00\x00\x02\x00\x00\x01\x01\x01\x01\t1.02.007\x01w\x07\x01\x00`Z\x02\x01\x01\x01\x01\x01\x05A01A\x01w\x07\x01\x00`\x05\x00\xff\x01\x01\x01\x01e\x00\x1c\x81\x04\x01\x01\x01c#b\x00v\x04\x00\x00\x03b\x00b\x00re\x00\x00\x02\x01q\x01c\xe8#\x00'

The EndofSMLMsg comes in the wrong place.

['000002', 0, 0, [1793, [None, '0a01484c5902000424a0', None, None, ['770701', <EndofSmlMsg>, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 0]], 0, 0]

Can you help ?

spacemanspiff2007 commented 3 years ago

You have to call get_frame of SmlStreamReader first.

Can you provide a proper code sample and the raw data (use b2a_hex from binascii)? Your data is not a valid sml frame.

TheYttrium commented 3 years ago

Thanks, to exclude errors from me I use sml2mqtt . From get_frame my raw data is

b'\x1b\x1b\x1b\x1b\x01\x01\x01\x01v\x04\x00\x00\x01b\x00b\x00re\x00\x00\x01\x01v\x01\x01\x07\x00\x00\x02\xdb\xa2<\x0b\n\x01HLY\x02\x00\x04$\xa0\x01\x01c\x94[\x00v\x04\x00\x00\x02b\x00b\x00re\x00\x00\x07\x01w\x01\x0b\n\x01HLY\x02\x00\x04$\xa0\x01\x01\xf1\x04w\x07\x01\x002\x01\x01\x01\x01\x01\x01\x04HLY\x01w\x07\x01\x00\x01\x00\xff\x01\x01\x01\x01\x0b\n\x01HLY\x02\x00\x04$\xa0\x01w\x07\x01\x00\x01\x08\x00\xffe\x00\x1c\x81\x04e\x02\xdb\xa2=b\x1eR\xffe\x02\xae\xa12\x01w\x07\x01\x00\x02\x08\x00\xffe\x00\x1c\x81\x04e\x02\xdb\xa2=b\x1eR\xffb\x00\x01w\x07\x01\x00\x10\x07\x00\xff\x01\x01b\x1bR\x00S\x00\x89\x01w\x07\x01\x00 \x07\x00\xff\x01\x01b#R\xffc\t(\x01w\x07\x01\x004\x07\x00\xff\x01\x01b#R\xffc\t)\x01w\x07\x01\x00H\x07\x00\xff\x01\x01b#R\xffc\t"\x01w\x07\x01\x00\x1f\x07\x00\xff\x01\x01b!R\xfeb)\x01w\x07\x01\x003\x07\x00\xff\x01\x01b!R\xfebN\x01w\x07\x01\x00G\x07\x00\xff\x01\x01b!R\xfeb.\x01w\x07\x01\x00Q\x07\x01\xff\x01\x01b\x08R\x00b\xf0\x01w\x07\x01\x00Q\x07\x02\xff\x01\x01b\x08R\x00bx\x01w\x07\x01\x00Q\x07\x04\xff\x01\x01b\x08R\x00c\x01\x10\x01w\x07\x01\x00Q\x07\x0f\xff\x01\x01b\x08R\x00c\x018\x01w\x07\x01\x00Q\x07\x1a\xff\x01\x01b\x08R\x00c\x01\x11\x01w\x07\x01\x00\x0e\x07\x00\xff\x01\x01b,R\xffc\x01\xf4\x01w\x07\x01\x00\x00\x02\x00\x00\x01\x01\x01\x01\t1.02.007\x01w\x07\x01\x00Z\x02\x01\x01\x01\x01\x01\x05A01A\x01w\x07\x01\x00\x05\x00\xff\x01\x01\x01\x01e\x00\x1c\x81\x04\x01\x01\x01c\xfc\x1e\x00v\x04\x00\x00\x03b\x00b\x00re\x00\x00\x02\x01q\x01c\xe8#\x00\x00\x00\x1b\x1b\x1b\x1b\x1a\x02"\xed'

spacemanspiff2007 commented 3 years ago

fixed with 0.5

spacemanspiff2007 commented 3 years ago

sml2mqtt is available as 0.2