Skip to content

Problems with pull opening it's own serial port connection. #3

Description

@cversek

Currently the pull process is implemented by requiring a serial port path to be specified as an argument, e.g.:
./pull_serial_depth_json -p "/dev/ttyUSB0"
In the Python implementation pySerial is used to open this port:
ser = serial.Serial(args.path, baudrate=DEFAULT_BAUDRATE, dsrdtr=True)

There are two potential problems with this implementation:

  • We have noticed that some Arduino systems (certainly the Pro-mini with FTDI cable, maybe all the official ones?) will reset their firmware every time the serial port has been opened. Unfortunately, this can cause a significant lag (up to a few seconds) before the device is receptive to serial commands. This seems to be implemented by FTDI driver pulsing the DTR pin which is connected to the board's hardware reset pin - we can find no way to disable it without an ugly hack.
  • If there are two independently running OPK processes that request sensor data from that same serial device (and why not?) at close to the same time, then there is the potential for a race-condition causing command corruption and possible ruining the state of the communication protocol.

My proposal to solve these problems is to create a server that manages the serial port connection and listens on a session-persistent "named" pipe (a Unix style FIFO) for command requests which will be forwarded. Perhaps this server should be put in a startup script and it should keep looking for the appropriate udev device (match the ID fields) to attach before exporting the pipe interface. Or, maybe udev can be used to starup and shutdown this server (see Stack Exchange - "How to run custom scripts upon USB device plug-in?")? This should fix the delay on opening the port since it will only happen once per session. Now the race condition can be fixed in the pull process by waiting to obtain an exclusive lock on the pipe file. Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions