It is another of the very newb questions I have... I have 2 components on serial ports, one being 57600, the other 115200 speed, the uarts are initialized as {115200,0,USART_CR2_STOP1_BITS|USART_CR2_LINEN,0}; and generally both having a thread that is reading data and analyzing it. I'm using the serial system with sdGetTimeout, sdReadTimeout and increased the serial buffers to 64 bytes.
What I found out is that I can't really debug incoming data, if I don't read every single incoming byte right away, it is missing and subsequent read operations timeout. I found out that I can't reliably get the data from the port on 4mhz (STM32L) on 57600 and sometimes even losing bytes on 16mhz on 115200. That with a 2 threads running, one in direct sleep after sending the data, the other just looping to read data. The data should stay in serial buffers until read or overflow right? But even 1 millisecond delay before calling sdGet and I can no longer read the incoming byte. The test:
Code: Select all
static msg_t readThread(void *arg)
{
(void)arg;
s16 b;
while (TRUE)
{
//wait for a packet header
if(sdGetTimeout(&SERIAL_DRIVER,MS2ST(1000))!=CSOH)
continue;
chThdSleepMilliseconds(1);
if(sdGetTimeout(&SERIAL_DRIVER,MS2ST(1000))!=0x01)
continue;
Then I put a breakpoint on the second "continue" and device sends the packet, I can see on the logic analyzer that all the data is sent, yet, I hit the breakpoint. If I remove the 1ms sleep it is able to get most of the data, but still losing. I'm obviously missing something badly...
ps: 2.4.0 release