This repository was archived by the owner on Dec 20, 2019. It is now read-only.
Bug/BLE packet parsing#91
Open
scheunemann wants to merge 4 commits into
Open
Conversation
… notifications" are of 22 bytes, so they may come in two separate packages of 24 and 4 bytes (containing sphero.js packages of 20 and 2 bytes)
… are of minimal length (6 bytes) and have not a valid header.
…size correct + some extra bytes) or unvalid (proper header for fragments >= 2 bytes) Change logic, drop first package if two valid packages are received
Author
|
Regarding the failed test: "Packet #parse with sync response SOPs don't pass validation and @partialBuffer is emptytialBuffer should not be empty" is a described case in the request. If ignored, that's the only fail. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
bluez@5.45andnode@v6.10.3on 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 detectionstucks 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
parsemethod) 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.