- Thu Apr 04, 2019 4:05 pm
#33411
Hi,
not sure, this is a bug and I seem to be not fully able to describe side effects.
In comms.ino in the receiveValue function, there is:
case canbusPage:
pnt_configPage = &configPage9;
//For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size
if (valueOffset < npage_size[currentPage])
{
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
}
break;
and in globals.h npage_size is defined as:
const int16_t npage_size[11] PROGMEM = {0,128,288,288,128,288,128,240,192,192,192};
And here's the BUT: as npage_size is defined as being part of PROGMEM, access to these variable must be run through a macro.
So doing these:
if (valueOffset < npage_size[currentPage]) always evaulates to false, as npage_size[currentPage] always return 0.
So to my understanding, the if statement should look like this:
if (valueOffset < pgm_read_word_near( npage_size[currentPage] ) ) {
Again not sure on the effect, as only warmupPage and canbusPage have this check.
Let me know, if I can do some more testing on this or if I misunderstood something here.
not sure, this is a bug and I seem to be not fully able to describe side effects.
In comms.ino in the receiveValue function, there is:
case canbusPage:
pnt_configPage = &configPage9;
//For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size
if (valueOffset < npage_size[currentPage])
{
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
}
break;
and in globals.h npage_size is defined as:
const int16_t npage_size[11] PROGMEM = {0,128,288,288,128,288,128,240,192,192,192};
And here's the BUT: as npage_size is defined as being part of PROGMEM, access to these variable must be run through a macro.
So doing these:
if (valueOffset < npage_size[currentPage]) always evaulates to false, as npage_size[currentPage] always return 0.
So to my understanding, the if statement should look like this:
if (valueOffset < pgm_read_word_near( npage_size[currentPage] ) ) {
Again not sure on the effect, as only warmupPage and canbusPage have this check.
Let me know, if I can do some more testing on this or if I misunderstood something here.