
Portbase User Guide
2.
TTY Port Communication Program
TTYxx port communication is most generally used serial communication method under the Linux/Unix
environment.
1) Function Description
open() -------------- Open a communication port.
|
read(), write() --- Read or write data from the open communication port.
|
close() ------------- Close the open communication port.
2) Result
Application repeatedly transmits “This is LoopBack Data!” through the ttyS0 port at 3 second
intervals and displays data from ttyS0 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 ttyS0.
If you run the program, the following screen appears and “This is LoopBack Data!“ is repeatedly
displayed on the edit box at 3 sec. Intervals.
4) Source Code
//Inserts the necessary header files.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/un.h>
#include <string.h>
int porthandle; // Handle for the socket of RTCP
int readval; // Variable for saving the returned value of read
void OpenSerial(void);
105