mdlayher / consrv

Command consrv is a SSH to serial console bridge server, originally designed for deployment on gokrazy.org devices. Apache 2.0 Licensed.
Other
136 stars 3 forks source link

Add ability to reference the n'th port on a multiple port device #10

Open davidc0le opened 3 weeks ago

davidc0le commented 3 weeks ago

Some devices expose multiple serial ports on a single USB port. For example, the AMD/Xilinx KR260 development kit uses a FTDI FT4232H and when you connect to a system, you see 4 serial ports.

[721176.705420] usb 2-1: new high-speed USB device number 3 using xhci-hcd
[721176.835666] usb 2-1: New USB device found, idVendor=0403, idProduct=6011, bcdDevice= 8.00
[721176.835675] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[721176.835679] usb 2-1: Product: KR Carrier Card
[721176.835683] usb 2-1: Manufacturer: Xilinx
[721176.835687] usb 2-1: SerialNumber: XFL1UUHT425Y
[721176.838668] usb 2-1: Detected FT4232H
[721176.838817] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB2
[721176.840615] usb 2-1: Detected FT4232H
[721176.840784] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB3
[721176.842555] usb 2-1: Detected FT4232H
[721176.842684] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB4
[721176.844399] usb 2-1: Detected FT4232H
[721176.844520] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB5

It would be good if we could reference the SN ('XFL1UUHT425Y' from the example above) , with some reference to the n'th serial number in the consrv toml file, for example 'XFL1UUHT425Y;2' could be mapped to the 2nd port on the FT4232H

mdlayher commented 3 weeks ago

Interesting, yeah makes sense to me. Is there a standard syntax for that type of addressing? Otherwise I'd be inclined to go with serial:port because it matches IP:port syntax.

mdlayher commented 3 weeks ago

One other thing: I don't have a device with this capability and thus can't poke around the sysfs entries. A contribution would be welcome. Basically:

[[devices]]
name = "desktop"
serial = "DEADBEEF:0"
baud = 115200

[[devices]]
name = "desktop"
serial = "DEADBEEF:1"
baud = 115200

Or similar is what I had in mind.

mdlayher commented 2 weeks ago

One other config option that might be better:

[[devices]]
name = "desktop"
serial = "DEADBEEF"
port = 0
baud = 115200

Where port = 0 is implied by default but can be explicitly set to index 1 or more for multi port devices.