EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: faekjarz on April 21, 2017, 11:59:35 am
-
Hey there, enginerds! ;D
I made this thing (https://www.eevblog.com/forum/beginners/(diy-serial-analog-duty-cycle-meter)-voltmeter-voltage-regulators-mcu-usb/msg1080093/#msg1080093) a few whiles ago and now i'm fed up of manually starting the thing every time. I want to "daemonize" the driving shell script. I want it to be started automatically on boot. I intend to modify the driver script and create a systemd unit file (which i will publish in the project thread).
In my case there are, at times, multiple serial devices (/dev/tty[USB]?*) connected to the host, and i'd like to pick _that one target device_.
The first approach, i thought of is to iterate every /dev/tty**?? (serial port, on Linux), connect to it, read, and expect a certain reply string, e.g. "OhaiIAmTheTargetDevice" …then pick that serial port.
1) Am i taking a detour, or is it the right direction?
2) Is there an industry standard method for iteratively identifying "ttyserial" devices, i'm not yet aware of?
3) Examples, Experiences, HowTos, Guides, Links… anyone?
-
1) No. Be polite and don't send random stuff to devices you don't know. Instead, listen for announcements.
2) Ask for hardware identification of the USB port. PID/VID should already exclude many ports.
Or don't use virtual com/tty, you can write directly to one or multiple usb endpoints.
3) Libusb?
-
Here's a good start. This details the old serial plug and play spec and explains how to do it in a manner that most serial devices won't mind or may even be expecting.
http://www.osdever.net/documents/PNP-ExternalSerial-v1.00.pdf (http://www.osdever.net/documents/PNP-ExternalSerial-v1.00.pdf)
-
If you are not adverse to using FTDI:
1/ Program the FTDI with your chosen serial number.
2/ Install the FTDI D2XX driver.
3/ Use FT_OpenEx() with FT_OPEN_BY_SERIAL_NUMBER
-
Hey there, enginerds! ;D
I made this thing (https://www.eevblog.com/forum/beginners/(diy-serial-analog-duty-cycle-meter)-voltmeter-voltage-regulators-mcu-usb/msg1080093/#msg1080093) a few whiles ago and now i'm fed up of manually starting the thing every time. I want to "daemonize" the driving shell script. I want it to be started automatically on boot. I intend to modify the driver script and create a systemd unit file (which i will publish in the project thread).
In my case there are, at times, multiple serial devices (/dev/tty[USB]?*) connected to the host, and i'd like to pick _that one target device_.
The first approach, i thought of is to iterate every /dev/tty**?? (serial port, on Linux), connect to it, read, and expect a certain reply string, e.g. "OhaiIAmTheTargetDevice" …then pick that serial port.
1) Am i taking a detour, or is it the right direction?
2) Is there an industry standard method for iteratively identifying "ttyserial" devices, i'm not yet aware of?
3) Examples, Experiences, HowTos, Guides, Links… anyone?
Use a device with a unique serial number, employ udev to create a symlink. Sorted.
-
Thanks everyone, so far. :-+
Keep the input flowing, if you like.
Now i'm busy reading the PDF @BradC mentioned …I'm on page 9 now "1.2. Device Implementation Considerations" …interesting…
I'd like to mention @honx on twitter (https://twitter.com/honx), who mentioned (https://twitter.com/honx/status/855414048975986689) a tool for programming a unique serial into a Prolific PL2303 and using udev.