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 "hal/abs_rxtx.h"
00038
00039 namespace rp{ namespace arch{ namespace net{
00040
00041 class raw_serial : public rp::hal::serial_rxtx
00042 {
00043 public:
00044 enum{
00045 SERIAL_RX_BUFFER_SIZE = 512,
00046 SERIAL_TX_BUFFER_SIZE = 128,
00047 SERIAL_RX_TIMEOUT = 2000,
00048 SERIAL_TX_TIMEOUT = 2000,
00049 };
00050
00051 raw_serial();
00052 virtual ~raw_serial();
00053 virtual bool bind(const char * portname, _u32 baudrate, _u32 flags = 0);
00054 virtual bool open();
00055 virtual void close();
00056 virtual void flush( _u32 flags);
00057
00058 virtual int waitfordata(size_t data_count,_u32 timeout = -1, size_t * returned_size = NULL);
00059
00060 virtual int senddata(const unsigned char * data, size_t size);
00061 virtual int recvdata(unsigned char * data, size_t size);
00062
00063 virtual int waitforsent(_u32 timeout = -1, size_t * returned_size = NULL);
00064 virtual int waitforrecv(_u32 timeout = -1, size_t * returned_size = NULL);
00065
00066 virtual size_t rxqueue_count();
00067
00068 virtual void setDTR();
00069 virtual void clearDTR();
00070
00071 protected:
00072 bool open(const char * portname, _u32 baudrate, _u32 flags);
00073 void _init();
00074
00075 char _portName[20];
00076 uint32_t _baudrate;
00077 uint32_t _flags;
00078
00079 OVERLAPPED _ro, _wo;
00080 OVERLAPPED _wait_o;
00081 volatile HANDLE _serial_handle;
00082 DCB _dcb;
00083 COMMTIMEOUTS _co;
00084 };
00085
00086 }}}