Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #pragma once
00038
00039 #include "rptypes.h"
00040
00041 namespace rp{ namespace hal{
00042
00043 class serial_rxtx
00044 {
00045 public:
00046 enum{
00047 ANS_OK = 0,
00048 ANS_TIMEOUT = -1,
00049 ANS_DEV_ERR = -2,
00050 };
00051
00052 static serial_rxtx * CreateRxTx();
00053 static void ReleaseRxTx( serial_rxtx * );
00054
00055 serial_rxtx():_is_serial_opened(false){}
00056 virtual ~serial_rxtx(){}
00057
00058 virtual void flush( _u32 flags) = 0;
00059
00060 virtual bool bind(const char * portname, _u32 baudrate, _u32 flags = 0) = 0;
00061 virtual bool open() = 0;
00062 virtual void close() = 0;
00063
00064 virtual int waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00065
00066 virtual int senddata(const unsigned char * data, size_t size) = 0;
00067 virtual int recvdata(unsigned char * data, size_t size) = 0;
00068
00069 virtual int waitforsent(_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00070 virtual int waitforrecv(_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00071
00072 virtual size_t rxqueue_count() = 0;
00073
00074 virtual void setDTR() = 0;
00075 virtual void clearDTR() = 0;
00076
00077 virtual bool isOpened()
00078 {
00079 return _is_serial_opened;
00080 }
00081
00082 protected:
00083 volatile bool _is_serial_opened;
00084 };
00085
00086 }}
00087
00088
00089