lmandres / GT06ScannerClient

GNU General Public License v3.0
4 stars 6 forks source link

Cannot convert incoming message #3

Closed Artiom-M closed 3 years ago

Artiom-M commented 3 years ago

I am getting this while communicating with traccar server.

Namespace(config='config.xml', id=None, server_address=None, server_port=None, update_delay=None, gps_port=None, gps_baud=None, maps_url=None)
(protocolIn :: messageIn) 1 :: 012589567
crc failed 00010125895670001
messageOut: 78780001012589567000100000d0a
Traceback (most recent call last):
  File "/home/artiom/Projects/GPS/GT06ScannerClient/runClient.py", line 69, in <module>
    scanner.connectDevices()
  File "/home/artiom/Projects/GPS/GT06ScannerClient/GT06ScannerClient.py", line 77, in connectDevices
    self.gt06Client.sendLoginMessage(
  File "/home/artiom/Projects/GPS/GT06ScannerClient/gt06Client.py", line 126, in sendLoginMessage
    self.socket.sendall(self.makeBasicMessage(1, imeiIn))
  File "/home/artiom/Projects/GPS/GT06ScannerClient/gt06Client.py", line 85, in makeBasicMessage
    returnBytes = bytes.fromhex(messageOut)
ValueError: non-hexadecimal number found in fromhex() arg at position 29

looks like messageOut has impair number of characters

Artiom-M commented 3 years ago

This happens then device ID has impair number of digits

lmandres commented 3 years ago

Hi @Artiom-M ,

I started to do some error checking on the input for the serial numbers, but I let it pass and tried to adjust on the config.xml file. The error checking is at the line below:

https://github.com/lmandres/GT06ScannerClient/blob/master/gt06Client.py#L60

Can you get it to pass by adjusting the scanner ID number in the config.xml?

Thanks, lmandres

Artiom-M commented 3 years ago

Yes, I can make it pass if I change it to contain pair number of chars. So it's not blocking. Just 2 points:

  1. I could be good to put a comment to the default config that this number is considered HEX
  2. Validate and write an appropriate message.

I may have some time in coming days and make a patch if you don't mind

lmandres commented 3 years ago

@Artiom-M, sure! Feel free to send me a pull request when you have it done. Thanks!

lmandres commented 3 years ago

Issue addressed by @Artiom-M in #4