C/C++ Sample code for Serial Communication

J

Jamil

I have a device connected through serial port of my desk top PC
running Windows 2000. The device is sending some data as serial stream
asynchronously. I need to do the follwings:

1) Open the COM1 port of the PC
2) Read the data coming from the connected device
3) Save the data into a file
4) After writing all the data, the COM1 port should be closed

Please refer me any sample code either in C or C++ which I could run
on Windows 2000 PC side for above tasks.
 
J

Jack Klein

I have a device connected through serial port of my desk top PC
running Windows 2000. The device is sending some data as serial stream
asynchronously. I need to do the follwings:

1) Open the COM1 port of the PC
2) Read the data coming from the connected device
3) Save the data into a file
4) After writing all the data, the COM1 port should be closed

Please refer me any sample code either in C or C++ which I could run
on Windows 2000 PC side for above tasks.

Sorry, but you can't do any of those things in standard C++, the topic
here. The C++ language (and the C language, for that matter) do not
define or support direct access to any hardware at all. All input and
output is defined in terms of C++ stream or C FILE objects.

You need to ask in a support group for your particular compiler to
find out what non-standard extensions it might provide to help with
this. It is a compiler and platform specific issue, not a language
one.
 
K

Karl Heinz Buchegger

Jamil said:
I have a device connected through serial port of my desk top PC
running Windows 2000. The device is sending some data as serial stream
asynchronously. I need to do the follwings:

1) Open the COM1 port of the PC
2) Read the data coming from the connected device
3) Save the data into a file
4) After writing all the data, the COM1 port should be closed

Please refer me any sample code either in C or C++ which I could run
on Windows 2000 PC side for above tasks.

What's complicated about locating information on your own?
You have the world on you finger tips, you just need to find
the information:

http://www.google.com
Search string: serial port Win C++
 
Joined
Jul 3, 2012
Messages
1
Reaction score
0
brother , did you finf any code related to your problem as mentioned . i also want this code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top