Easytranfer between Due and Mega (problem solved)

I’ve used Easytransfer (EasyTransfer Arduino Library « The Mind of Bill Porter) successfully for some time but now and I’m trying to connect a Mega (generates the data) with a DUE (with TFT shield to display the data).

I have no problem to connect 2 Due’s or 2 Mega’s with Easytransfer but sending from a MEGA to a DUE (or from a DUE to a MEGA) does not work (no data is received).

The DUE and MEGA are connected via RS485 to cover the distance between both as well as to match the operating voltage difference (3.3 vs 5.0V)

The RS485 connection works fine between DUE and MEGA in both directions as long as I use Serial.write, so I am pretty sure everything works fine on the RS485 hardware side.

I use the same sketch for MEGA <-> MEGA or DUE <-> DUE works fine but DUE <-> MEGA won’t work.

Any idea why this won’t work ?

Thanks for your help.

Yes, this can't work, the EasyTransfer library relies on both ends having the
same sized ints and pointers, it doesn't do any marshalling/unmarshalling so relies
on data layout being identical. I'm not even sure the Mega and the Due have the
same endianness, let alone integer and double sizes.

Are there any alternatives to make a DUE and MEGA talk to each other via RS485 ?

Hi i have successfully used it from mega to due. Their are problems with data type size. I use types like uint16 and similar. I have had problems with floats as well for some reason even though a float is the same size on both it doesn't like you mixing types. I got round this by using all floats and the a union at each end to get 4 bytes out and in.

this is an example of a struct that works for me

struct RECEIVE_DATA_STRUCTURE{
  byte MIDI_Screen [ScreenSize]; 
  byte sensorScreen [ScreenSize];
  HandPoint Hand;
  boolean Gate;
   uint8_t Genral; //for debugging

};
struct SEND_DATA_STRUCTURE{

  ColourNoAlpha Screen_Output [ScreenSize][ScreenSize];
  uint8_t Genral; // Mode
};

Ive just taken that straight from my code that is the Due end but obviously the mege end looks the same with tx/rx reversed.

EVP:
Hi i have successfully used it from mega to due. Their are problems with data type size. I use types like uint16 and similar. I have had problems with floats as well for some reason even though a float is the same size on both it doesn't like you mixing types. I got round this by using all floats and the a union at each end to get 4 bytes out and in.

this is an example of a struct that works for me

struct RECEIVE_DATA_STRUCTURE{

byte MIDI_Screen [ScreenSize];
  byte sensorScreen [ScreenSize];
  HandPoint Hand;
  boolean Gate;
   uint8_t Genral; //for debugging

};
struct SEND_DATA_STRUCTURE{

ColourNoAlpha Screen_Output [ScreenSize][ScreenSize];
  uint8_t Genral; // Mode
};




Ive just taken that straight from my code that is the Due end but obviously the mege end looks the same with tx/rx reversed.

Ah, glad you've bashed it into submission - do the endianness's match then?

Due has proper doubles, Mega has doubles faked as just float, but if you stick to
just float they ought to match up if int16's match as endianness is the only issue
then?

I gave up the idea to use a DUE but now reading this i will give another try.
Thanks !

Just noticed this reply, my code wasn't all that clear. to be clear type Handpoint is a struct of two uint8_t's and ColourNoAlpha is a struct of three uint8_t's. I never got round to checking the question about uint16_t's but their is defiantly an issue along those lines going on. As i said i found if i used floats i could only use floats and not mix them. But with a bit of messing most things should be possible.

I tried again but without success, the DUE won't receive anything.
Could you give me the stucture of a working sketch ?

I use this but it doesn't work

struct SEND_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to receive
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  float temp1;
  float temp2;
};

Ahh,just remembered i posted this a bit back, this should clear it up. The library doesn't work as it is it need editing. Here is my post on it from last year. hope it works for you. I'm using version 1.7

http://forum.arduino.cc/index.php?topic=144679.msg1086585#msg1086585

EVP:
Ahh,just remembered i posted this a bit back, this should clear it up. The library doesn't work as it is it need editing. Here is my post on it from last year. hope it works for you. I'm using version 1.7

Easy Transfer and Due - Arduino Due - Arduino Forum

It works !!!
Thanks for sorting this out, this will make a huge speed difference for my project as I will be able to use the DUE for my TFT.
I can now use EASYTRANSFER between the MEGA and the DUE in both directions (only with floats but I can live with that)
THIS IS GREAT !!!
Thank you so much.

:slight_smile:
Glad it worked!. You only have to use only floats if you use a float at all. But i think we covered that. If you don't use i think there is a bit more flexibility. Anyway which ever way you do it you can always use unions to get it to do what you want.