mborgerson
Well-known member
I suspect that this topic has been discussed before, but a forum search didn't get me a good answer.
I have a project that would be greatly simplified if I could expand the hardware serial receive buffer size for Serial1 to 32768 bytes and the transmit size for Serial2 to 2048 bytes.
The project looks like this:
1. Receive serial data from an oceanographic instrument in 36-byte packets which are sent every 10mSec at 115KBaud.
The data is sent continuously and no flow control is possible, so the Teensy (a 3.6) has to be able to keep up with the data.
2. When 500 packets have been received, (18,000 bytes), convert the data from 16-bit integers to 32-bit floating point using calibration equations.
3. Compute means, variances, and spectral data using FFTs. Stuff these results into a packet of about 1KBytes length and save the packets to SD card.
4. Transmit the packets at 9600 baud to a host system which will send them back to the real world from the wet end of nowhere via satellite.
5. Go back to Step 1 until batteries die or a research vessel retrieves the system (weeks to months later).
There is nothing too difficult in this with a loop like:
loop(){
Get500Packets();
Process500Packets(); // I've got scientists and engineers to write and debug this code
StoreResults();
SendResults();
}
but this only works if the serial buffer doesn't overflow between calls to Get500Packets(). Since processing, storing and sending the data could
take a second or two, this won't work with a small hardware serial buffer. Teensy 3.6 has lots of RAM for data arrays and packet buffers, but
expanding the buffers used by the serial interrupt handlers apparently isn't straightforward. This could probably be done with a timer callback
that checks the Serial1 for data every 10mSec and fills secondary buffer, but that seems more complex than necessary.
I've looked on other Arduino fora, and it seems that changing the serial buffer size is not as simple as changing a #define in user code space.
What is the best way to do this for the Teensy?
I could do this project with ChiBios on an STM-32 system, but I'm working with people that have much more Arduino experience than RTOS experience.
I have a project that would be greatly simplified if I could expand the hardware serial receive buffer size for Serial1 to 32768 bytes and the transmit size for Serial2 to 2048 bytes.
The project looks like this:
1. Receive serial data from an oceanographic instrument in 36-byte packets which are sent every 10mSec at 115KBaud.
The data is sent continuously and no flow control is possible, so the Teensy (a 3.6) has to be able to keep up with the data.
2. When 500 packets have been received, (18,000 bytes), convert the data from 16-bit integers to 32-bit floating point using calibration equations.
3. Compute means, variances, and spectral data using FFTs. Stuff these results into a packet of about 1KBytes length and save the packets to SD card.
4. Transmit the packets at 9600 baud to a host system which will send them back to the real world from the wet end of nowhere via satellite.
5. Go back to Step 1 until batteries die or a research vessel retrieves the system (weeks to months later).
There is nothing too difficult in this with a loop like:
loop(){
Get500Packets();
Process500Packets(); // I've got scientists and engineers to write and debug this code
StoreResults();
SendResults();
}
but this only works if the serial buffer doesn't overflow between calls to Get500Packets(). Since processing, storing and sending the data could
take a second or two, this won't work with a small hardware serial buffer. Teensy 3.6 has lots of RAM for data arrays and packet buffers, but
expanding the buffers used by the serial interrupt handlers apparently isn't straightforward. This could probably be done with a timer callback
that checks the Serial1 for data every 10mSec and fills secondary buffer, but that seems more complex than necessary.
I've looked on other Arduino fora, and it seems that changing the serial buffer size is not as simple as changing a #define in user code space.
What is the best way to do this for the Teensy?
I could do this project with ChiBios on an STM-32 system, but I'm working with people that have much more Arduino experience than RTOS experience.