This repository has been archived by the owner on Dec 20, 2019. It is now read-only.
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.
Running
[email protected]
and[email protected]
on Linux 4.11.6-3-ARCH #1 SMP PREEMPT Thu Jun 22 12:21:46 CEST 2017 x86_64 GNU/Linux.Issue
Hence the long package answers, it seems only notable with
collission detection
. Sometimes, a long list of sync losses apears andcollsion detection
stucks since waiting for sync responses. There are two main causes for that.Cause 1
A typical collsion detection package could have 17 bytes, which can get split over two BLE packages like this:
At two positions it is assumed that the minimal package size is at least 6 bytes (https://github.com/orbotix/sphero.js/blob/master/lib/adaptors/ble.js#L168 and https://github.com/orbotix/sphero.js/blob/master/lib/packet.js#L85)
The last two bytes get eaten and instead, another valid package got attached and will become invalid making the whole collision detection inapplicable.
Solution 1
Except all package length and use a different parsing idea https://github.com/orbotix/sphero.js/blob/master/lib/packet.js#L71.
Basically, the core still remains with the "checkIfValid" function. However, smaller packets get stored for further use. Thus, a new function is needed checking whether a small package / concatenated package is for sure invalid.
For example, the inital sync has for some reason the package 753e to offer, which get's dropped.
Cause 2
Two sync responses can be packed in one BLE package like this:
ff ff 00 42 01 bc ff ff 00 43 01 bb
.Computing the first package and only compute the rest bytes in the next response results again in a chain of sync losses.
Solution 2
If the received (fresh) buffer is valid (in the meaning of the old
parse
method) compute this and drop the temporal buffer (the old package). Thus, only one sync loss appears. From what I can see, it needs changes in the whole parsing infrastructure to implement a clean solution.