Closed cyberman54 closed 3 years ago
I'm ok with adding more devices, but you need to write code which is sensitive to the limits of Arduino. On AVR, that code will use an extra 24 bytes of RAM because of the way you defined the data. A better way is to read the 3 bytes into a uint32_t and compare the value to 3 uint32_t constants.
I tried to reuse your template with cTemp[8]. Not sure, what you want, something like
const uint32_t oui1 = 0x000004a3, oui2 = 0x00001ec0, oui3 = 0x00d88039,
oui4 = 0x005410ec;
I2CReadRegister(pI2C, i, 0xf8, cTemp, 3); // check for Microchip's OUI
if (cTemp == oui1) || (cTemp == oui2) || (cTemp == oui3) || (cTemp == oui4))
That won't work and "const" by itself isn't enough on AVR.
Something like this: { uint32_t u32Temp = 0; I2CReadRegister(pI2C, i, 0xf8, (uint8_t *)&u32Temp, 3); // check for Microchip's OUI if (u32Temp == 0x000004a3 || u32Temp == 0x00001ec0 || u32Temp == 0x00d88039 || u32Temp == 0x005410ec) { return xxxxx; } }
I don't have your device to test - please try that
That won't work and "const" by itself isn't enough on AVR.
Something like this: { uint32_t u32Temp = 0; I2CReadRegister(pI2C, i, 0xf8, (uint8_t *)&u32Temp, 3); // check for Microchip's OUI if (u32Temp == 0x000004a3 || u32Temp == 0x00001ec0 || u32Temp == 0x00d88039 || u32Temp == 0x005410ec) { return xxxxx; } }
I don't yet understand the pointer magic you applied here, but will test this on a device and learn more pointer esoteric ;-)
I'm ok with adding more devices, but you need to write code which is sensitive to the limits of Arduino. On AVR, that code will use an extra 24 bytes of RAM because of the way you defined the data. A better way is to read the 3 bytes into a uint32_t and compare the value to 3 uint32_t constants.