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