logo
Jack H

6.2 SERIAL COMMUNICATIONS UNDER LINUX

In Linux serial communications is similar to normal file access. The file names used to access

these ports are in the ’dev’ directory. The ’com1’ port is called ’ttyS0’, and the ’com2’ port is

called ’ttyS1’.

#ifndef __SERIAL

 

#define __SERIAL

 

#define

ERROR

-1

#define

NO_ERROR

0

class serial_io {

 

protected:

 

public:

 

 

 

int

fd; /* File Descriptor Global Variable */

 

 

serial_io(char*);

 

 

~serial_io();

 

int

decode_param(char*);

 

int

writer(char*);

 

int

reader(char*, int);

};

 

 

#endif

 

 

Figure X.10 - The Header File (serial_io.h)