Servial Port (TTY) and usb ports (lsusb) forward to LXD container

I am using a usb device (zigbee stick) and want OpenHAB (smart Home system) to have access to it.
It uses the serial port (ttyACM0) and I am not sure how to forward the port. I can forward the usb device, but this seems to be something else.

I tried to forward the usb by
lxc config device add iobroker CC2531 usb vendorid=0451
but as mentioned, this is not the same. It did not forward the serial port. I have the usb devices (lsusb) in the container, but not the serial port (sudo ls -la /dev/ttyACM* does not show the device).

The unix-hotplug device type is meant for those cases where you want the resulting devices from a USB device rather than the raw USB device itself.

Though for most of my own setups, I’ve just used unix-char and set the source to a /dev/serial/… path (one based on the device name to avoid issues with mutliple devices and ordering).

So this might mean something like:
lxc config device add OpenHAB ttyACM0 unix-char mode=0666 gid=20 path=/dev/ttyACM0
I will try and report…

Right, for me, it’s something like:

  usb-alarmdecoder:
    path: /dev/serial/alarmdecoder-modem
    source: /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DQ00AXEP-if00-port0
    type: unix-char
  usb-insteon:
    path: /dev/serial/insteon-modem
    source: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A60337Y1-if00-port0
    type: unix-char
  usb-insteon-terminal:
    path: /dev/serial/insteon-terminal
    source: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A60337XU-if00-port0
    type: unix-char
  usb-z-wave:
    path: /dev/serial/zwave-modem
    source: /dev/serial/by-id/usb-0658_0200-if00
    type: unix-char
  usb-zigbee:
    path: /dev/serial/zigbee-modem
    source: /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2212602-if00
    type: unix-char

So I’m using the /dev/serial/by-id as the source path on the host to avoid potential renumbering and then give it a nice short descriptive name inside of the container.

1 Like

Many thanks. So just for completion, I think this should be the right command then:

lxc config device add OpenHAB usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE5ADB1-if00 unix-char mode=0666 gid=20 path=/dev/serial/Zigbee_2531

I suppose the part “Zigbee_2531” or in your case “zigbee-modem” can be freely chosen.

Edit: I get an error here:

$ lxc config device add OpenHAB usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE5ADB1-if00 unix-char mode=0666 gid=20 path=/dev/serial/Zigbee_2531
Error: Failed to start device "usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE5ADB1-if00": The required device path doesn't exist and the major and minor settings are not specified

$ ls -lh /dev/serial/by-id
total 0
lrwxrwxrwx 1 root root 13 Dez 23 21:03 usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE5ADB1-if00 -> ../../ttyACM0

lxc config device add OpenHAB zigbee unix-char mode=0666 gid=20 source=/dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000BE5ADB1-if00 path=/dev/serial/Zigbee_2531

I think that’s closer to what you want in this case.