iSpindel-TCP-Server icon indicating copy to clipboard operation
iSpindel-TCP-Server copied to clipboard

Server on Python3 - changes required

Open BaggyLala opened this issue 6 years ago • 3 comments

The code as it stands doesnt like sending the NAKs or AKs

eg.

in handler clientsock.send(NAK) TypeError: a bytes-like object is required, not 'str'

so I commented this out (line 104 i think) and found that the string being received is as follows received:b'{' which looks like the ispindel is sending the code to convert a { into a byte value rather than the actual { so if I bypass this as its essentially sending the { and change the check to

if inpstr[2] != "{" :

then things continue to the next step and I get stuff like

         _('xxx.xxx.xxx.xxx', 2043) received:b'"name":"iSpindel001","ID":748188,"angle":73.62824,"temperature":32.375,"battery":4.035453,"gravity":1.239934,"interval":30,"RSSI":-49}\r\n'

('xxx.xxx.xxx.xxx', 2043) Not JSON. ('xxx.xxx.xxx.xxx', 2043) - closed connection_

So two questions

  1. How best to fix the original NAK issue (& do I need to fork a seperate version for Python 3)?
  2. Is the problem of the extra characters with the iSpindel software (Sorry I know nothing of JSON yet)?

iSpindel is at 5.85

BaggyLala avatar May 02 '18 12:05 BaggyLala

I will look into this. It might have to do with Python 3 indeed as I have not noticed this behaviour with 2.7. I am currently working on this part of the code anyway, so stay tuned and thanks for the info!

DottoreTozzi avatar May 06 '18 03:05 DottoreTozzi

We'll switch to Python3 with the next release.

DottoreTozzi avatar Jun 19 '19 03:06 DottoreTozzi

Any word on Python 3?

I would be happy to contribute if you don't have the time...

rhys-ender avatar Sep 21 '19 00:09 rhys-ender