[Ovmsdev] Multiple OVMS devices

Stephen Casner casner at acm.org
Mon Feb 19 09:18:32 HKT 2018


Perhaps none of you (other than Mark) have multiple OVMS v3 devices to
connect to your computer.  I have an OVMS v3.0 plus a smaller DEVKIT-C
module that Mark sent to me to begin the infrastructure work before
the developer boards were available.  I want to run some other code on
the DEVKIT-C module, so I plugged it into my Mac laptop via the same
powered hub that I bought to support the OVMS v3.0 board.

I discovered that the driver for the Silicon Labs CP2102 USB-to-UART
bridge controller assigns a device name like /dev/tty.SLAB_USBtoUART19
to the second device that is connected.  The number 19 represents how
many times one of these devices has been connected, so if I unplug the
second device and plug it back in again its device name will change to
/dev/tty.SLAB_USBtoUART20.  Since that device name is configured into
sdkconfig that means a reconfig and full rebuild each time I need to
unplug!  Bah.

So I went searching on the Silicon Labs forum and found that a support
request to do something more sane was filed three years ago and has
yet to be addressed.  But one post included a workaround which is to
use a python script to scan the system information about the USB
hierarchy to find the location ID corresponding to each of these
device names.  The location ID of the port where the device is plugged
in remains constant.  Depending upon how the devices are being used,
that can allow using a script to learn the device name currently
assigned to each of the physical devices (assuming that a given
physical device is always plugged into the same port).

I took this idea and modified components/esptool_py/Makefile.projbuild
to invoke an added program tools/findcp2102.py to look up the serial
port as a location ID and translate it to the current device name.
For example, in the sdkconfig file in my work tree for the DEVKIT-C I
have changed CONFIG_ESPTOOLPY_PORT="20-2.1" which (currently) gets
translated to /dev/tty.SLAB_USBtoUART20 when I run make (or make
flash or make monitor).

If the tools/findcp2102.py program is run with no argument it will
list the location ID and device name for all the connected CP2102
devices.  I can know which device name belongs to each physical device
according to the order in which I plugged them in, so that gives me
the associated location ID.  It is also possible to see these location
IDs in the Mac's System Report, but the numbering scheme is different.

I've committed this change to the openvehicles/esp-idf repository.
The change is implemented such that is has no effect if the serial
port spec is not found as a USB location ID, so it should cause no
harm.

                                                        -- Steve



More information about the OvmsDev mailing list