Member Login
member
passwd
remember me on
this computer.

- join now -
- forgot username or password? -

Jump to a Date

Sponsored Communities
Cool stuff
Select a topic of interest:
...and press:
Neat Stuff
Control.com Stuff

Visit our shop for nerds in control lifestyle products.

Fortune
Positive, adj.:
Mistaken at the top of one's voice.
-- Ambrose Bierce, "The Devil's Dictionary"
RSS Feed
RSS feed Use this link to get an RSS feed of the Control.com article flow, for private, non-commercial use only:
www.control.com/rss/
To get a personalized feed, become a member at no cost.
Select a Page Style
Select one of the following styles:
- BluFu
- Classic
(cookies required)
advertisement
from the Having a tough time finding solid information... department...
RS232 in Win2k using Visual C++
Programming languages. topic
Posted by jbf on 2 July, 2004 - 7:37 pm
Hello.

I am working with hardware that receives its commands serially over fiber. I have a bunch of RS232-to-fiber adapters, and would like to write some C/C++ code to send data over a serial port in the particular protocol I am using.

I have had a tough time finding a straight-forward article or resource on this topic.

I should mention I am using Visual C++ 6.0, running on Windows 2000. Is this version of C++ new enough?

It would seem to me there would exist some library to facilitate this function; I just don't know where to look. Any help would be greatly appreciated. Thank you.


Posted by Anonymous on 7 July, 2004 - 11:47 am
Take this:
http://pvbrowser.sourceforge.net/manual/rllib/classrlSerial.h tml

Download here:
http://pvbrowser.org/pvbrowser/index.php?menu=7&topic=7&a mp;subtopic=4


Posted by Rufus on 7 July, 2004 - 4:52 pm
Questions like this really make me feel my age.

It used to be that when you bought computer controlled hardware, you got sample code, at least in basic, and probably C. Often you got a floppy (what's a floppy?)
with driver software sources to add to your projects.

Talk to the vendor. If they don't have this, see if they have some customers that are doing a similar thing and talk to them (assuming they're not competitors).

What type of hardware is it? There might be appropriate newsgroups. If you have no newsreader, use google groups.

Otherwise, you're in the next best place (sometimes the best) for information right here on the automation list.

Oh, and yes, VC++ V. 6.0 is more than sufficient.

Rufus


Posted by Dan Brown on 7 July, 2004 - 4:55 pm
Hi

I had to connect to a Forte system using RS-232 and useing C++ 6.0. I found the book Serial Communications developers guide (Mark Nelson) ideal. In short you treat the com port as a file, and you read and write to the file. I do suggest that you use a seperate thread for the com. port part of your program.

Hope this helps.
Dan Brown


Posted by Anonymous on 7 July, 2004 - 5:24 pm
Hello.

You must look for stuff relating to I/O streams and Asynchronous I/O. You write or read data from a serial port just as you are doing I/O with an ordinary file; just that you have to define COM1 or COM2 in your call to CreateFile() with particular settings of other parameters that you must look forward in a related text.


Posted by Andrzej on 7 July, 2004 - 5:22 pm
Hi

You can use MSComm control. This is Microsoft ActiveX you can use to control RS232 in W2K.

Regards
Andrzej
www.modbus.pl


Posted by Punita on 8 July, 2004 - 9:53 am
Hello,

Win2k/NT/98 etc all have a comman API which is used to program the serial port. It is called the Win32 Comm API. I must admit, its not so easy to get started with this straight away. The API is difficult to use.

There are several websites that provide, good resources on programming in VC++ 6.0 for the Comm API.

There are commercial libraries available that provide easy to use functions for programming the serial port. These libs hide the intricacies of the Win32 Comm API and provide easy to use functions like open_port(), read(), write().

For more details and help on programming serial ports in VC++, send me an email at punita@tatvik.com.

regards


Posted by Gopinath on 24 January, 2005 - 6:31 pm
Hello Punita

Thank u for the kind suggestion made regarding the serial interfacing.

Could u please give me the details of the Commercial libraries u said about for the serial interfacing with VC++?

Thanking You

Gopi


Posted by yapster on 2 February, 2005 - 11:28 pm
hello,

I would like to ask on how to use VISUAL C++ to communicate with the RS-232 of the computer? I am trying to write a code for my RFID (from Texas instruement) and was planning to use the RS232 as my communication port from the host computer to the "reader".A sample program on how to access the serial port as an I/O would be a lot of help. Thank you very much.


Posted by Jair on 17 February, 2005 - 3:27 pm
Yapster,

I'm looking for the same code for the same technology (RFID). could you help or send me some code?

jair105764@yahoo.com


Posted by Anonymous on 23 May, 2005 - 6:35 pm
Hi,

Can i get this sample code for my project? if possible, then send me this code on vikrant_salunkhe@rediffmail.com or call me on 919890137697 in india.


Posted by Anonymous on 11 November, 2006 - 1:36 am
hello,

please send to me code send file comport into visual c++ 6.0. thank you.


Posted by Anonymous on 8 July, 2004 - 4:37 pm
see in programmersheaven.com

so if you find something please send me. thank you.


Posted by Brian E Boothe on 11 July, 2004 - 5:05 pm
Simply strange,,, just write your own library.?? I did


Posted by last_turk on 21 June, 2005 - 10:31 pm
// COM32.CPP
// -----------
// WIN32 communications library interface


hCom = ::Open_Comport (1, 9600);

::Close_Comport (hCom);

::Read_Comport (hCom, &BytesRead, BufferSize, Buffer);

::Write_Comport (hCom, buffer.GetLength(), buffer);


Posted by dfb on 9 July, 2004 - 2:55 am
Hi

I used V C++ to use the serial port to comunicate with a Forte moisture measurment system. I used a book called Serial Communications developers's guide by Mark Nelson (M & T Books). You can contact me if you need any more info.


Posted by Kunal Lagwankar on 26 January, 2005 - 4:45 pm
Hello

A very good site to understand serial communication is http://www.beyondlogic.org.

Also for programming serial port in Windows environment, msdn is the best place for resources and guides.

Regards
Kunal Lagwankar


Posted by Ivank on 1 October, 2005 - 5:57 pm
Hi, do you still have the code for communicating with the serial port? I currently need the pc to communicate with the serial port but I also can hardly find any book or article on this topic. If you still have the code, do you mind to tell me? Really thank you very much!

From Control Engineering magazine...
Related articles from Control Engineering magazine
Above articles copyright 2009 Reed Business Information. Subject to its Terms of Use.
Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2009 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

Control Engineering magazine subscription
Advertisement
Our Advertisers
Help keep our servers running...
Patronize our advertisers!