43 #ifndef CCXX_SERIAL_H_
44 #define CCXX_SERIAL_H_
46 #ifndef CCXX_MISSING_H_
50 #ifndef CCXX_THREAD_H_
54 #ifndef CCXX_EXCEPTION_H_
60 #define INVALID_HANDLE_VALUE (-1)
63 #ifdef CCXX_NAMESPACES
155 void initSerial(
void);
168 void open(
const char *fname);
183 virtual int aRead(
char * Data,
const int Length);
191 virtual int aWrite(
const char * Data,
const int Length);
200 Error error(
Error error,
char *errstr = NULL);
208 inline void error(
char *err)
209 {
error(errExtended, err);};
218 inline void setError(
bool enable)
219 {flags.thrown = !enable;};
231 int setPacketInput(
int size,
unsigned char btimer = 0);
242 int setLineInput(
char newline = 13,
char nl1 = 0);
252 void flushInput(
void);
257 void flushOutput(
void);
262 void waitOutput(
void);
268 void endSerial(
void);
275 void initConfig(
void);
315 Error setSpeed(
unsigned long speed);
323 Error setCharBits(
int bits);
331 Error setParity(Parity parity);
339 Error setStopBits(
int bits);
347 Error setFlowControl(Flow flow);
359 void sendBreak(
void);
376 inline char *getErrorString(
void)
386 inline int getBufferSize(
void)
450 void endStream(
void);
477 int overflow(
int ch);
508 void interactive(
bool flag);
563 void open(
const char *name);
573 inline bool operator!()
597 TTYSession(
const char *name,
int pri = 0,
int stack = 0);
640 bool detect_disconnect;
663 void setDetectPending(
bool );
668 inline bool getDetectPending(
void )
const
669 {
return detect_pending; }
675 void setDetectOutput(
bool );
680 inline bool getDetectOutput(
void )
const
681 {
return detect_output; }
687 virtual void expired(
void);
694 virtual void pending(
void);
700 virtual void disconnect(
void);
711 inline int output(
void *buf,
int len)
712 {
return aWrite((
char *)buf, len);};
717 virtual void output(
void);
728 inline int input(
void *buf,
int len)
729 {
return aRead((
char *)buf, len);};
807 virtual void onUpdate(
unsigned char flag);
813 virtual void onEvent(
void);
833 void update(
unsigned char flag = 0xff);
843 SerialService(
int pri = 0,
size_t stack = 0,
const char *
id = NULL);
856 inline int getCount(
void)
864 #ifdef COMMON_STD_EXCEPTION
865 class __EXPORT SerException :
public IOException
868 SerException(
const String &str) : IOException(str) {};
872 #ifdef CCXX_NAMESPACES