Skip to content

Conversation

@woodfell
Copy link
Contributor

@woodfell woodfell commented Mar 4, 2019

When a piksi is connected to a host via USB cable it will create
3 virtual serial ports which appear on linux systems as /dev/ttyACM*.
When Piksi resets or the USB cable is disconnected the kernel will
remove these device nodes automatically.

When console connects to Piksi via one of these ports is will
detect the disconnect event and raise a message in the log. However
it will not close the file descriptor. The kernel will be unable to
fully remove the device since a FD is still open.

When the Piksi reboots and tries to recreate its virtual ports the
linux kernel will be unable to reuse the same device number as before
so long as the previous console process is still running.

Solution - When console detects the piksi disconnect event it should
close the handle. This allows the kernel to reuse the previous device
node as soon as piksi reboots.

Testing

  1. Open console, connect to a running Piksi via USB cable, eg /dev/ttyACM0
  2. Keep console open, reset Piksi
  3. Observe "Piksi disconnected" log
  4. When Piksi reboots check /dev or the output of dmesg for the serial ports. /dev/ttyACM0 should have been recreated

When a piksi is connected to a host via USB cable it will create
3 virtual serial ports which appear on linux systems as /dev/ttyACM*.
When Piksi resets or the USB cable is disconnected the kernel will
remove these device nodes automatically.

When console connects to Piksi via one of these ports is will
detect the disconnect event and raise a message in the log. However
it will not close the file descriptor. The kernel will be unable to
fully remove the device since a FD is still open.

When the Piksi reboots and tries to recreate its virtual ports the
linux kernel will be unable to reuse the same device number as before
so long as the previous console process is still running.

Solution - When console detects the piksi disconnect event it should
close the handle. This allows the kernel to reuse the previous device
node as soon as piksi reboots.
@woodfell woodfell changed the title Close serial port fd when piksi disconnects Close serial port fd when piksi disconnects [ESD-1111] Mar 4, 2019
Copy link
Contributor

@benjaminaltieri benjaminaltieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@woodfell woodfell merged commit 9b15928 into master Mar 6, 2019
@woodfell woodfell deleted the woodfell/close_serial_port_on_disconnect branch March 6, 2019 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants