44 #ifndef CCXX_SERIAL_H_ 45 #define CCXX_SERIAL_H_ 47 #ifndef CCXX_MISSING_H_ 51 #ifndef CCXX_THREAD_H_ 55 #ifndef CCXX_EXCEPTION_H_ 61 #define INVALID_HANDLE_VALUE (-1) 64 #ifdef CCXX_NAMESPACES 156 void initSerial(
void);
169 void open(
const char *fname);
184 virtual int aRead(
char * Data,
const int Length);
192 virtual int aWrite(
const char * Data,
const int Length);
201 Error
error(Error
error,
char *errstr = NULL);
210 {
error(errExtended, err);};
220 {flags.thrown = !enable;};
232 int setPacketInput(
int size,
unsigned char btimer = 0);
243 int setLineInput(
char newline = 13,
char nl1 = 0);
253 void flushInput(
void);
258 void flushOutput(
void);
263 void waitOutput(
void);
269 void endSerial(
void);
276 void initConfig(
void);
316 Error setSpeed(
unsigned long speed);
324 Error setCharBits(
int bits);
332 Error setParity(Parity parity);
340 Error setStopBits(
int bits);
348 Error setFlowControl(Flow flow);
360 void sendBreak(
void);
451 void endStream(
void);
478 int overflow(
int ch);
509 void interactive(
bool flag);
564 void open(
const char *name);
598 TTYSession(
const char *name,
int pri = 0,
int stack = 0);
641 bool detect_disconnect;
664 void setDetectPending(
bool );
670 {
return detect_pending; }
676 void setDetectOutput(
bool );
682 {
return detect_output; }
688 virtual void expired(
void);
695 virtual void pending(
void);
701 virtual void disconnect(
void);
713 {
return aWrite((
char *)buf, len);};
718 virtual void output(
void);
729 inline int input(
void *buf,
int len)
730 {
return aRead((
char *)buf, len);};
808 virtual void onUpdate(
unsigned char flag);
814 virtual void onEvent(
void);
834 void update(
unsigned char flag = 0xff);
844 SerialService(
int pri = 0,
size_t stack = 0,
const char *
id = NULL);
865 #ifdef COMMON_STD_EXCEPTION 866 class __EXPORT SerException :
public IOException
869 SerException(
const String &str) : IOException(str) {};
873 #ifdef CCXX_NAMESPACES
int bufsize
Definition: serial.h:162
bool operator!()
Test to see if stream is opened.
Definition: serial.h:574
This is a generic and portable string class.
Definition: string.h:77
The serial port is an internal class which is attached to and then serviced by a specified SerialServ...
Definition: serial.h:631
int getCount(void)
Get current reference count.
Definition: serial.h:857
timeout_t timeout
Definition: serial.h:433
int HANDLE
Definition: serial.h:60
Pending
Definition: serial.h:134
Error getErrorNumber(void)
Often used by a "catch" to fetch the last error of a thrown serial.
Definition: serial.h:368
#define __EXPORT
Definition: config.h:980
substitute functions which may be missing in target platform libc.
#define TIMEOUT_INF
Definition: thread.h:115
int output(void *buf, int len)
Transmit "send" data to the serial port.
Definition: serial.h:712
int getBufferSize(void)
Get the "buffer" size for buffered operations.
Definition: serial.h:387
HANDLE dev
Definition: serial.h:160
GNU Common C++ exception model base classes.
A more natural C++ "ttystream" class for use by non-threaded applications.
Definition: serial.h:542
unsigned long timeout_t
Definition: thread.h:74
Synchronization and threading services.
The SerialService is a thead service object that is meant to service attached serial ports...
Definition: serial.h:771
Serial()
This allows later ttystream class to open and close a serial device.
Definition: serial.h:282
class __EXPORT SerialPort
Definition: serial.h:607
bool thrown
Definition: serial.h:146
Parity
Definition: serial.h:127
TTY streams are used to represent serial connections that are fully "streamable" objects using C++ st...
Definition: serial.h:423
Flow
Definition: serial.h:119
Timer ports are used to provide synchronized timing events when managed under a "service thread" such...
Definition: thread.h:1759
char * getErrorString(void)
Often used by a "catch" to fetch the user set error string of a thrown serial.
Definition: serial.h:377
The TTYSession aggragates a TTYStream and a Common C++ Thread which is assumed to be the execution co...
Definition: serial.h:588
bool getDetectPending(void) const
Get the current state of the DetectPending flag.
Definition: serial.h:669
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:186
bool getDetectOutput(void) const
Get the current state of the DetectOutput flag.
Definition: serial.h:681
bool linebuf
Definition: serial.h:147
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1093
int input(void *buf, int len)
Receive "input" for pending data from the serial port.
Definition: serial.h:729
void setTimeout(timeout_t to)
Set the timeout control.
Definition: serial.h:499
void setError(bool enable)
This method is used to turn the error handler on or off for "throwing" execptions by manipulating the...
Definition: serial.h:219
void error(char *err)
This service is used to thow application defined serial errors where the application specific error c...
Definition: serial.h:209
The Serial class is used as the base for all serial I/O services under APE.
Definition: serial.h:98
class __EXPORT SerialService
Definition: serial.h:608
Error
Definition: serial.h:101
char * pbuf
Definition: serial.h:432
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541