44 #ifndef COMMONCPP_SERIAL_H_
45 #define COMMONCPP_SERIAL_H_
47 #ifndef COMMONCPP_CONFIG_H_
48 #include <commoncpp/config.h>
51 #ifndef COMMONCPP_THREAD_H_
55 #ifndef COMMMONCPP_EXCEPTION_H_
110 typedef enum Error Error;
118 typedef enum Flow Flow;
125 typedef enum Parity Parity;
132 typedef enum Pending Pending;
149 void initSerial(
void);
162 void open(
const char *fname);
177 virtual int aRead(
char * Data,
const int Length);
185 virtual int aWrite(
const char * Data,
const int Length);
194 Error error(Error error,
char *errstr = NULL);
202 inline void error(
char *err)
203 {
error(errExtended, err);};
212 inline void setError(
bool enable)
213 {flags.thrown = !enable;};
225 int setPacketInput(
int size,
unsigned char btimer = 0);
236 int setLineInput(
char newline = 13,
char nl1 = 0);
246 void flushInput(
void);
251 void flushOutput(
void);
256 void waitOutput(
void);
262 void endSerial(
void);
269 void initConfig(
void);
309 Error setSpeed(
unsigned long speed);
317 Error setCharBits(
int bits);
325 Error setParity(Parity parity);
333 Error setStopBits(
int bits);
341 Error setFlowControl(Flow flow);
353 void sendBreak(
void);
361 inline Error getErrorNumber(
void)
370 inline char *getErrorString(
void)
380 inline int getBufferSize(
void)
392 virtual bool isPending(Pending pend,
timeout_t timeout = TIMEOUT_INF);
416 class __EXPORT
TTYStream :
protected std::streambuf,
public Serial,
public std::iostream
444 void endStream(
void);
471 int overflow(
int ch);
502 void interactive(
bool flag);
557 void open(
const char *name);
567 inline bool operator!()
591 TTYSession(
const char *name,
int pri = 0,
int stack = 0);
634 bool detect_disconnect;
657 void setDetectPending(
bool );
662 inline bool getDetectPending(
void )
const
663 {
return detect_pending; }
669 void setDetectOutput(
bool );
674 inline bool getDetectOutput(
void )
const
675 {
return detect_output; }
681 virtual void expired(
void);
688 virtual void pending(
void);
694 virtual void disconnect(
void);
705 inline int output(
void *buf,
int len)
706 {
return aWrite((
char *)buf, len);};
711 virtual void output(
void);
722 inline int input(
void *buf,
int len)
723 {
return aRead((
char *)buf, len);};
801 virtual void onUpdate(
unsigned char flag);
807 virtual void onEvent(
void);
827 void update(
unsigned char flag = 0xff);
837 SerialService(
int pri = 0,
size_t stack = 0,
const char *
id = NULL);
850 inline int getCount(
void)
856 #ifdef CCXX_EXCEPTIONS
857 class __EXPORT SerException :
public IOException
860 SerException(
const String &str) : IOException(str) {};