|
hardware\arduino\avr\cores\arduino\HardwareSerial_private.h(IDE1.6.6版本)中对于串口缓存的代码,其中注释we're about to overflow the buffer and so we don't write the character or advance the head.
说明串口缓存64B溢出后,后面的数据是丢弃的。而不是当其中数据超过64字节后,Arduino就会将最早存入的缓冲区的数据丢弃。
[mw_shl_code=bash,true]void HardwareSerial::_rx_complete_irq(void)
{
if (bit_is_clear(*_ucsra, UPE0)) {
// No Parity error, read byte and store it in the buffer if there is
// room
unsigned char c = *_udr;
rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != _rx_buffer_tail) {
_rx_buffer[_rx_buffer_head] = c;
_rx_buffer_head = i;
}
} else {
// Parity error, read byte but discard it
*_udr;
};
}[/mw_shl_code] |
评分
-
查看全部评分
|