mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-21 10:39:25 +08:00
arduino : fix bug in the Reed-Solomon code that causes crashes on some MCUs
The issue was first reported here: https://github.com/ggerganov/ggwave-arduino/issues/1 We were incorrectly reading the "log" array in RS::gf::pow() function. It is surprising how this code even worked on the other microcontrollers. Probably we have been reading bogus values, so I expect the performance of the transmissions to improve after this change.
This commit is contained in:
@@ -129,7 +129,11 @@ inline uint8_t div(uint8_t x, uint8_t y){
|
||||
* @param power - power
|
||||
* @return x^power */
|
||||
inline uint8_t pow(uint8_t x, intmax_t power){
|
||||
#ifdef ARDUINO
|
||||
intmax_t i = pgm_read_byte(log + x);
|
||||
#else
|
||||
intmax_t i = log[x];
|
||||
#endif
|
||||
i *= power;
|
||||
i %= 255;
|
||||
if(i < 0) i = i + 255;
|
||||
|
||||
Reference in New Issue
Block a user