Fix two issues preventing Garmin devices working #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a couple of implementation issues preventing Garmin devices working correctly with OpenMTP (ganeshrvel/openmtp#153).
First, Garmin devices don't typically populate all three device descriptors - usually only the SerialNumber string is available. Previously, we would fail early if any string was unavailable.
Second, Garmin devices separate the header from payload during the data phase. It seems like we previously assumed that if that were the case then the packet would be full, but that's not necessarily true. I've added a check so if we read less than the size the device has said it's going to send, that will also trigger a bulk read of the payload.
Note:
This code was committed on a different computer than was developed, so it probably needs secondary verification. Also, I'm not a Go developer so this may need formatting/rewriting to conform to Go standards.