I am working on a Zephyr project where I need to assign a unique COM port to a USB CDC ACM device such that I can consistently query this port from a different application. My current setup assigns ports like tty.usbmodem1101, tty.usbmodem101, etc., which vary each time the device is connected to a different port.
- Modified the device tree to include a USB CDC ACM configuration.
- Written application code to initialize the USB subsystem and bind the CDC ACM device.
&zephyr_udc0 {
cdc_acm {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM";
status = "okay";
};
};
int main(void)
{
const struct device *dev;
int rc;
if (IS_ENABLED(CONFIG_USB_DEVICE_STACK)) {
dev = device_get_binding("CDC_ACM");
if (dev == NULL) {
printk("CDC ACM device not foundn");
return;
}
rc = usb_enable(dc_status_cb);
if (rc) {
LOG_ERR("Failed to enable USB (%d)", rc);
return rc;
}
}
...