SkoltechRobotics / rplidar

Python module for RPLidar A1 and A2 rangefinder scanners
MIT License
185 stars 126 forks source link

string vs hex #8

Open jjehl opened 7 years ago

jjehl commented 7 years ago

\x is a string escape code in python which cause some confusion for example in the reset function.

b = '\x40' print(b)

'@'

because \x40 is the ascii code for '@'

newpavlov commented 7 years ago

Not sure what you mean here. Constants were intentionally written in the hexadecimal form. I don't think it's a good idea to use "@" instead of "\x40". Another possible approach is to use integers in the constants (i.e. RESET_BYTE = 0x40), but it will require additional conversions in the code and I don't think this change worth it

jjehl commented 7 years ago

The problem is only about visualization in the log. To check if the frame is the good one. I mean that in the log it is written "message send : @" in place of "\x40" and it is confusing and really not convenient. I added a function to convert str in the real hex representation - and not the unicode caracter - to print in the log.