You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The buffer used for transmission is fixed at 32 bytes. Trying to use write() to transmit more than this in one transmission results in only 32 bytes being sent out, but the write() function incorrectly returning the amount of bytes originally requested.
Example of writing a page to a 24C EEPROM chip:
voidwritePage(intaddr, char*buf, intlen) {
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(addr); // set write offset addressWire.endTransmission();
for(inti=0; i<len;) {
Wire.beginTransmission(I2C_ADDRESS);
i+=Wire.write(buf+i, len-i); // i will immediately be set to len and loop will terminate prematurelyWire.endTransmission();
}
}
writePage(0, data, 256);
In the above example I am trying to overcome the 32 byte buffer limitation by paging writes to whatever size write() actually writes out, however it will always return the full length, making the code believe everything was sent out. Instead I would have to limit my transmission to BUFFER_LENGTH manually. write() should check if the requested amount of data is exceeding the buffer and then return the amount that is actually still able to be sent out.
The text was updated successfully, but these errors were encountered:
The buffer used for transmission is fixed at 32 bytes. Trying to use write() to transmit more than this in one transmission results in only 32 bytes being sent out, but the
write()
function incorrectly returning the amount of bytes originally requested.Example of writing a page to a 24C EEPROM chip:
In the above example I am trying to overcome the 32 byte buffer limitation by paging writes to whatever size
write()
actually writes out, however it will always return the full length, making the code believe everything was sent out. Instead I would have to limit my transmission toBUFFER_LENGTH
manually.write()
should check if the requested amount of data is exceeding the buffer and then return the amount that is actually still able to be sent out.The text was updated successfully, but these errors were encountered: