38 #include <sys/select.h>    40 namespace rp{ 
namespace arch{ 
namespace net{
    43     : 
rp::hal::serial_rxtx()
    78     struct termios options, oldopt;
    80     bzero(&options,
sizeof(
struct termios));
    84     if (termbaud == (
_u32)-1) {
    88     cfsetispeed(&options, termbaud);
    89     cfsetospeed(&options, termbaud);
    92     options.c_cflag |= (CLOCAL | CREAD);
    95     options.c_cflag &= ~PARENB; 
    96     options.c_cflag &= ~CSTOPB; 
    98     options.c_cflag &= ~CSIZE;
    99     options.c_cflag |= CS8; 
   102     options.c_cflag &= ~CNEW_RTSCTS; 
   105     options.c_iflag &= ~(IXON | IXOFF | IXANY); 
   108     options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
   110     options.c_oflag &= ~OPOST;
   119     if (tcsetattr(
serial_fd, TCSANOW, &options))
   147     if (
data == NULL || 
size ==0) 
return 0;
   154         if (ans == -1) 
return tx_len;
   158     }
while (tx_len<
size);
   171     if (ans == -1) ans=0;
   199     if (returned_size==NULL) returned_size=(
size_t *)&
length;
   204     struct timeval timeout_val;
   212     timeout_val.tv_sec = timeout / 1000;
   213     timeout_val.tv_usec = (timeout % 1000) * 1000;
   218         if (*returned_size >= data_count)
   227         int n = ::select(max_fd, &input_set, NULL, NULL, &timeout_val);
   242             assert (FD_ISSET(
serial_fd, &input_set));
   246             if (*returned_size >= data_count)
   252                 int remain_timeout = timeout_val.tv_sec*1000000 + timeout_val.tv_usec;
   253                 int expect_remain_time = (data_count - *returned_size)*1000000*8/
_baudrate;
   254                 if (remain_timeout > expect_remain_time)
   255                     usleep(expect_remain_time);
   269     if (::ioctl(
serial_fd, FIONREAD, &remaining) == -1) 
return 0;
   300 #define BAUD_CONV(_baud_) \   330 namespace rp{ 
namespace hal{
 
virtual void flush(_u32 flags)
 
virtual int waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=NULL)
 
virtual int waitforsent(_u32 timeout=-1, size_t *returned_size=NULL)
 
#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 recvdata(unsigned char *data, size_t size)
 
_u32 getTermBaudBitmap(_u32 baud)
 
GLuint GLsizei GLsizei * length
 
virtual int waitforrecv(_u32 timeout=-1, size_t *returned_size=NULL)
 
unsigned __int32 uint32_t
 
GLsizei GLsizei GLenum GLenum const GLvoid * data