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:
Georgi Gerganov
2022-09-03 15:40:40 +03:00
parent 48830a1e18
commit 649f73fd60

View File

@@ -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;