Portbase User Guide
Programming Examples
This chapter provides application program examples that communicate through COM ports, TTY ports and
sockets to help the user develop a PC based application using Portbase
7
1.
COM Port Communication Program
COM port communication is most generally used serial communication way in the Windows
environment.
1) Function Description
CreateFile()------------ Create a communication port.
|
GetCommState() ------------ Get the speed, byte spec of the open communication port.
|
SetCommState() ------------ Set the speed, spec of the open communication port.
|
ReadFile(), WriteFile() --- Read or write data from the open communication port.
|
CloseHandle() ------------- Close the open communication port.
2) Result
Application repeatedly transmits “This is LoopBack Data!” through the COM3 port at 3 second
intervals and displays data from COM3 on screen.
3) How to Run
Plug the loopback connector to the first serial port of Portbase.
Run Redirector and select Portbase to register the first serial port as COM3.
(Refer to
Chapter 4. COM Port Redirector
.)
If you run the program, the following screen appears and “This is LoopBack Data!“ is repeatedly
102