00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 #ifndef _RL_SERIAL_H_
00025 #define _RL_SERIAL_H_
00026
00027 #include "rlthread.h"
00028
00029 #ifdef RLUNIX
00030 #include <termios.h>
00031 #endif
00032
00033 #ifndef B0
00034
00035 #define B0 0000000
00036 #define B50 0000001
00037 #define B75 0000002
00038 #define B110 0000003
00039 #define B134 0000004
00040 #define B150 0000005
00041 #define B200 0000006
00042 #define B300 0000007
00043 #define B600 0000010
00044 #define B1200 0000011
00045 #define B1800 0000012
00046 #define B2400 0000013
00047 #define B4800 0000014
00048 #define B9600 0000015
00049 #define B19200 0000016
00050 #define B38400 0000017
00051 #define B57600 0010001
00052 #define B115200 0010002
00053 #define B230400 0010003
00054 #define B460800 0010004
00055 #define B500000 0010005
00056 #define B576000 0010006
00057 #define B921600 0010007
00058 #define B1000000 0010010
00059 #define B1152000 0010011
00060 #define B1500000 0010012
00061 #define B2000000 0010013
00062 #define B2500000 0010014
00063 #define B3000000 0010015
00064 #define B3500000 0010016
00065 #define B4000000 0010017
00066 #endif
00067
00071 class rlSerial
00072 {
00073 public:
00074 enum Parity
00075 {
00076 NONE = 0,
00077 ODD ,
00078 EVEN
00079 };
00080
00081 rlSerial();
00082 virtual ~rlSerial();
00107 int openDevice(const char *devicename, int speed=B9600, int block=1, int rtscts=1, int bits=8, int stopbits=1, int parity=rlSerial::NONE);
00108 int select(int timeout=500);
00109 int readChar();
00110 int writeChar(unsigned char uchar);
00111 int readBlock(unsigned char *buf, int len, int timeout=-1);
00112 int writeBlock(const unsigned char *buf, int len);
00113 int readLine(unsigned char *buf, int maxlen, int timeout=1000);
00114 int closeDevice();
00116 void setTrace(int on);
00117 private:
00118 #ifdef RLUNIX
00119 struct termios save_termios;
00120 #endif
00121 #ifdef __VMS
00122 unsigned short int vms_channel;
00123 #endif
00124 #ifdef RLWIN32
00125 HANDLE hdl;
00126 #endif
00127 #ifdef RM3
00128 int device, uint, com, baudrate;
00129 #endif
00130 enum { RESET, RAW, CBREAK } ttystate;
00131 int ttysavefd;
00132 int fd,trace;
00133 };
00134
00135 #endif