0
votes

I have an embedded Linux solution and want to create a command service over serial USB. The idea being that when a computer connects to my embedded via USB, they see a serial device and send serial commands to me through that port and I send responses back.

I need some help in the direction to proceed. Do I need to emulate a serial device so they see me as a COM port? Is there build in Linux solutions to broadcast my details as a serial device? Are there code examples? I can see block devices connect with my embedded solution like a USB storage device. When I plug into another computer, I would like it to see me as a serial COM port.

I just need help in the direction of which path I should go down to solve this.

Thanks in advance.

1
You are operating some weird terms. Do you mean you want to automatically load the device driver once the USB is plugged in? Then look for udev.Eugene Sh.

1 Answers

3
votes

What you are looking for is the Linux USB serial gadget. The Linux USB gadgets framework allows devices to behave as a variety of standard USB devices, including serial devices, Ethernet adapters, and mass storage devices.

Note that USB gadgets will only work on targets with a USB controller that can be set to operate as a USB device. Not all USB controllers and target devices are compatible with this configuration. For instance, most PCs have a host-only USB controller, and the Raspberry Pi Model B is not compatible with gadgets because it contains an embedded USB hub upstream of the USB ports. (However, the Pi Zero is fully compatible with gadgets.)