Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-01-2003, 07:42 PM   #1
Member (10 bit)
 
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
Interface with computer ports

Topic says it really. I want to learn how to interface with ports on my computer, like the parallel, serial, and usb port. I'd like to learn it for either C++ or VB, but I'd be willing to learn a new language if it would work better for this task.

Thanks!
mattg2k4 is offline   Reply With Quote
Old 03-02-2003, 05:08 PM   #2
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
It's quite easy, for the most part. C++ is a good language choice, you'll need to learn about the windows API to handle these kinds of things (these are handled by the OS).

USB may require you to write drivers, like PCMCIA would (I've written PCMCIA drivers, actually). I don't think you have direct control over the USB port like you would a serial or parallel port, which you can easily write to/read from with API commands.
Paul Victorey is offline   Reply With Quote
Old 03-02-2003, 08:28 PM   #3
Member (10 bit)
 
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
Thanks Paul.

Know anywhere I can find all these API calls without going through that handy little win32.hlp file you gave me?

BTW, I did find a method for programming it in VB here, http://aaroncake.net/electronics/vblpt.htm, but the dll it uses will not work under NT according to the docs due to security concerns. Will that still affect XP and 2000, being based on the NT architecture?
mattg2k4 is offline   Reply With Quote
Old 03-03-2003, 10:33 PM   #4
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
Searching Win32.hlp is the main place to find those commands. In Win32, ports are handled just like files, so to open a port, you can do something like

HANDLE serialPort = CreateFile("COM1:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

// Do reads/writes here just like you would a file.
// You might need to reset data parameters for a serial I/O device

CloseHandle(serialPort); //IMPORTANT, nobody else can use it until you're done with it
Paul Victorey is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:30 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2