How to send binary using uart.write() #9786
-
I'm working on communicating with a custom firmware on another device, and I'm trying to use a micropython pyboard to send certain sequences to manipulate the menu on the other system. Specifically I need to be able to send escape (ASCII 27) followed by a d. I tried uart.write(0x1B) and I get the following error.. TypeError: object with buffer protocol required. Using usart.write('abc') works fine. I just need a way to insert an escape. Thanks in advance for any help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Got it... Jus as an example, to send a carriage return you can do uart.write((10).to_bytes(1, 'little')) where 10 is the decimal code for newline. The same line works for sending any character via its ASCII code. |
Beta Was this translation helpful? Give feedback.
-
You can also use |
Beta Was this translation helpful? Give feedback.
Got it...
Jus as an example, to send a carriage return you can do uart.write((10).to_bytes(1, 'little'))
where 10 is the decimal code for newline. The same line works for sending any character via its ASCII code.