EasyTransfer Library I2C maximum

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.

EasyTransferI2C_NL 6-19-2013.zip (9.6 KB)

I've read that the maximum number of bytes that can be transferred over VirtualWire is 26 (or is it 27 or 28?) bytes

It's some small number.

and over serial, it's 255 bytes.

Nonsense. There is no limit.

I'm using I2C, and I've found by experience that its maximum is 26 bytes also.

No, it isn't, but it is small.

I need to transfer a struct of 30 bytes or more,

Why do you need to do it in one step? Transfer the data the way I type - one byte at a time.

PaulS:
It's some small number.
Nonsense. There is no limit.
No, it isn't, but it is small.

  • Limits of the Library
  • You can change the Serial port,
  • but the Struct size must not pass 255 bytes
  • VirtualWire Version Struct can'e be bigger then 26 bytes

PaulS:
Why do you need to do it in one step? Transfer the data the way I type - one byte at a time.

Because the EasyTransfer library does it in one step.

Because the EasyTransfer library does it in one step.

So, the problem is that the EasyTransfer library imposes additional limits, not the hardware.

You can work within the limits by using multiple structs or you can work around the limits by not using EasyTransfer.

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.

I'd really like to know if there's a good reason why there's a 26 byte limit for I2C

Of course there is. Look at the code for the Wire library. Look at where the 26 byte limit is defined. Look at where that limit is used.

and see if it's possible to change that.

You can. It will mean sacrificing 5 bytes of SRAM for every byte added.

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.

PaulS:
You can. It will mean sacrificing 5 bytes of SRAM for every byte added.

How's that?

aswine:
How's that?

If you had looked at the Wire source code, you'd know.

PaulS:
If you had looked at the Wire source code, you'd know.

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.

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.

160 bytes of RAM, not Flash!

Which Arduino has 253,952 bytes of SRAM?

Oh, sorry. Still, I'm not worried about 1,953 out of 6,239.