OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 8:36 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 9:43 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 370
Location: United States
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".


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 11:32 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
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!


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 11:54 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 370
Location: United States
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".


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 12:05 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
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!


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 12:10 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 370
Location: United States
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".


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 12:43 pm 
Offline
Member
Member

Joined: Sun Aug 23, 2020 4:35 pm
Posts: 148
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?


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 1:13 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: To send data to a USB COM port do I need a USB driver?
PostPosted: Mon Nov 30, 2020 1:38 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 370
Location: United States
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".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 200 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group