Write from CPP program to serial port

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 1
Reputation: hugoboss911 is an unknown quantity at this point 
Solved Threads: 0
hugoboss911 hugoboss911 is offline Offline
Newbie Poster

Write from CPP program to serial port

 
0
  #1
Oct 22nd, 2008
Hi all,
im doing a uni project and ive run into a little trouble

im writing a program in cpp (has to be cpp because of other constraints)
this program will get values from a file and depending on the values, send a high or low signal to the corresponding output pin on a serial port

i have done some research, but i cant get a solid answer on how to write from a program to a specific pin on a serial port

all i know is that i have to specify the com port (com1 or com2 etc) and the pin

any help on this would be MUCH appreciated

thanks

EDIT: im using windows xp pro, if that helps.
Last edited by hugoboss911; Oct 22nd, 2008 at 7:26 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,651
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1499
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Write from CPP program to serial port

 
0
  #2
Oct 22nd, 2008
you need to use the win32 api communications functions
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Write from CPP program to serial port

 
0
  #3
Oct 22nd, 2008
> EDIT: im using windows xp pro, if that helps.
But which compiler?
Not some fossil like TurboC by any chance?

> send a high or low signal to the corresponding output pin on a serial port
Er, you do know what a serial port looks like right?
Or even how a serial port works?
http://www.lammertbies.nl/comm/cable/RS-232.html
The only output pins which have a level associated with them are CTS and RTS.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: Write from CPP program to serial port

 
0
  #4
Oct 22nd, 2008
Originally Posted by Salem View Post
> EDIT: im using windows xp pro, if that helps.
But which compiler?
Not some fossil like TurboC by any chance?

> send a high or low signal to the corresponding output pin on a serial port
Er, you do know what a serial port looks like right?
Or even how a serial port works?
http://www.lammertbies.nl/comm/cable/RS-232.html
The only output pins which have a level associated with them are CTS and RTS.
Why are you providing this information. I can't imagine someone trying to work with serial ports if they don't know the first thing about them.

Thats about as bad as if i was to set out writing a driver program in assembly for a microcontroller to interact with a keyboard. And then not looking at how the keyboard transmitts and recievers data.

That was a fun project btw, i also did it using shift registers aswell as assembly. I'm a bit of an electornics geek too

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1491 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC