To send data to a USB COM port do I need a USB driver?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

To send data to a USB COM port do I need a USB driver?

Post 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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: To send data to a USB COM port do I need a USB driver?

Post 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.
Carpe diem!
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: To send data to a USB COM port do I need a USB driver?

Post 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?
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: To send data to a USB COM port do I need a USB driver?

Post 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
  1. enumerate PCI to find the USB HCI(s) of your PC.
  2. initialize that HCI (the great thing about USB HCIs is that there are so many to choose from)
  3. enumerate USB to find the chip that you're interested in
  4. figure out what chip it is you are talking to
  5. 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.
Carpe diem!
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: To send data to a USB COM port do I need a USB driver?

Post by austanss »

Gonna go do that. Will keep you updated.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: To send data to a USB COM port do I need a USB driver?

Post 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.
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: To send data to a USB COM port do I need a USB driver?

Post 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
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: To send data to a USB COM port do I need a USB driver?

Post 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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
Post Reply