Introduction
AsSC7 uses overlapped I/O with Arduino: Tx can be pushed while receiving and it seems full-duplex. AsProC9 uses overlapped I/O with asynchronous procedure calls with Arduino: an APC timer polls for Rx, but it is strictly half-duplex.
Using the Code
AsSC7
- Connect Arduino to laptop via USB and check which COM port it is.
- Load in Arduino
WriteAndRead
. - Launch AsSC7, choose the same COM port in
combobox
, push Start, then push Tx when enabled: messages will appear in editbox. - Push Pause to stop receiving from Arduino without closing serial port: 00000... will pop up.
- Push Tx when enabled... Again and again Pause and Tx.
- To close serial port, push Stop.
- Push x system command to close app.
- EXE app has almost no error checking and messages. It presumes all devices work correctly.
AsProC9
- Connect Arduino to laptop via USB and check which COM port it is.
- Load in Arduino
WriteAndRead
. Launch AsProC9, choose the same COM port in combobox
: CRichEdit2
is white. - Push Communicate,
CRichEdit2
is Azure and wait for response: white CRichEdit2
. TimerAPC
polls for Rx. Timer
has a weak algorithm to vary its period depending on frequency of received string
s: check or uncheck checkbox
and see StringLength
, NumRead
and ZeroLen
in the CRichEdit2
. - While communicating, wait for an arbitrary moment and push Stop:
CRichEdit2
gets pink and some string
s received from Arduino or locally written, will be shown. - Stop button uses an estimated interval not to stop before transmission from microcontroller is finished: if not, Rx buffer would get dirty.
- Each app has its own
WriteAndRead
.
SyScUc8
While the previous two are asynchronous, this one is synchronous. Connect Arduino to laptop via USB and check which COM port it is. Load in Arduino WriteAndRead
. Launch SyScUc8
, choose the same COM port in combobox
. Push Communicate: russian is displayed in Rx. Push again Communicate, till it lasts (5 sec). Then push Stop: with x syscommand can close app. Arduino will flash led 13 to signal it. If last row in WriteAndRead Serial.end();
is inserted, after pushing Stop, Arduino must be reset to redo communication.
Points of Interest
In WriteAndRead.ino, I used crt
functions. They seem to work fine.
References
- MSDN
- Internet samples
- Jeffrey Richter, Stanley B. Lippman & Josee Lajoie
History
- 18th April, 2015: Initial version