Hardware info:
Custom board with STM32F407
Serial port running at 921600 baud and RTS/CTS flow control (voltage levels are fine and verified)
Sierra Wireless HL8547 3G modem with serial port AT command interface.
chconf.h: SERIAL_BUFFERS_SIZE 512
I'm implementating a driver for a 3G modem which uses the AT command specification. I wrote a cross-platform driver which has a hook to read/write of serial buffered data.
The driver will call the registered callbacks to fetch buffered data and I mapped it to use the ChibiOS HAL serial driver. And is defined as follows:
The callbacks:
Code: Select all
static int32_t dncm_modem_write_serial(const void *buf, size_t nbyte)
{
return sdWriteTimeout(&DNCM_MODEM_DEV, buf, nbyte, MS2ST(1));
}
static int32_t dncm_modem_read_serial(void *buf, size_t nbyte)
{
return sdReadTimeout(&DNCM_MODEM_DEV, buf, nbyte, MS2ST(1));
}
I decided to use the read/write with a 1 millisecond timeout so the calling thread can sleep if there is no data.
On the serial port I see the following output:
Code: Select all
AT+KTCPSND=1,82\r\n
CONNECT\r\nThe "reader" which calls the read callbacks reports the following:
Code: Select all
reader(26): AT+KTCPSND=1,82\r\n
CONNCT\r\nThe "reader" should report:
Code: Select all
reader(27): AT+KTCPSND=1,82
CONNECT
RUN CB [CONNECT]
I'm 100% sure the thread is fast enough to read the data, because the buffer size is 512 bytes and the command I send will wait until the CONNECT is received
so no other serial port traffic is received.
As seen, I only mis one character most of the time. Then the driver stops working because it is not able to match the returned pattern.
I also used the sdReadTimeout because the BaseSequentialStream will not report zero length when reading nothing, this screws op the
multithreading because I would sleep a little after I got no data at all.
I'm a little lost for now, hopefully somebody can point me how to investigate further where the character(s) are lost.
Kind regards,
Wafel