Skip to content

Commit

Permalink
get_device_info: correctlz decode string for device name
Browse files Browse the repository at this point in the history
...and adapt nxtfilemgr accordingly
  • Loading branch information
codestruct committed Apr 21, 2018
1 parent e4c734b commit 79499ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nxt/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_device_info(opcode):

def _parse_get_device_info(tgram):
tgram.check_status()
name = tgram.parse_string(15)
name = tgram.parse_string(15).decode('windows-1252').split('\0')[0]
a0 = tgram.parse_u8()
a1 = tgram.parse_u8()
a2 = tgram.parse_u8()
Expand Down
8 changes: 3 additions & 5 deletions scripts/nxtfilemgr
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,11 @@ class NXT_FileMgr(Gtk.Window):
prot_version, fw_version = self.brick.get_firmware_version()
print("Protocol version: %s.%s" % prot_version)
if prot_version == PROTOCOL_VER:
brick_name_b, brick_hostid, brick_signal_strength, brick_user_flash = self.brick.get_device_info()
brick_name, brick_hostid, brick_signal_strength, brick_user_flash = self.brick.get_device_info()
connection_type = str(self.brick.sock)
brick_name_str = brick_name_b.decode('windows-1252')
print("brick_name_b = {0}, brick_name_str = {1}".format(brick_name_b, brick_name_str))
if DEBUG:
print("Brick Info: ", connection_type, brick_name_str, brick_hostid, brick_signal_strength, fw_version, brick_user_flash)
self.brick_info_str = "%s ==> %s [%s]\tFirmware: v%s.%s\tFreespace: %s" % (connection_type, brick_name_str, brick_hostid, fw_version[0], fw_version[1], brick_user_flash)
print("Brick Info: ", connection_type, brick_name, brick_hostid, brick_signal_strength, fw_version, brick_user_flash)
self.brick_info_str = "%s ==> %s [%s]\tFirmware: v%s.%s\tFreespace: %s" % (connection_type, brick_name, brick_hostid, fw_version[0], fw_version[1], brick_user_flash)
else:
print("Invalid Protocol version! Closing connection.")
self.do_housekeeping()
Expand Down

0 comments on commit 79499ac

Please sign in to comment.