I am working on editing this package from python 2 to python 3 because I need use KivyMD, which only support python3.
source code can be found here: [https://github.com/groner/pythinkgear/tree/master/thinkgear]
When running under python 2, it can output the desired results like this:
DEBUG:__main__:ASIC EEG Power: EEGPowerData(delta=3656, theta=5612, lowalpha=697, highalpha=3450, lowbeta=6125, highbeta=5826, lowgamma=2728, midgamma=53552)
DEBUG:__main__:ATTENTION eSense: 0
DEBUG:__main__:MEDITATION eSense: 0
DEBUG:__main__:POOR SIGNAL: 200
DEBUG:__main__:ASIC EEG Power: EEGPowerData(delta=1340, theta=5046, lowalpha=4464, highalpha=5822, lowbeta=2467, highbeta=4815, lowgamma=8844, midgamma=57809)
DEBUG:__main__:ATTENTION eSense: 0
DEBUG:__main__:MEDITATION eSense: 0
In order to make it run on python 3, I edited line 31 to this:
from io import StringIO ## for Python 3
and line 91 from:
_bytelog.debug('%04X '+' '.join(('%02X',)*len(buf[o:o+16])), o, *( ord(c) for c in buf[o:o+16] ))
to this:
_bytelog.debug('%04X '+' '.join(('%02X',)*len(buf[o:o+16])), o, *(c for c in buf[o:o+16]))
also I have changed all "xrange" function to "range".
But the result I get(without any error reported) is this:
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing
DEBUG:__main__:discarding b'x80' while syncing
DEBUG:__main__:discarding b'x02' while syncing
DEBUG:__main__:discarding b'x00' while syncing
DEBUG:__main__:discarding b'-' while syncing
DEBUG:__main__:discarding b'P' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing
DEBUG:__main__:discarding b'x80' while syncing
DEBUG:__main__:discarding b'x02' while syncing
DEBUG:__main__:discarding b'x00' while syncing
DEBUG:__main__:discarding b'Q' while syncing
DEBUG:__main__:discarding b',' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'xaa' while syncing
DEBUG:__main__:discarding b'x04' while syncing
all are binary code instead of numerical result.
Can anyone please tell me the reason? or is there any place I still need edit in order to make this package work in python 3?
Thank you very much!!!
question from:
https://stackoverflow.com/questions/65952734/problem-when-edit-a-package-from-python-2-to-3