tessel/t2-firmware

Make USBExecd a server instead of a client to spid

johnnyman727 opened this issue · 1 comments

We should change the USB Daemon from being a client of the SPI Daemon because the SPI Daemon should be opening and closing connections to it as the CLI opens and closes USB connections. Opening and closing allows us to reset the state of the USB Daemon in case of any bugs or other unexpected behavior. However, if the USB Daemon is a client, we have to wait for OpenWRT to restart the client which can take any number of seconds. By making the USB Daemon an always-running server, it can scrub it's state between SPI Daemon connections.

Things that need to change:

  1. Don't start listening for connections from usbd at initialization
  2. When the enable bit goes from 0->1 connect to the usbd (code is already in the usbd, make sure to make it nonblocking)
  3. Set the writable and open bitmask (potentially on flag change, potentially on connect)
  4. When the enable bit goes from 1->0, disconnect from the usbd (might already work as is)
  5. In the case the usbdaemon drops the connection, it should just set the open and writable bits to false (may also work as is)

USBD init code needs to be re-written to be a server instead of a client as well.

Fixed with #134.