I'm using a C program with termios to exchange information and commands between my pc with Ubuntu and a USB motor controller.
It works great and i'm able to successfully send messages over the serial port; however, sometimes it happens that if i close the program in the wrong way or something else happens, i'm not able any more to reconnect to my usb device.
To be able to connect again to the device, i have to reboot my pc and start again ubuntu.
I'd like to avoid this problem and to find a solution to enable again the usb port without have to reboot my system each time.
At the first time, i tried to kill all the processes (sudo killall -9 program_name) that were using the usb port, but the port still remains blocked and i have to reboot it.
Can you suggest me some solutions to avoid the reboot, please?
And why it happens?
I connect to the usb port (/dev/ttyACM0) in this way:
handle = open(port.c_str(), O_RDWR |O_NOCTTY | O_NDELAY);
if(handle == RQ_INVALID_HANDLE)