37 #include <sys/select.h>    46     : 
rp::hal::serial_rxtx(), _baudrate(0), _flags(0), serial_fd(-1)
    69     struct termios options, oldopt;
    71     bzero(&options, 
sizeof(
struct termios));
    75     if (termbaud == (
_u32)-1)
    80     cfsetispeed(&options, termbaud);
    81     cfsetospeed(&options, termbaud);
    84     options.c_cflag |= (CLOCAL | CREAD);
    86     options.c_cflag &= ~PARENB;  
    87     options.c_cflag &= ~CSTOPB;  
    89     options.c_cflag &= ~CSIZE;
    90     options.c_cflag |= CS8; 
    93     options.c_cflag &= ~CNEW_RTSCTS;  
    96     options.c_iflag &= ~(IXON | IXOFF | IXANY);  
    99     options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
   101     options.c_oflag &= ~OPOST;
   110     if (tcsetattr(
serial_fd, TCSANOW, &options))
   137     if (
data == 
nullptr || 
size == 0) 
return 0;
   145         if (ans == -1) 
return tx_len;
   149     } 
while (tx_len < 
size);
   160     if (ans == -1) ans = 0;
   181     size_t data_count, 
_u32 timeout, 
size_t* returned_size)
   184     if (returned_size == 
nullptr) returned_size = (
size_t*)&
length;
   189     struct timeval timeout_val;
   197     timeout_val.tv_sec = timeout / 1000;
   198     timeout_val.tv_usec = (timeout % 1000) * 1000;
   203         if (*returned_size >= data_count)
   212         int n = ::select(max_fd, &input_set, 
nullptr, 
nullptr, &timeout_val);
   229             if (ioctl(
serial_fd, FIONREAD, returned_size) == -1)
   231             if (*returned_size >= data_count)
   238                     timeout_val.tv_sec * 1000000 + timeout_val.tv_usec;
   239                 int expect_remain_time =
   240                     (data_count - *returned_size) * 1000000 * 8 / 
_baudrate;
   241                 if (remain_timeout > expect_remain_time)
   242                     usleep(expect_remain_time);
   255     if (::ioctl(
serial_fd, FIONREAD, &remaining) == -1) 
return 0;
   284 #define BAUD_CONV(_baud_) \ 
virtual void flush(_u32 flags)
 
#define BAUD_CONV(_baud_)
 
static serial_rxtx * CreateRxTx()
 
static void ReleaseRxTx(serial_rxtx *)
 
virtual size_t rxqueue_count()
 
volatile bool _is_serial_opened
 
virtual bool bind(const char *portname, uint32_t baudrate, uint32_t flags=0)
 
virtual int senddata(const unsigned char *data, size_t size)
 
virtual int waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=nullptr)
 
virtual int recvdata(unsigned char *data, size_t size)
 
_u32 getTermBaudBitmap(_u32 baud)
 
virtual int waitforsent(_u32 timeout=-1, size_t *returned_size=nullptr)
 
GLuint GLsizei GLsizei * length
 
virtual int waitforrecv(_u32 timeout=-1, size_t *returned_size=nullptr)
 
unsigned __int32 uint32_t
 
GLsizei GLsizei GLenum GLenum const GLvoid * data