| | |
How do I communicate to a USB port through C? (for Linux and Windows)
![]() |
•
•
Join Date: Oct 2006
Posts: 116
Reputation:
Solved Threads: 0
As all of you can tell from the title, I need help understanding how to communicate to a USB port. Basically I need to send some bits to a usb micro controller and to do so I need to understand how you do it in C for both a Windows and Linux computers. I'm going to be creating my own interface (still figuring that out) which basically works by having the micro controller send out a signal so I can figure out what port it's on and from then on I just start sending the bits to it.
So here's a breakdown of what I need to know.
1. When the data exits the port to the device, will it have the port address with it when the device reads in the data?
2. I'm going to be working with Ubuntu and Win XP, what things will I need to utilize from the OS?
3. Would you recommend a better way to interface to USB?
4. Do I have to repeatedly send a signal when trying to find which usb port the device is on?
As you can tell I'm kind of jumping into this without know what I'm getting myself into. I'm open to any suggestions (other than giving up).
So here's a breakdown of what I need to know.
1. When the data exits the port to the device, will it have the port address with it when the device reads in the data?
2. I'm going to be working with Ubuntu and Win XP, what things will I need to utilize from the OS?
3. Would you recommend a better way to interface to USB?
4. Do I have to repeatedly send a signal when trying to find which usb port the device is on?
As you can tell I'm kind of jumping into this without know what I'm getting myself into. I'm open to any suggestions (other than giving up).
You may have to write a driver for the USB device or uterlize it as a communications port as say you do with usb serial adapters or things like that.
The windows device foundation SDK has methods for dealing with USB devices ( and also quite possable some sample code. ) Documentation can be found here.
The windows device foundation also allows you to write a usermode driver, if you don't want to risk crashing windows
.
The windows device foundation SDK has methods for dealing with USB devices ( and also quite possable some sample code. ) Documentation can be found here.
The windows device foundation also allows you to write a usermode driver, if you don't want to risk crashing windows
. I have looked around the net abit more and have not found any other ways to talk to USB in windows without using the windows device foundation. There will be examples included with the foundation probably in C, If the samples are not in C, I am certain that the drivers can be written in C.
I would look at the userspace driver samples provided with WDF.
I would love to know if there was a simple way to do this without writing a driver, Would be great to know.
I would look at the userspace driver samples provided with WDF.
I would love to know if there was a simple way to do this without writing a driver, Would be great to know.
•
•
Join Date: Sep 2006
Posts: 327
Reputation:
Solved Threads: 22
USB communication is easily 20 times more complex than RS232. No one I know bothers with it. There's a module
for the Python language called pyUSB which is said to simplify things. There's also Easy HID.
http://www.protongeeks.com/index.php...=136&Itemid=30
for the Python language called pyUSB which is said to simplify things. There's also Easy HID.
http://www.protongeeks.com/index.php...=136&Itemid=30
Last edited by Colin Mac; Apr 3rd, 2008 at 7:55 am.
•
•
Join Date: Oct 2006
Posts: 116
Reputation:
Solved Threads: 0
I think the best solution is to make the USB look like a serial (COM) port. If I do that, what would I have to do in C to find that particular port and how would I go about communicating with it? In other words how do I go to each port a listen to it?
Also for those who are familiar with doing this, will this work for linux also?
Also for those who are familiar with doing this, will this work for linux also?
Last edited by Mr.UNOwen; Apr 4th, 2008 at 4:13 pm.
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Joypad to Text interface... How? (C++)
- General Tips for Mac OS X (Mac tips 'n' tweaks)
Other Threads in the C Forum
- Previous Thread: need help with c
- Next Thread: TURBO C++ output
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






