main task that is doing:
Code: Select all
while (TRUE)
{
chThdSleepMilliseconds(500);
}
and serial task, with HIGHPRIO that does
Code: Select all
static u8 cmdBuf[256];
static u16 cmdLen=0;
while (TRUE)
{
u16 read=sdReadTimeout(&SD2,&cmdBuf[cmdLen],sizeof(cmdBuf),1000);
cmdLen+=read;
if(serialDataCB(cmdBuf,cmdLen))
{
cmdLen=0;
break;
}
}
serialDataCB in question just checks if the packet is complete and then executes the command, otherwise returns 0
Code: Select all
u16 serialDataCB(u8 *buffer, u16 length)
{
if(length<4)
return 0;
u16 cmdLen=(buffer[2]<<8)|buffer[3];
if(length<(4+cmdLen))
return 0;
...
}
Now... this code can't keep up with 115200 serial communication and can't get 134 bytes without losing several on the way. Am I on the wrong track and threads can't be used this way? If I increase the serial buffer from 16 to some higher value, I start getting the data, which means the code is executing slow enough to fill up those 16 byte (thats... ~1.4ms) meanwhile? And thats only with 1 thread (besides idle) running, but I plan to have 3 dealing with serial communication, one i2c, one spi...
I also haven't touched anything in the init about the frequency, no idea actually what the default cpu frequency is.