Serial Communication Code example

J

Jamil

I have a target box connected to my desktop (x86 Windows 2000) PC
through a serial cable (COM port). The target box running on different
processor and OS. The target box needs to send a specific formatted
data (2 bytes header + 128 bytes data) asynchronously through the
serial port and I've to capture it at the host PC side and save those
into a file.

I like to have the client-server model. The PC will be a server and
start a forever loop process to wait for client's (target box) data
and read its COM port and collect those data and save in a file. Note
that, client target box runs a process which sends those data after
some asynchronous event occurs.

Please refer me to any code example either in C or C++ for
implemneting the establishment of serial communication, read the data
from COM port etc. at the host PC side.
 
J

Jack Klein

I have a target box connected to my desktop (x86 Windows 2000) PC
through a serial cable (COM port). The target box running on different
processor and OS. The target box needs to send a specific formatted
data (2 bytes header + 128 bytes data) asynchronously through the
serial port and I've to capture it at the host PC side and save those
into a file.

I like to have the client-server model. The PC will be a server and
start a forever loop process to wait for client's (target box) data
and read its COM port and collect those data and save in a file. Note
that, client target box runs a process which sends those data after
some asynchronous event occurs.

Please refer me to any code example either in C or C++ for
implemneting the establishment of serial communication, read the data
from COM port etc. at the host PC side.

The standard C language, the topic of this group, has no support for
any hardware devices at all. All input and output is defined strictly
in terms of <stdio.h> FILE * streams.

You need to ask this question in a group that supports your particular
compiler/OS combination, to find out what non-standard extensions
might be available for this sort of thing. Just specifying that it is
a PC is not nearly enough. The extensions will be completely
different on the same PC depending on whether it is running MS-DOS,
Windows, Solaris, Linux, BSD, OS/2, or some other operating system.
 

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

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,104
Latest member
LesliVqm09
Top