¿ªÔÆÌåÓý

Locked Connection preferences for serial TTYUSB on #ubuntu


 

I have a JMRI 4.18 setup using both Locobuffer and CMRI USB/serial connections, with Ubuntu 18.04 running on an old IMac.?? Both serial connections appear as /dev/TTYUSBx, but x is not predictable.? To avoid constantly changing the preferences settings, I've set up a udev .rules file for both serial devices, so that they now also appear as /dev/TTYCMRI and /dev/TTYLOCO, regardless of which USBx the system may have assigned.

Unfortunately, when I try to set the connection in JMRI preferences, only the USBx choices (and a bunch of TTYsx ones) are listed in the dropdown.? The /dev directory shows? the TTYUSBx devices, and also the CMRI and LOCO devices as symlinks to the appropriate USB device.? But only the USB devices show up in the JMRI preferences dropdown.

How does JMRI populate the dropdown list??? Is there something else I have to do to get the TTYLOCO and TTYCMRI devices to be available as options?
Tnx,
/Jack in California


 

¿ªÔÆÌåÓý

Jack,

On 11 Apr 2020, at 8:55 AM, Jack Haverty. <jack@...> wrote:

I have a JMRI 4.18 setup using both Locobuffer and CMRI USB/serial connections, with Ubuntu 18.04 running on an old IMac. ??Both serial connections appear as /dev/TTYUSBx, but x is not predictable. ?To avoid constantly changing the preferences settings, I've set up a udev .rules file for both serial devices, so that they now also appear as /dev/TTYCMRI and /dev/TTYLOCO, regardless of which USBx the system may have assigned.

Unfortunately, when I try to set the connection in JMRI preferences, only the USBx choices (and a bunch of TTYsx ones) are listed in the dropdown. ?The /dev directory shows ?the TTYUSBx devices, and also the CMRI and LOCO devices as symlinks to the appropriate USB device. ?But only the USB devices show up in the JMRI preferences dropdown.

If you inspect one of the startup scripts (DecoderPro or PanelPro) in gedit (or similar) you'll see an explanation at around line 24 of the extra command line argument you need to make JMRI see your custom ports). You'll need to add that into your desktop startup file if you have one.

# If your serial ports are not in the default list, include them in the
# command line argument --serial-ports separated by commas:
# ? ?--serial-ports=/dev/locobuffer,/dev/cmri

It's also documented at:
<>

Dave in Australia




 

Jack,

DaveH has suggested one approach.

Another approach is to change your udev names.

The name pattern appears to be?^(ttyS|ttyUSB|ttyACM|ttyAMA|tty\.)*

If you change your names to start with tty instead of TTY they will probably work: lowercase tty.

Dave Sand


----- Original message -----
From: "Jack Haverty." <jack@...>
Subject: [jmriusers] Connection preferences for serial TTYUSB on #ubuntu
Date: Friday, April 10, 2020 5:55 PM

I have a JMRI 4.18 setup using both Locobuffer and CMRI USB/serial connections, with Ubuntu 18.04 running on an old IMac.?? Both serial connections appear as /dev/TTYUSBx, but x is not predictable.? To avoid constantly changing the preferences settings, I've set up a udev .rules file for both serial devices, so that they now also appear as /dev/TTYCMRI and /dev/TTYLOCO, regardless of which USBx the system may have assigned.

Unfortunately, when I try to set the connection in JMRI preferences, only the USBx choices (and a bunch of TTYsx ones) are listed in the dropdown.? The /dev directory shows? the TTYUSBx devices, and also the CMRI and LOCO devices as symlinks to the appropriate USB device.? But only the USB devices show up in the JMRI preferences dropdown.

How does JMRI populate the dropdown list??? Is there something else I have to do to get the TTYLOCO and TTYCMRI devices to be available as options?
Tnx,
/Jack in California


 

Dave S,

