Hello,
So i am currently reading the data from a sensor in an buffer created by byte array. So as usual the data recevied from the sensor are binary 1 or 0.
So when i try to write that byte array using uart.write(bytearray), i get garbage values printed on terminal.
So how can i solve this.
The baudrate is correctly arranged, and i am able to read data and also can write strings. But only binary data is not getting printed.
Even simple example like :
uart.writechar(1) is giving me garbage value.
Please help .
Thankyou
STM32F407: Not able to write binary data
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Re: STM32F407: Not able to write binary data
Most binary data looks like garabage. When you do uart.writechar(1) you're sending the character 0x01 which is a Control-A. If you're expecting something readable, then you need to convert the binary data into ASCII data. For example if you used binascii.hexlify then you can convert your binary data into a readable representation. There are many different ways of converting binary data into ASCII, it really depends on your data.
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Re: STM32F407: Not able to write binary data
okay thanks
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Re: STM32F407: Not able to write binary data
Hello,
What should i do to print a a variable on UART. I tried converting in binascii but its saying, object with buffer protocol required .
Binascii worked well with bytearray, as i converted my data. But with my variable it didnt worked?
eg:
x = 10
uart.write(x)
Any solution ?
What should i do to print a a variable on UART. I tried converting in binascii but its saying, object with buffer protocol required .
Binascii worked well with bytearray, as i converted my data. But with my variable it didnt worked?
eg:
x = 10
uart.write(x)
Any solution ?
Re: STM32F407: Not able to write binary data
Code: Select all
uart.write('%d' % (x))