Have two ESP32 units, using sketch Code from DroneBot Workshop. Sending myData successfully to receiving unit and printing on LCD screen successfully. How do I get the "myData.x" converted back to the original form so I can make decisions/calculations within the receiving unit?
// Define a data structure typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message; // Create a structured object struct_message myData;
Have two ESP32 units, using sketch Code from DroneBot Workshop. Sending myData successfully to receiving unit and printing on LCD screen successfully. How do I get the "myData.x" converted back to the original form so I can make decisions/calculations within the receiving unit?
// Define a data structure typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message; // Create a structured object struct_message myData;
Not sure what you mean, if you mean working with the individual fields, then syntax like myData.b can be read or changed if on other side of the equation. Is that what you wanted to know?
Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting
Not quite following your reply. Please give an example about the "other side of the equation". e.g. : a=myData.a
@otto To retrieve data from the structure you would code
b = myData.b;
To store data in the structure you would code
myData.b = b;
Where b is int and myData.b is int
Clear?
of course the char array a requires a little more work, but by now you should understand what is needed.
Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting
Ron, thanx very much. Have put the equations into the code, but haven't had time to test yet, thanks again
@otto Just remember the char array will need appropriate strxxxx or memxxx helpers depending on if the array is really just a char array or is actually a string. Then you must deal with if the string is /0 terminated or not. I am old school but understand there are C++ things to deal with that situation that I am only vaguely aware of. Perhaps one of our C++ members will chime in.
Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting