gpstar81 / GPStar-proton-pack

GPStar Proton Pack and Neutrona Wand
https://www.gpstartechnologies.com
GNU General Public License v3.0
38 stars 9 forks source link

Refactor serial handshake #269

Closed nomakewan closed 8 months ago

nomakewan commented 8 months ago

This PR completely refactors the serial handshake process between the Proton Pack and Neutrona Wand. It makes the actual handshake process more state-driven, increases the number of pings the Pack will wait for before starting a timeout from 1 to 2, and creates a new serial data struct specifically for synchronizing initial settings between the Pack and Wand.

Please put this through its paces and make sure nothing got fundamentally broken in the shuffle. Please note that further code efficiency is possible with this new struct in place as several Pack commands may no longer be necessary, and that this struct could also be expanded if necessary to allow other devices to share sync data as well. For example, leaning out the Pack-to-Attenuator sync process in a similar way.

DustinGrau commented 8 months ago

As we begin to consolidate items like this, it makes sense to consider whether we should switch to using the various struct objects as the source of truth for the pack and wand states, as opposed to individual variables. Yes, we would lose the "bool" variables, though at their core they are simply uint8_t (byte) values anyway. If we were to switch to simply setting the struct values with any changes, it will reduce the swapping/assigning of values across the codebase for each device and make it simpler to send via serial comms when necessary. Just a thought.