Transmit data through COM port in Visual C++

Dear members:
I need to write a program in Visual C++ platform that trasmit data
through the COM port.
The task would be as follows:
Whenever the peripheral device sents 1 byte to the computer through
the RX pin of the COM Port, the program will send 4 bytes to the TX
pin to peripheral device.

do you know any source or the class in Visual C++ on the Internet that
can reliably transmit data through COM port ?

Advertisements

Liu Ju wrote:
>
> Dear members:
> I need to write a program in Visual C++ platform that trasmit data
> through the COM port.
> The task would be as follows:
> Whenever the peripheral device sents 1 byte to the computer through
> the RX pin of the COM Port, the program will send 4 bytes to the TX
> pin to peripheral device.
>
> do you know any source or the class in Visual C++ on the Internet that
> can reliably transmit data through COM port ?

Advertisements

However I would like to ask for more specifically. In my program, I
need to wait for a confirmation byte from the peripheral device before
starting sending 4 data bytes. After the peripheral device completes
processing data, it will again require 4 next data bytes. This process
will repeat in the priod of 4 ms.
In DOS, I often used 1 interrupt to know when the peripheral device
requires the tramsmission from the computer. In Visual C++, what
should I do?
Do I have to frequently scan the RxD pin to know whether or not the
peripheral device is sending data? IS there any solution like
interrupt in DOS for this task?

Liu Ju wrote:
> Thank you very much for the answer.
>
> However I would like to ask for more specifically. In my program, I
> need to wait for a confirmation byte from the peripheral device before
> starting sending 4 data bytes. After the peripheral device completes
> processing data, it will again require 4 next data bytes. This process
> will repeat in the priod of 4 ms.
> In DOS, I often used 1 interrupt to know when the peripheral device
> requires the tramsmission from the computer. In Visual C++, what
> should I do?
> Do I have to frequently scan the RxD pin to know whether or not the
> peripheral device is sending data? IS there any solution like
> interrupt in DOS for this task?
>
> Thank you and look forward to your replies.
>
> Sincerely
> LiuJU

You need to ask in a newsgroup specific to your platform.

There are some standard properties (attributes) of a serial port,
but beyond that, they are platform specific.

Read the welcome.txt below to find the proper newsgroup. You
may also want to lurk in news:comp.arch.embedded also.

[Off-Topic]
In general, there are two methods to read from a serial port:
polling and interrupt. With polling, the program is reading
the status register to determine if a character has arrived.
With interrupts, the program is interrupted when a character
has arrived and an Interrupt Service Routine (ISR) is invoked.
Once the character has arrived, the value must be read out
of the Recieve Register. After that, the status may have
to be reset.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!