libserial icon indicating copy to clipboard operation
libserial copied to clipboard

Input/output error

Open mrspirytus opened this issue 4 years ago • 3 comments
trafficstars

Hello,

I am getting exceptions occasionally on Write(). Here is an exception I am getting.

terminate called after throwing an instance of 'std::runtime_error'
  what():  Input/output error
Aborted (core dumped)

here is kernel dmsg. Did you ever encounter this? I have a little LTE module plugged into 2 port USB hub. And sending AT commands on /dev/ttyUSB1. I am not sure if this is a problem with liberalism. I am still investigating

disabled by hub (EMI?), re-enabling...

Cheers

mrspirytus avatar Mar 19 '21 04:03 mrspirytus

Hi @mrspirytus , are you using a SerialPort or a SerialStream object?

mcsauder avatar Mar 25 '21 01:03 mcsauder

You will get this exception in the following case:

else if (write_result <= 0 && errno != EWOULDBLOCK)
{
        throw std::runtime_error(std::strerror(errno)) ;
}

So if the write was unsuccessful and reported back as such by the OS, or if errno is anything but a blocking call you will see this. If you add a try/catch block to your executing code you can capture this exception and continue execution of your application.

mcsauder avatar Mar 25 '21 01:03 mcsauder

Still looking into this...

mrspirytus avatar Apr 15 '21 23:04 mrspirytus