# Serial read with python

**URL:** <https://discuss.python.org/t/serial-read-with-python/16925>\
**Category:** Python Help\
**Tags:** help\
**Created:** [June 29, 2022, 2:19pm UTC](https://discuss.python.org/t/serial-read-with-python/16925 "2022-06-29T14:19:03Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![mlgtechuser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mlgtechuser/32/7310_2.png) [@mlgtechuser](https://discuss.python.org/u/mlgtechuser)\
**Post date:** [June 30, 2022, 10:48am UTC](https://discuss.python.org/t/serial-read-with-python/16925/10 "2022-06-30T10:48:07Z")

</div>

> [@vbrozik](#):
>
> I think it is practically impossible that wrong parameters would cause the port to insert null characters (`b'\x00'`) and otherwise read correct data

Error checking active only on the transmitting side will add a checksum to the data packet that is then mishandled on the receiving side. The checksum can be any number of bytes.

> [@mlgtechuser](#):
>
> Serial communication is simple, but also complex and not easy.

(I tried to warn everyone. 😜 )

![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/2/270ac9e3976b5f705764ae9157212d9e69fa0899.png)

The `'\x00'` appears to be a two-byte checksum added by the sending device. @juniorprogrammer, what is your dongle talking to? That is the device that might be adding an error detection checksum. If the receiving device isn’t expecting a checksum in the data, it will treat the checksum as data. If the receiving device _ **is** _ expecting a checksum and it knows how many bytes are in the checksum, then the receiving device will strip out the checksum.

PuTTY is stripping off the extra two bytes after the `\r\n`. The PuTTY manual refers to detecting CRC errors but doesn’t say anything about enabling Error Checking, so it might be ‘always enabled’ internally. _ **If** your dongle can be set to use CRC_ (or whatever error checking the sending device is using), then your dongle will strip the extra byte (assuming it’s a checksum). There is also one more setting to check: Flow Control.

![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/1/133aa4f70eea1a873efd61f2a3edb82e9ba8b2ef.png)

The `serial.Serial()` class has a flow control argument, so check the PuTTY ‘Flow Control’ setting above and put one of these in your `ser = serial.Serial()` statement to use the same flow control that PuTTY is using.

```auto
xonxoff=True,
rtscts=True,

```

THEN… &nbsp;Get the serial settings of the transmitting (sending) device and look for error checking enabled. _And make sure **both sides** of the serial link have the same settings_–including the error checking.

---

_[View the full topic](https://discuss.python.org/t/serial-read-with-python/16925)._
