September 2019 Update

New! We're moving to the new forum, eventually it will replace this blog. Please join us there.

View the Most Recent Feature Sheet by clicking HERE!

Saturday, August 17, 2019

In an orderly fashion...

Posted: 2:30pm


Things are looking pretty darn good right now (knock on wood!).  I don't know how to describe it, but watching it run is like watching a precision military marching band whereas in the past, it was like watching recruits wearing clown shoes...

There is no more overlapping data being sent over the serial port, everything is based on acknowledgements, and knowing what happens next.

For example:

The 8266 sends a scan request to the 2560, and waits for an acknowledgement
The 2560 receives the scan request, and acknowledges to the 8266
The 2560 scans the specified sensor
The 2560 sends the response to the 8266 and waits for an acknowledgement
The 8266 receives the response and sends an acknowledgement to the 2560


That by itself works perfectly... which is how I tested it while writing it, one sensor...

When it loops through a list of sensors, something happens...

Once the 8266 sends the scan request, and gets the acknowledgement, that's it, that is considered one transaction, a complete one...

The fact that the result came back was like a pleasant surprise.... but one the 8266 was waiting for, it had nothing else to do....

But, if once it sends the first scan request, and receives the acknowledgement, it merrily goes off to send the scan request for the next sensor.  Now we have colliding data again.

Lets look at the above statement again...

There is no more overlapping data being sent over the serial port, everything is based on acknowledgements, and knowing what happens next.

You can see the acknowledgments in action in the above scenario, but the knowing what happens next is the new part today...

When we send the scan command, we need to have it acknowledged so we know it was received complete. But we also know that's not the end of the conversation, we are expecting it to do something, and send back a response, and because we know this, and are expecting it for a scan command, we can anticipate it, and wait for it before we move on, just like we wait for an acknowledgement. That's the concept, and it works, I handled it a little differently thoug. Since I want to wait until I have not only received the results payload, but have finished processing it, and saved it to the database, I am using a flag that I set on the sensorCfg record when I have finished with it. 


No comments:

Post a Comment

Any comments deemed off topic or offensive will be removed