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 #pragma once
00036
00037 #include "rptypes.h"
00038
00039 namespace rp{ namespace hal{
00040
00041 class serial_rxtx
00042 {
00043 public:
00044 enum{
00045 ANS_OK = 0,
00046 ANS_TIMEOUT = -1,
00047 ANS_DEV_ERR = -2,
00048 };
00049
00050 static serial_rxtx * CreateRxTx();
00051 static void ReleaseRxTx( serial_rxtx * );
00052
00053 serial_rxtx():_is_serial_opened(false){}
00054 virtual ~serial_rxtx(){}
00055
00056 virtual void flush( _u32 flags) = 0;
00057
00058 virtual bool bind(const char * portname, _u32 baudrate, _u32 flags = 0) = 0;
00059 virtual bool open() = 0;
00060 virtual void close() = 0;
00061
00062 virtual int waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00063
00064 virtual int senddata(const unsigned char * data, size_t size) = 0;
00065 virtual int recvdata(unsigned char * data, size_t size) = 0;
00066
00067 virtual int waitforsent(_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00068 virtual int waitforrecv(_u32 timeout = -1, size_t * returned_size = NULL) = 0;
00069
00070 virtual size_t rxqueue_count() = 0;
00071
00072 virtual void setDTR() = 0;
00073 virtual void clearDTR() = 0;
00074
00075 virtual bool isOpened()
00076 {
00077 return _is_serial_opened;
00078 }
00079
00080 protected:
00081 volatile bool _is_serial_opened;
00082 };
00083
00084 }}
00085
00086
00087