瀏覽代碼

Serial.readBytes and Serial.peak

Put in probably temporary bandaids to allow code that uses:
Serial.readBytes(Buffer, cnt);

To function.  It simply loops calling the underlying code for Serial.read().
teensy4-core
Kurt Eckhardt 5 年之前
父節點
當前提交
0f0639b0c3
共有 1 個檔案被更改,包括 18 行新增1 行删除
  1. +18
    -1
      teensy4/usb_serial.c

+ 18
- 1
teensy4/usb_serial.c 查看文件

@@ -141,6 +141,10 @@ int usb_serial_getchar(void)
// peek at the next character, or -1 if nothing received
int usb_serial_peekchar(void)
{
if (rx_index[0] < rx_count[0]) {
return rx_buffer[rx_index[0]];
}

#if 0
if (!rx_packet) {
if (!usb_configuration) return -1;
@@ -169,7 +173,20 @@ int usb_serial_available(void)
// read a block of bytes to a buffer
int usb_serial_read(void *buffer, uint32_t size)
{
#if 0
#if 1
// Quick and dirty to make it at least limp...
uint8_t *p = (uint8_t *)buffer;
uint32_t count=0;

while (size) {
int ch = usb_serial_getchar();
if (ch == -1) break;
*p++ = (uint8_t)ch;
size--;
count++;
}
return count;
#else
uint8_t *p = (uint8_t *)buffer;
uint32_t qty, count=0;


Loading…
取消
儲存