From ea9412ffc2c0c7164b95c6106784299c81527fee Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Tue, 5 Apr 2022 23:13:47 +0200 Subject: [PATCH] update python test script to support utf8 --- test-msg-gen.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-msg-gen.py b/test-msg-gen.py index 30f6f0b7..10760271 100644 --- a/test-msg-gen.py +++ b/test-msg-gen.py @@ -5,7 +5,7 @@ import codecs print("Calculate NSPanel hex command from JSON payload\n") #value = input("Enter JSON:\n") -value = "entityUpdHeading,Heading1234" +value = "weatherUpdate~1~9.4 C~Wed~2~14.1 C~Thu~3~12.4 C~Fri~4~7.6 C~Sat~5~8.5 C~6~90 %" def crc16(data:bytes, poly:hex=0xA001) -> str: ''' @@ -21,13 +21,13 @@ def crc16(data:bytes, poly:hex=0xA001) -> str: return crc -payload = bytes(value, 'ascii') +payload = bytes(value, 'utf-8') header = binascii.unhexlify('55BB') -print("length:", len(value)) +print("length:", len(payload)) -length = len(value).to_bytes(2, 'little') +length = len(payload).to_bytes(2, 'little') bytes_payload = header + length + payload