On 11 Apr 2020, at 12:08 PM, Dave Sand <ds@...> wrote:

Another approach is to change your udev names.

The name pattern appears to be ^(ttyS|ttyUSB|ttyACM|ttyAMA|tty\.)*

If you change your names to start with tty instead of TTY they will probably work: lowercase tty.
I don't think "/dev/ttyCMRI and /dev/ttyLOCO" will match that regex.

However "/dev/tty.CMRI and /dev/tty.LOCO" should match.

P.S. I went looking for the default regex but didn't find it in the
script. I've found it now in
"jmri/java/src/jmri/jmrix/PortNamePatterns.properties".

Dave in Australia


 

Dave,

I helped a guy who uses two LocoNet connections (Layout control and train control) get his Linux system to use a consistent port. This was before purejavacom. At that time I used ttyUSBTrain and ttyUSBLayout. That appears to still work since he is now on 4.18 and did not need any changes. So it appears that ttyUSB... works or as you mentioned, the tty. prefix.

Dave Sand

----- Original message -----
From: Dave Heap <dgheap@...>
To: [email protected]
Subject: Re: [jmriusers] Connection preferences for serial TTYUSB on #ubuntu
Date: Friday, April 10, 2020 9:35 PM

Dave S,

On 11 Apr 2020, at 12:08 PM, Dave Sand <ds@...> wrote:

Another approach is to change your udev names.

The name pattern appears to be ^(ttyS|ttyUSB|ttyACM|ttyAMA|tty\.)*

If you change your names to start with tty instead of TTY they will probably work: lowercase tty.
I don't think "/dev/ttyCMRI and /dev/ttyLOCO" will match that regex.

However "/dev/tty.CMRI and /dev/tty.LOCO" should match.

P.S. I went looking for the default regex but didn't find it in the
script. I've found it now in
"jmri/java/src/jmri/jmrix/PortNamePatterns.properties".

Dave in Australia


 

Dave S,

On 11 Apr 2020, at 12:57 PM, Dave Sand <ds@...> wrote:

I helped a guy who uses two LocoNet connections (Layout control and train control) get his Linux system to use a consistent port. This was before purejavacom. At that time I used ttyUSBTrain and ttyUSBLayout. That appears to still work since he is now on 4.18 and did not need any changes. So it appears that ttyUSB... works or as you mentioned, the tty. prefix.
The name pattern appears to be ^(ttyS|ttyUSB|ttyACM|ttyAMA|tty\.)*
Yes, "ttyUSBxxx" and "tty.xxx" (where xxx is anything) will match.

But none of TTYCMRI , TTYLOCO, ttyCMRI, ttyLOCO will match.

Dave in Australia


 

Thanks, Dave(s)!?? It's working now, with /dev/ttyUSBloconet and /dev/ttyUSBcmri.?

First I tried adding the serial-ports option to the command line of PanelPro but of course ttyLOCO et al didn't work.

Second, I looked at jmri.conf, and noticed the example use of the serial-ports option included there.? So I uncommented the example to make it active, and just changed my .rules file to create symlinks matching the example.? But that unfortunately didn't work either.

Then I poked around the code on github to try to find out how JMRI populates that dropdown list.?? I thought perhaps there was something else I had to do to make the symlink'ed ttys acceptable.? I used to be a kernel hacker but that was 40+ years ago and a lot has changed in Unix, so I thought maybe JMRI was somehow probing to check for tty behavior with an ioctl or something else I don't know about.

I was still rummaging on github when your message about the regex came in.?? That was the key to getting it to work.?? Thanks again!

I think this surfaces a bug/feature in JMRI.? Either the documentation should be changed (so the examples included in jmri.conf can actually work), or the code should take whatever is specified in the serial-ports option (by jmri.conf, command line, etc.) as true, and not subject it to the regex filter.

I'd lean toward changing the code, but someone who has more knowledge of the system structure should decide.

/Jack in California