/* Change Logs: Date Author Notes  bernard first version  lgnq modified according bernard's implementation.  bernard code cleanup  bernard fix compiler warning.  bernard use RT_SERIAL_RB_BUFSZ to define the size of ring buffer.  bernard rewrite serial framework Serial poll routines  */
rt_inline int _serial_poll_rx(struct rt_serial_device *serial, rt_uint8_t *data, int length)
/* Change Logs: Date Author Notes  bernard first version  lgnq modified according bernard's implementation.  bernard code cleanup  bernard fix compiler warning.  bernard use RT_SERIAL_RB_BUFSZ to define the size of ring buffer.  bernard rewrite serial framework Serial poll routines  */
rt_inline int _serial_poll_rx(struct rt_serial_device *serial, rt_uint8_t *data, int length)
{
    int ch;
    int size;
    RT_ASSERT(serial != RT_NULL);
    size = length;
    while (length)
    {
        ch = serial->ops->getc(serial);
        *data = ch;
        data ++; length --;
        if (ch == '\n') break;
    }
    return size - length;
}