Debugging Serial Port


I am using Colibri iMX6 with all 5 serial ports enabled in device tree. All UARTs just have receive and transmit lines.

We have an application where I need to disconnect and reconnect the serial port device. I am using poll() to monitor events on one of the serial ports (UART 5 to be specific). Whenever I press a key on serial device I get a POLLIN event. We are not using any interrupt service routine on the serial port as of now.

I have the following questions:

  1. Is there any way that I could detect the device being unplugged/plugged from the UART port?
  2. One more issue I am facing is that after I unplug the serial device and connect it back again, the serial device is dead (it is powered but not able to read events from device).

This makes me wonder if it is the application or the IMX-Serial driver that is responsible for not reading the events?



  1. No, you can not distinguish between a remote partner sending ‘idle’ and an open UART input line.
    If you’re using a RS232 transceiver then that transceiver does this,
    if you’re communication is on CMOS level you need a pullup to define the input level.
    Technically you could use a pulldown which on for an unconnected device but opened tty will give you break characters but IMHO that is not a sound solution.
    If you need to detect device presence either define a communication protocol which transmits a heartbeat or have a ‘are you there’ operation in the protocol.
    Alternatively have a HW solution with a GPIO.

  2. Since, assuming you don’t create any noise on the RX pin when disonnecting/connecting, the module does not detect that the serial device has been missing I expect something changed on the serial device. Does it need reconfiguration in order to start communication?