i am currently working with the above aparts, and am experiencing serial data loss/corruption.
The interface to the WiFi module is a simple UART 115200 with hardware flow control. Module is controlled via AT commands.
All the AT command control works fine, as the data returned from the module is not large. 10-20 byte responses.
Now when i get the module to do a HTTP POST to webserver, the response to this is quite long, basically its the HTTP 200 OK crap you get back from a server, so it can be a good few 100 bytes.
The issue is the MCU is not getting everything correctly, i've checked if everything is coming out of the WiFi module TX pin Ok and it is.
Flow control is all enable as i can see the CTS line holding the WiFi off periodically. I've also increased the 'SERIAL_BUFFERS_SIZE' upto 128bytes in the halconf.h
I've tried changing the Threads priority, this made no difference.
This is my Thread code
Code: Select all
static THD_FUNCTION(ThreadAthl, arg)
{
msg_t c;
eventflags_t flags;
ATHND_ST *pd = &at;
event_listener_t elModemdata;
(void)arg;
chRegSetThreadName("athl");
sdStart(&SD2, &serialconfig);
/* Register thread watchdog */
// watchdogRegister( APPWTDG_ATC );
chEvtRegister(chnGetEventSource(&SD2),
&elModemdata, EVENT_MASK(1));
while( TRUE )
{
// watchdogNotify( APPWTDG_ATC );
flags = chEvtGetAndClearFlags(&elModemdata);
if(flags & CHN_INPUT_AVAILABLE)
{
do
{
c = chnGetTimeout(&SD2, TIME_IMMEDIATE);
if ( c != Q_TIMEOUT )
{
switch( pd->service )
{
case DAT_MODE:
data_mode_handler( c );
break;
case CMD_MODE:
command_mode_handler( c );
break;
}
MBS_DEBUG( DBG_MASK_ATC, "%c", c );
}
}
while ( c != Q_TIMEOUT );
}
chEvtWaitOneTimeout(EVENT_MASK(1), MS2ST(10));
}
// return( 0 );
}
This line just outputs what is received, and this does not match what is coming out of the WiFi Module TX pin
MBS_DEBUG( DBG_MASK_ATC, "%c", c );
What else can i look at ?