Bind serial device address to specific usb port
My OS: Raspbian Stretch Lite
tl;dr;
- I have 2 identical USB device
- I want to make sure their address didn't get confused
- My thinking goes to bind the address to specific USB Port. I'm fine to "sacrifice" the port
- Since I'm new on linux, I don't know how to do it. As far as my knowledge goes, udev differentiate device by it's ID, not port (different manufacturer, models, etc)
- Is there any other recommended method?
Long version:
So, I have this UART-to-USB converter with the same manufacturer, so it have the same ID in udev and all. I want to make sure that the 2 device didn't get confused. For example, /dev/ttyUSB0 will always point to the specific hardware that I wanted (e.g.: inside. The 2 device will be separated by a door, so it's really important not to mess which is outside and inside).
I don't know how to accomplish this. My thinking goes to bind the specific port so that when the device is plugged to those specific port, it'll always give the address ttyUSB0 to that device. Is it even possible to do that? I'm new to linux and I know there's udev rule. But as far as I can find, it only bind device by it's id, not port. Or is there any other recommended way to do it using udev?
Here's my udevadm
for the device:
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0':
KERNELS=="3-2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2':
KERNELS=="3-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0100"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="57"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="ea60"
ATTRS{idVendor}=="10c4"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Silicon Labs"
ATTRS{maxchild}=="0"
ATTRS{product}=="CP2102 USB to UART Bridge Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{serial}=="0001"
ATTRS{speed}=="12"
ATTRS{urbnum}=="1909"
ATTRS{version}==" 1.10"
Note: If binding a port to a specific serial address means I can't use the port for any other device, then it's fine to me
udev raspbian usb-device
add a comment |
My OS: Raspbian Stretch Lite
tl;dr;
- I have 2 identical USB device
- I want to make sure their address didn't get confused
- My thinking goes to bind the address to specific USB Port. I'm fine to "sacrifice" the port
- Since I'm new on linux, I don't know how to do it. As far as my knowledge goes, udev differentiate device by it's ID, not port (different manufacturer, models, etc)
- Is there any other recommended method?
Long version:
So, I have this UART-to-USB converter with the same manufacturer, so it have the same ID in udev and all. I want to make sure that the 2 device didn't get confused. For example, /dev/ttyUSB0 will always point to the specific hardware that I wanted (e.g.: inside. The 2 device will be separated by a door, so it's really important not to mess which is outside and inside).
I don't know how to accomplish this. My thinking goes to bind the specific port so that when the device is plugged to those specific port, it'll always give the address ttyUSB0 to that device. Is it even possible to do that? I'm new to linux and I know there's udev rule. But as far as I can find, it only bind device by it's id, not port. Or is there any other recommended way to do it using udev?
Here's my udevadm
for the device:
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0':
KERNELS=="3-2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2':
KERNELS=="3-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0100"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="57"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="ea60"
ATTRS{idVendor}=="10c4"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Silicon Labs"
ATTRS{maxchild}=="0"
ATTRS{product}=="CP2102 USB to UART Bridge Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{serial}=="0001"
ATTRS{speed}=="12"
ATTRS{urbnum}=="1909"
ATTRS{version}==" 1.10"
Note: If binding a port to a specific serial address means I can't use the port for any other device, then it's fine to me
udev raspbian usb-device
1
Have a look at/dev/serial/by-id/
and/dev/serial/by-path/
. Use those entries instead of/dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
I tend to use theby-id
entries because that doesn't matter what port the device is plugged into.
– Stephen Harris
Dec 17 at 18:31
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37
add a comment |
My OS: Raspbian Stretch Lite
tl;dr;
- I have 2 identical USB device
- I want to make sure their address didn't get confused
- My thinking goes to bind the address to specific USB Port. I'm fine to "sacrifice" the port
- Since I'm new on linux, I don't know how to do it. As far as my knowledge goes, udev differentiate device by it's ID, not port (different manufacturer, models, etc)
- Is there any other recommended method?
Long version:
So, I have this UART-to-USB converter with the same manufacturer, so it have the same ID in udev and all. I want to make sure that the 2 device didn't get confused. For example, /dev/ttyUSB0 will always point to the specific hardware that I wanted (e.g.: inside. The 2 device will be separated by a door, so it's really important not to mess which is outside and inside).
I don't know how to accomplish this. My thinking goes to bind the specific port so that when the device is plugged to those specific port, it'll always give the address ttyUSB0 to that device. Is it even possible to do that? I'm new to linux and I know there's udev rule. But as far as I can find, it only bind device by it's id, not port. Or is there any other recommended way to do it using udev?
Here's my udevadm
for the device:
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0':
KERNELS=="3-2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2':
KERNELS=="3-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0100"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="57"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="ea60"
ATTRS{idVendor}=="10c4"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Silicon Labs"
ATTRS{maxchild}=="0"
ATTRS{product}=="CP2102 USB to UART Bridge Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{serial}=="0001"
ATTRS{speed}=="12"
ATTRS{urbnum}=="1909"
ATTRS{version}==" 1.10"
Note: If binding a port to a specific serial address means I can't use the port for any other device, then it's fine to me
udev raspbian usb-device
My OS: Raspbian Stretch Lite
tl;dr;
- I have 2 identical USB device
- I want to make sure their address didn't get confused
- My thinking goes to bind the address to specific USB Port. I'm fine to "sacrifice" the port
- Since I'm new on linux, I don't know how to do it. As far as my knowledge goes, udev differentiate device by it's ID, not port (different manufacturer, models, etc)
- Is there any other recommended method?
Long version:
So, I have this UART-to-USB converter with the same manufacturer, so it have the same ID in udev and all. I want to make sure that the 2 device didn't get confused. For example, /dev/ttyUSB0 will always point to the specific hardware that I wanted (e.g.: inside. The 2 device will be separated by a door, so it's really important not to mess which is outside and inside).
I don't know how to accomplish this. My thinking goes to bind the specific port so that when the device is plugged to those specific port, it'll always give the address ttyUSB0 to that device. Is it even possible to do that? I'm new to linux and I know there's udev rule. But as far as I can find, it only bind device by it's id, not port. Or is there any other recommended way to do it using udev?
Here's my udevadm
for the device:
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0':
KERNELS=="3-2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2':
KERNELS=="3-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0100"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="57"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="ea60"
ATTRS{idVendor}=="10c4"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Silicon Labs"
ATTRS{maxchild}=="0"
ATTRS{product}=="CP2102 USB to UART Bridge Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{serial}=="0001"
ATTRS{speed}=="12"
ATTRS{urbnum}=="1909"
ATTRS{version}==" 1.10"
Note: If binding a port to a specific serial address means I can't use the port for any other device, then it's fine to me
udev raspbian usb-device
udev raspbian usb-device
asked Dec 17 at 17:49
Yandi Banyu Karima Waly
32
32
1
Have a look at/dev/serial/by-id/
and/dev/serial/by-path/
. Use those entries instead of/dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
I tend to use theby-id
entries because that doesn't matter what port the device is plugged into.
– Stephen Harris
Dec 17 at 18:31
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37
add a comment |
1
Have a look at/dev/serial/by-id/
and/dev/serial/by-path/
. Use those entries instead of/dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
I tend to use theby-id
entries because that doesn't matter what port the device is plugged into.
– Stephen Harris
Dec 17 at 18:31
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37
1
1
Have a look at
/dev/serial/by-id/
and /dev/serial/by-path/
. Use those entries instead of /dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
Have a look at
/dev/serial/by-id/
and /dev/serial/by-path/
. Use those entries instead of /dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
I tend to use the
by-id
entries because that doesn't matter what port the device is plugged into.– Stephen Harris
Dec 17 at 18:31
I tend to use the
by-id
entries because that doesn't matter what port the device is plugged into.– Stephen Harris
Dec 17 at 18:31
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37
add a comment |
1 Answer
1
active
oldest
votes
Rather than trying to make udev
fix pathnames based on path, you may be able to directly use the values stored in /dev/serial/by-path
and /dev/serial/by-id
These are symlinks to the ttyUSB
device and are updated whenever a device is discovered.
eg on my machine:
% ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.0-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.1-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 9 10:56 pci-0000:00:1a.0-usb-0:1.5.2:1.0-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.0-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.1-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Dec 12 19:24 pci-0000:00:1a.0-usb-0:1.6:1.0-port0 -> ../../ttyUSB5
% ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Dec 9 10:56 usb-1a86_USB2.0-Ser_-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:24 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if01-port0 -> ../../ttyUSB3
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489538%2fbind-serial-device-address-to-specific-usb-port%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Rather than trying to make udev
fix pathnames based on path, you may be able to directly use the values stored in /dev/serial/by-path
and /dev/serial/by-id
These are symlinks to the ttyUSB
device and are updated whenever a device is discovered.
eg on my machine:
% ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.0-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.1-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 9 10:56 pci-0000:00:1a.0-usb-0:1.5.2:1.0-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.0-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.1-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Dec 12 19:24 pci-0000:00:1a.0-usb-0:1.6:1.0-port0 -> ../../ttyUSB5
% ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Dec 9 10:56 usb-1a86_USB2.0-Ser_-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:24 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if01-port0 -> ../../ttyUSB3
add a comment |
Rather than trying to make udev
fix pathnames based on path, you may be able to directly use the values stored in /dev/serial/by-path
and /dev/serial/by-id
These are symlinks to the ttyUSB
device and are updated whenever a device is discovered.
eg on my machine:
% ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.0-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.1-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 9 10:56 pci-0000:00:1a.0-usb-0:1.5.2:1.0-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.0-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.1-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Dec 12 19:24 pci-0000:00:1a.0-usb-0:1.6:1.0-port0 -> ../../ttyUSB5
% ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Dec 9 10:56 usb-1a86_USB2.0-Ser_-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:24 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if01-port0 -> ../../ttyUSB3
add a comment |
Rather than trying to make udev
fix pathnames based on path, you may be able to directly use the values stored in /dev/serial/by-path
and /dev/serial/by-id
These are symlinks to the ttyUSB
device and are updated whenever a device is discovered.
eg on my machine:
% ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.0-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.1-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 9 10:56 pci-0000:00:1a.0-usb-0:1.5.2:1.0-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.0-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.1-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Dec 12 19:24 pci-0000:00:1a.0-usb-0:1.6:1.0-port0 -> ../../ttyUSB5
% ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Dec 9 10:56 usb-1a86_USB2.0-Ser_-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:24 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if01-port0 -> ../../ttyUSB3
Rather than trying to make udev
fix pathnames based on path, you may be able to directly use the values stored in /dev/serial/by-path
and /dev/serial/by-id
These are symlinks to the ttyUSB
device and are updated whenever a device is discovered.
eg on my machine:
% ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.0-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.1:1.1-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 9 10:56 pci-0000:00:1a.0-usb-0:1.5.2:1.0-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.0-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 pci-0000:00:1a.0-usb-0:1.5.4:1.1-port0 -> ../../ttyUSB3
lrwxrwxrwx 1 root root 13 Dec 12 19:24 pci-0000:00:1a.0-usb-0:1.6:1.0-port0 -> ../../ttyUSB5
% ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Dec 9 10:56 usb-1a86_USB2.0-Ser_-if00-port0 -> ../../ttyUSB4
lrwxrwxrwx 1 root root 13 Dec 12 19:24 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB5
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTVW64JR-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if00-port0 -> ../../ttyUSB2
lrwxrwxrwx 1 root root 13 Dec 12 19:23 usb-utek_USB__-__Serial_Cable_FTWKU6FP-if01-port0 -> ../../ttyUSB3
answered Dec 17 at 18:30
Stephen Harris
24.8k24477
24.8k24477
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489538%2fbind-serial-device-address-to-specific-usb-port%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have a look at
/dev/serial/by-id/
and/dev/serial/by-path/
. Use those entries instead of/dev/ttyUSB0
– Stephen Harris
Dec 17 at 18:19
@StephenHarris Ahhh, thank you dear sir! Care to add it as an answer so I can accept it?
– Yandi Banyu Karima Waly
Dec 17 at 18:26
@StephenHarris Quick question thought, will it randomly re-assign the port when I restart? For example, the "inside" is on port0, but after restart, it is assigned port1
– Yandi Banyu Karima Waly
Dec 17 at 18:29
I tend to use the
by-id
entries because that doesn't matter what port the device is plugged into.– Stephen Harris
Dec 17 at 18:31
@StephenHarris Thanks! So it means by-path is what I needed (I need the specific port)
– Yandi Banyu Karima Waly
Dec 17 at 18:37