Notifications
Clear all

Structures, Serialisation, XOR Checksums etc.

91 Posts
7 Users
8 Likes
25.5 K Views
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

   
Quote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

   
frogandtoad and ZeFerby reacted
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 

@pugwash Nice work Steve.  Thanks for sharing these educational articles.  Your code is very well formatted and easily readable.  Using a struct to set up the variables is a nice touch too.

@frogandtoad, Thanks to you as well for your contributions to this project.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@pugwash

Glad to help, and more importantly glad that you were able to get your project up and working!
Welcome to the world of using objects to encapsulate data... once you have a grip on them, you'll never want to write procedural code again 🙂

I'll have more time over the weekend, and looking forward to your next version!

Cheers!

 


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@robo-pi

Thank's, and you're welcome!
I hope some of OOP techniques help all viewers to see how they can be beneficial even with an Arduino!

Cheers!

 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@frogandtoad, @robo-pi 

Thank you guys, for the words of encouragement! I expect to get the next version finished by the weekend.

I hope some of OOP techniques help all viewers to see how they can be beneficial even with an Arduino!

As far as OOP is concerned, there's no turning back now! ? 

I can envisage countless possibilities for its usage. I do work with OOP in both Java and Python, but didn't realise, until now, that it could also be used with the slimmed-down version of C++ for the Arduino.

I just wonder how many other tools are lurking below the surface of C++, that can be used with the Arduino or other boards! ? 

 


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 

@pugwash

I think I saw some templates used in libraries ("generic" classes/functions that you can "specialize" with specific datatypes).

Some C++ templates infos :

https://www.geeksforgeeks.org/templates-cpp/

http://www.cplusplus.com/doc/oldtutorial/templates/

https://en.cppreference.com/w/cpp/language/templates

Eric


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

@zeferby

Thanks for the tip Eric, I'll take a look at them when I have got a bit more time on my hands!

Gotta run! It's my cards and booze night ? ? ? 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

 

After wallowing in the praise lavished on me yesterday, I now have to eat a large slice of humble pie!

I thought, before moving on to phase 2, I have to do one more code test and that was to force a checksum error. So I manipulated the checksum, expecting the "Checksum not valid" to be returned.

Oooops! It didn't happen!

Half an hour before my cards session, it wasn't working, I read and reread the code but still couldn't see the mistake. After a few rounds of cards and a couple of beers, it dawned on me, what I was doing wrong! So as soon as I got home and to a chorus of "what are you doing on the computer at this time of night?" (punctuated with a few expletives) from my better half, I fixed it. All I needed to do was change

if(validateChecksum){

to

if(validateChecksum()){

and it worked properly!

So this morning over a cuppa, I came up with the following alternative to "he's lost his marbles" or "he's one bun short of a baker's dozen"!

He's two parentheses short of a function call!

? ? ? ? ? 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
Topic starter  

Another Quantum Leap!

The code has now been altered to accommodate one base station and two remote sensor stations. Adding more stations(nodes) should be pretty straightforward.

Resend requests are sent to the offending station directly.

I was just wondering how I could simulate this, not wishing to repeat my last mistake, when I suddenly got a very rare checksum error and as shown in the picture below, despite the remotes alternately sending data, the requested data is resent immediately from the station sending the corrupted data.

rf24 test

I will just attach the files this time, for your perusal.

All comments welcome!


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 

Hi Steve,

Thank you, Thank You...  for a great Find and presentation...

I will probably change my system to use this one.

I presume that your program Links are updated after all of the changes & corrections have been made?

I don't think I would have to read all of the above and make required changes...  would I?  🙂

Thanks again!

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Page 1 / 7