Python Forum

Full Version: PC why serial code = converting to ascii ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
thanks for the detailed explanation, there is a lot for me to learn from this.
the code on the pico is just to test some things, but I will have to implement it in the actual code later. then it must indeed be better to prevent problems.

Quote:Is y supposed to be a button debouncer?
This code is only intended for testing, Y must ensure that the data is only sent once.
Quote:Why do you sleep between printing the numbers in r7? There is no reason for this. The PC program is not going to read any bytes until 1000 bytes have been written.
Indeed, waiting 1 mSec makes no sense.
Quote:You could use a special marker to indicate the end of the transmission.
85 & 170 are my special markers, because 0b01010101 and 0b10101010 never appear in my received data.
but I'll take a closer look at that.
Quote:Y must ensure that the data is only sent once.
It doesn't do that. In your program Y does nothing at all.

You cannot use 170 as the end of message marker unless you send your numbers as binary data instead of strings. Because you are writing strings, 170 is b'001100010011011100110000', the ascii table values for '1', '7', and '0'.

In python you can write binary data to stdout, but I don't see where the required commands are available in micropython. I did see something about the usb port being used as a serial port, but I could not find any details. Unfortunately I don't have a raspberry pi device to experiment with. You might have better luck asking your question on a raspberry pi forumn.
Pages: 1 2