-
|
Device: rpi Pico (rp2040) I'm trying to send data over USB serial using tinyUSB to debug some of my problems. Connected
Test 1:
1621061-GPIO28-0
1621245-GPIO22-0
Test 2:
1621341-GPIO28-1
1621372-GPIO22-0
Test 3:
1621440-GPIO28-1
1621471-GPIO22-1but what i receive is: Connected
Test 1:
1621061-GPIO28-0
1621245-GPIO22-0
Test 2:
1621341-GPIO28-1
1621372-GPIO22-0
Test 3:
1621440-An here the part of my code in main responsible for the previous output: Code// Invoked when cdc when line state changed e.g connected/disconnected
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
{
(void) itf;
(void) rts;
if ( dtr )
{
tud_cdc_write_str("Connected\r\n");
Test1();
tud_cdc_write_flush();
Test2();
tud_cdc_write_flush();
Test3();
tud_cdc_write_flush();
}
}
void CheckPins()
{
// Send the GPIO n°key0SensePin's state
PrepareString(time_us_64(), key0SensePin, GetPin(key0SensePin));
serial_send();
// Send the GPIO n°key0SendPin's state
PrepareString(time_us_64(), key0SendPin, GetPin(key0SendPin));
serial_send();
}
void Test1()
{
serial_print_separator();
serial_print("Test 1:\n\r");
CheckPins();
serial_print_separator();
}
void Test2()
{
serial_print("Test 2:\n\r");
// Drive the GPIO n°key0SensePin's HIGH
gpio_put(key0SensePin, 1);
// Drive the GPIO n°key0SendPin's HIGH
gpio_put(key0SendPin, 1);
// Send the GPIO n°key0SensePin's state
CheckPins();
serial_print_separator();
}
void Test3()
{
serial_print("Test 3:\n\r");
InverseDir();
CheckPins();
serial_print_separator();
}Here, basing myself on some things i read around online (which is probably wrong) It seem to be related to tinyusb's buffer as commenting one of my test in my code involving sending data will make the remaining data appear in the terminal (PuTTY). My first guess would be that tinyusb's buffer is full, and that it isn't being cleared, which would mean that i'm unable to send more. Unfortunately, i cannot take appropriate steps to diagnose this issue as i lack experience with how tinyusb work I'm pretty sure i can fix this on my own provided someone guided me in the troubleshooting process. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
The buffering scheme for cdc may sound complicated but is very simply.
back to your code, 1st flush() will sent data to bus, 2nd and 3rd flush() will return 0 since the usb bus is busy already. Data remains in the fifo, keeping bumping data will overflow the fifo. You should either add check to see if cdc is ready or write_available(), or increase fifo. |
Beta Was this translation helpful? Give feedback.
The buffering scheme for cdc may sound complicated but is very simply.
back to your code, 1st flush() will sent data to bus, 2nd and 3rd flush() will return 0 since the usb bus is busy already. Data remains in the fifo, keeping bumping data will overflow the fifo. You should either add check to see if cdc is ready or write_available(), or increase fifo.