Skip to content

Infinite CPU due to Misbehaving Serial Port #2856

@wes8ty

Description

@wes8ty

First wanted to say awesome library! Really easy to use.

Environment

Problem

After a lot of investigating, we determined that our Linux serial port is stuck randomly receiving 0xFF. After a while, this starts to add up (memray).

Image

Stack Trace

Thread 1 (active+gil): "MainThread"
    compute_CRC (pymodbus/framer/rtu.py:157)
    check_CRC (pymodbus/framer/rtu.py:143)
    decode (pymodbus/framer/rtu.py:123)
    handleFrame (pymodbus/framer/base.py:73)
    callback_data (pymodbus/transaction/transaction.py:229)
    datagram_received (pymodbus/transport/transport.py:331)
    data_received (pymodbus/transport/transport.py:304)
    intern_read_ready (pymodbus/transport/serialtransport.py:134)
    run (asyncio/runners.py:118)
    run (asyncio/runners.py:195)
    run (uvloop/__init__.py:96)
    <module> (hwmngr/__main__.py:45)
    _run_code (runpy.py:88)
    _run_module_as_main (runpy.py:199)

When I execute cat on our serial port it returns a bunch of 0xFF which tells me the serial port is thinking it is receiving data constantly.

root@9485062:~# cat /dev/rs485_chan_a                                                                                                                                       
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������

I do believe this is a hardware issue. However, I was wondering if there could be a change made in pymodbus to detect a buffer overflow to indicate this has happened and reset the bus (like a timeout error). I am trying to figure out how a solution to harden / detect / recover if this happens. I can't really do this is user space without some ugly hacks. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions