Skip to content

string vs hex #8

Open
jjehl opened this issue May 12, 2017 · 2 comments
Open

string vs hex #8

jjehl opened this issue May 12, 2017 · 2 comments

Comments

@jjehl
Copy link

jjehl commented May 12, 2017

\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
Copy link
Member

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
Copy link
Author

jjehl commented May 15, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants