Page 1 of 1
To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 9:43 am
by austanss
I recently got an Arduino. I've been tinkering around much with it, and one thing really interested me.
Arduinos use little USB cables to connect to the computer, but when they get into the OS, they appear as COM ports.
So I must ask, is this on a hardware level or a software level?
Meaning, if I wanted to send raw data the same way I send over my normal COM port, do I have to use a USB driver or a COM driver?
Reason I'm asking this is because I'm testing my OS on real hardware and I need something to log the serial output. My idea is that I could send the data to the Arduino, and have it store the text in memory. Then I would reboot, open the serial monitor, and press a button and have the Arduino spit the stored data back out.
Thank you in advance.
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 11:32 am
by nullplan
My guess as to what is happening here is that the AVR processor's UART I/O is pushed through a USB serial chip, and the USB cable only connects that chip through to the PC. This means that what you want is not possible, because you would have to connect your COM port to the side of the USB serial chip that is not exposed externally. And whether or not TTL UART is capable of communicating with a COM port is up in the air, although I have been able to make it work in the past.
Anyway, what you want means you need a USB stack to talk to the USB serial chip. And that is significantly more work than the ISA serial port.
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 11:54 am
by austanss
Well that still leaves how to implement it. From what you are saying, it seems that no, the Arduino will not map to a COM port that I can simply outb to. So do I need a USB driver? How do I communicate with this serial chip?
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 12:05 pm
by nullplan
rizxt wrote:Well that still leaves how to implement it. From what you are saying, it seems that no, the Arduino will not map to a COM port that I can simply outb to. So do I need a USB driver? How do I communicate with this serial chip?
You are certainly right that it won't map to an ISA COM port. Talking to a USB serial converter chip is complicated, since there is no standard. You would have to
- enumerate PCI to find the USB HCI(s) of your PC.
- initialize that HCI (the great thing about USB HCIs is that there are so many to choose from)
- enumerate USB to find the chip that you're interested in
- figure out what chip it is you are talking to
- talk to it in a way only the manufacturer knows, or maybe poach the driver from the Linux kernel
The two main USB serial chips are the Prolific one and the FTDI one. Have fun googling for their data sheets. Once you have a working driver for them, come back and we can talk about that Arduino idea of yours.
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 12:10 pm
by austanss
Gonna go do that. Will keep you updated.
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 12:43 pm
by foliagecanine
In my experience, Arduinos register as a standard USB device, specifically a "Communications and CDC Control" device, or class 2.
I'm pretty sure the Arduino drivers (the ones you install when installing the IDE) are the ones that communicate with the device and make it appear as a "COM Device" in Windows.
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 1:13 pm
by bzt
rizxt wrote:Meaning, if I wanted to send raw data the same way I send over my normal COM port, do I have to use a USB driver or a COM driver?
Both. You'll need an USB driver to handle the USB bus in general, and a COM driver for the USB serial device.
There's a loophole though if your PC is running in boot mode: BIOS int works for USB serial too, just as the UEFI SERIAL_IO_PROTOCOL service. In both case the firmware includes a complex USB driver, but provides the same interface as for the ISA UART chip. Similarly if you're using a mainstream OS (Win, Linux or MacOS) you have the same interface (SetCommState, termios etc.). But if you're about to use the USB serial from your OS, then you're on your own: you'll need a native driver just as @nullplan said.
Cheers,
bzt
Re: To send data to a USB COM port do I need a USB driver?
Posted: Mon Nov 30, 2020 1:38 pm
by austanss
That's pretty epic. I'll have to put this project on hold, I just fried my Arduino. Accidentally put a 65w power supply in and it burnt the whole thing.