[Tutor] Serial communication problem

Cameron Simpson cs at cskk.id.au
Thu Dec 7 01:02:05 EST 2023


On 07Dec2023 14:07, Phil <phillor9 at gmail.com> wrote:
>Next, this code sends an "s" asking for the LED's status. This where 
>the problem is. The pico does not receive the "s", yet the "1" and "0" 
>are received using the same read method.

I would be inclined to verify this for real.

Write a small function:

     def sread(ser):
         data = ser.read()
         print("read", repr(data), "from", ser)
         return data

and call `sread(ser_read)` wherever you're calling `ser_read.read()`.  
The objective here is to see all the data received, regardless of where 
your `read()` is taking place. (If `SerialReader` is your own class, it 
would be even better to stil the above `print()` in its `read()` method 
instead.)

I don't, for example, see anything in your code about receiving the `0` 
or `1` status result yet you say they're received.

So print out everything received, to be sure.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list