/*************************************************************************** rlserial.cpp - description ------------------- begin : Sat Dec 21 2002 copyright : (C) 2002 by R. Lehrig email : lehrig@t-online.de RMOS implementation: Copyright : (C) 2004 Zertrox GbR Written by : Alexander Feller Email : feller@zertrox.de ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * * published by the Free Software Foundation * * * ***************************************************************************/ /*!
With this class you can communicate over a serial line.*/ #ifndef _RL_SERIAL_H_ #define _RL_SERIAL_H_ #include "rlthread.h" #ifdef RLUNIX #include
With this class you can communicate over a serial line.*/ class rlSerial { public: enum Parity { NONE = 0, ODD , EVEN }; rlSerial(); virtual ~rlSerial(); /**
On OpenVMS please set the tt parameters at DCL level E.g.:
$ set term /perm/pasthru -
/eightbit -
/nottsync -
/nohostsync -
/noreadsync -
/type -
/noline -
/altype -
/parity=even -
/speed=9600 tta1:
devicename := /dev/ttyX (unix) | COMx (Windows) | ttaX: (OpenVMS)
speed := B50 ... B4000000
block := 0 | 1 (bool)
rtscts := 0 | 1 (bool)
bits := 7 | 8 (unix) | 4-8 (Windows)
stopbits := 1 | 2
parity := rlSerial::NONE | rlSerial::ODD | rlSerial::EVEN
return == 0 success, return < 0 error
*/
int openDevice(const char *devicename, int speed=B9600, int block=1, int rtscts=1, int bits=8, int stopbits=1, int parity=rlSerial::NONE);
int select(int timeout=500);
int readChar();
int writeChar(unsigned char uchar);
int readBlock(unsigned char *buf, int len, int timeout=-1);
int writeBlock(const unsigned char *buf, int len);
int readLine(unsigned char *buf, int maxlen, int timeout=1000);
int closeDevice();
//! on := 0 | 1 (bool)
void setTrace(int on);
private:
#ifdef RLUNIX
struct termios save_termios;
#endif
#ifdef __VMS
unsigned short int vms_channel;
#endif
#ifdef RLWIN32
HANDLE hdl;
#endif
#ifdef RM3
int device, uint, com, baudrate;
#endif
enum { RESET, RAW, CBREAK } ttystate;
int ttysavefd;
int fd,trace;
};
#endif