pythonbufferportpyserialbaud-rate

Can you read from serial buffer without knowing baudrate?


I'm just wondering why it's necessary to know the baud rate when reading serial data from the buffer with PySerial. Shouldn't the byte data in the buffer be the same regardless of 9600 or 38400 baud rate, with the exception that the latter fills faster? I'm asking because I might have a scenario where I don't know the source transmission rate and would like to read and record the incoming data anyway. Is it possible to record the incoming data and then check it against the baud rates in post-analysis?


Solution

  • Nope.

    We're talking about an asynchronous protocol here, so both sides need to know when to sample the data. Imagine you're standing next to a conveyor belt that's carrying chocolates that you need to pick up. Now imagine that your eyes are closed... You need to know how fast the belt is moving and how much space is between the chocolates.

    You can sometimes get away with it for super short messages, but don't count on it.

    https://en.wikipedia.org/wiki/Asynchronous_serial_communication