I've been very much helped by the two way I2C EasyTransfer Library. One version of it is posted here, but I've been using the attached version whose source I've forgotten. I've read that the maximum number of bytes that can be transferred over VirtualWire is 26 (or is it 27 or 28?) bytes, and over serial, it's 255 bytes. I'm using I2C, and I've found by experience that its maximum is 26 bytes also. I've looked at the code of the library, and I don't see why it has a maximum. Is it possible to increase its maximum? I'm too ignorant of C and such things to figure it out by myself. I need to transfer a struct of 30 bytes or more, and it'd be too bad if I had to almost reinvent the wheel to do that.
PaulS:
So, the problem is that the EasyTransfer library imposes additional limits, not the hardware.
That's right.
PaulS:
You can work within the limits by using multiple structs...
Could you explain some more about using multiple structs? That seems like a good idea, but I tried to use multiple EasyTransfer objects with their own structs and I'm not getting it to work.
PaulS:
or you can work around the limits by not using EasyTransfer.
As I said in my initial post, EasyTransfer does things well, so if I could avoid writing my own code to transfer data, I'd like to do that. I'd really like to know if there's a good reason why there's a 26 byte limit for I2C and see if it's possible to change that.
The buffer size is 32 and mentioned several places in the TWI.h library. That's the size I use successfully when transferring data from four Nano slaves to one Mega master.
aswine:
If I understood the Wire source code, I'd know. A large part of the reason this thread exists is that I don't understand it.
OK. There are 5 copies of the data that the Wire library sends and receives. I don't understand why, entirely, but that doesn't really matter. It is what it is. Increasing the size of "the buffer" means increasing the size of all 5 buffers.
PaulS:
OK. There are 5 copies of the data that the Wire library sends and receives. I don't understand why, entirely, but that doesn't really matter. It is what it is. Increasing the size of "the buffer" means increasing the size of all 5 buffers.
You're saying I can change #define BUFFER_LENGTH 32 to #define BUFFER_LENGTH 64 without any problems? I figured there was a good reason that it was set to 32, so 32 would be the only (or biggest) number that would work. Simply changing that number will change the number of bytes I can send with EasyTransfer?
That looks like it worked, though I'm a little worried about bad things happening when I have my back turned. I changed BUFFER_LENGTH in Wire.h and TWI_BUFFER_LENGTH in twi.h to 64. Thanks for the help.
You're saying I can change ... without any problems?
Where did you get THAT impression. I CLEARLY warned you that increasing the size of the buffer by 32 would use 160 more bytes of SRAM. That is by no means the same as "without any problems".
PaulS:
Where did you get THAT impression. I CLEARLY warned you that increasing the size of the buffer by 32 would use 160 more bytes of SRAM. That is by no means the same as "without any problems".
I'm using 30,430 bytes out of 253,952 bytes. Spending another 160 on that is not a problem.