Currently the only way to change the buffer size is to modify the header file you mentioned.
Redefining it in your sketch does not work.
increase the serial1 buffer size
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: increase the serial1 buffer size
You can use software serial to create a double-buffer (2 line) scheme of arbitrary length. Ladyada did this with the AVR version of her Adafruit GPS code.
https://github.com/adafruit/Adafruit_GP ... it_GPS.cpp
The buffers appear as
As Adafruit code has evolved lots since 2014 when I wrote my GPS clock using a Maple Mini, I attached a ZIP with all required file that will compile using Roger's Core and IDE 1.8.13. I seem to remember I hacked both Adafruit and SoftwareSerial at the time.
https://github.com/adafruit/Adafruit_GP ... it_GPS.cpp
Code: Select all
Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) {
common_init(); // Set everything to common state, then...
gpsSwSerial = ser; // ...override gpsSwSerial with value passed.
}
Code: Select all
if (currentline == line1) {
currentline = line2;
lastline = line1;
} else {
currentline = line1;
lastline = line2;
}
Sketch uses 51056 bytes (46%) of program storage space. Maximum is 110592 bytes.
Global variables use 5512 bytes (31%) of dynamic memory, leaving 11896 bytes for local variables. Maximum is 17408 bytes.
- Attachments
-
- GPS_Time_Baro (2).zip
- (50.66 KiB) Downloaded 529 times
Last edited by mrburnette on Sun Jan 10, 2021 1:17 am, edited 3 times in total.
Re: increase the serial1 buffer size
Hi, if I can recall correctly you can pass USART_RX_BUF_SIZE and USART_TX_BUF_SIZE as compiler options via the -D parameter.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: increase the serial1 buffer size
https://stm32duinoforum.com/forum/viewt ... tml#p41706Edogaldo wrote: Sat Jan 09, 2021 6:24 pm Hi, if I can recall correctly you can pass USART_RX_BUF_SIZE and USART_TX_BUF_SIZE as compiler options via the -D parameter.
but I do not see that it was implemented.
Looking at https://github.com/rogerclarkmelbourne/ ... le/usart.h
Code: Select all
#ifndef USART_RX_BUF_SIZE
#define USART_RX_BUF_SIZE 64
#endif
#ifndef USART_TX_BUF_SIZE
#define USART_TX_BUF_SIZE 64
#endif
-DUSART_RX_BUF_SIZE nnn
https://github.com/rogerclarkmelbourne/ ... boards.txt
Re: increase the serial1 buffer size
Yes, correct.mrburnette wrote: Sat Jan 09, 2021 10:48 pmMy (untried) thinking is to create a new boards.txt entry and set the environmental variable there, using something like
-DUSART_RX_BUF_SIZE nnn
https://github.com/rogerclarkmelbourne/ ... boards.txt
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: increase the serial1 buffer size
@Edogaldo,
I seem to remember some concerns about making the buffers long and causing lost interrupts/data corruption ... I cannot find the post, so I could be off on this, 'tis been a while.
In any case, through testing needs to be carried out with buffers larger than default.
Ray
I seem to remember some concerns about making the buffers long and causing lost interrupts/data corruption ... I cannot find the post, so I could be off on this, 'tis been a while.
In any case, through testing needs to be carried out with buffers larger than default.
Ray
Re: increase the serial1 buffer size
@ray i've occasionally seen my sketches/firmware crash and i think it is caused by the stack overwriting heap memory. there is only 20k sram on bluepill style mcus after all. i'd guess sometimes with various functionalities integrated together, it is quite possible to run out of memory.
there doesn't seem to be an 'easy' way to detect this, i'm not sure if the memory protection features on the mcu could be used to detect this condition.
there doesn't seem to be an 'easy' way to detect this, i'm not sure if the memory protection features on the mcu could be used to detect this condition.
Re: increase the serial1 buffer size
Conflicts between heap and stack could happen, it's to be checked case by case.
Also, if I'm not wrong, the buffers are created for each available serial and not only for the used ones, so this means that the buffer allocated is multiplied by the number of available serials.
This can make more probable memory conflicts.
Also, if I'm not wrong, the buffers are created for each available serial and not only for the used ones, so this means that the buffer allocated is multiplied by the number of available serials.
This can make more probable memory conflicts.