Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HEV - High Energy Ventilator
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
HEV - High Energy Ventilator
Commits
4b67dc97
Commit
4b67dc97
authored
4 years ago
by
Peter Švihra
Browse files
Options
Downloads
Patches
Plain Diff
fixed wrong packet reading
- could happen if started reading random trailing packet and first got stop flag
parent
785dfca7
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arduino/common/lib/CommsControl/CommsControl.cpp
+2
-2
2 additions, 2 deletions
arduino/common/lib/CommsControl/CommsControl.cpp
raspberry-dataserver/CommsControl.py
+3
-2
3 additions, 2 deletions
raspberry-dataserver/CommsControl.py
with
5 additions
and
4 deletions
arduino/common/lib/CommsControl/CommsControl.cpp
+
2
−
2
View file @
4b67dc97
...
...
@@ -74,8 +74,8 @@ void CommsControl::receiver() {
// find the boundary of frames
if
(
_last_trans
[
current_trans_index
]
==
COMMS_FRAME_BOUNDARY
)
{
// if not found start or if read the same byte as last time
if
(
!
_found_start
||
_star
t_trans_index
==
curren
t_trans_index
)
{
// if not found start or if read the same byte as last time
or if read a random end first
if
(
!
_found_start
||
curren
t_trans_index
<
_star
t_trans_index
+
6
)
{
_found_start
=
true
;
_start_trans_index
=
current_trans_index
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
raspberry-dataserver/CommsControl.py
+
3
−
2
View file @
4b67dc97
...
...
@@ -36,6 +36,7 @@ class CommsControl():
# needed to find packet frames
self
.
_received
=
[]
self
.
_receivedStart
=
0
self
.
_foundStart
=
False
self
.
_timeLastTransmission
=
int
(
round
(
time
.
time
()
*
1000
))
...
...
@@ -136,9 +137,9 @@ class CommsControl():
# TODO: this could be written in more pythonic way
# force read byte by byte
self
.
_received
.
append
(
byte
)
# logging.
debug
(byte)
# logging.
info
(byte)
# find starting flag of the packet
if
not
self
.
_foundStart
and
byte
==
bytes
([
0x7E
]
):
if
byte
==
bytes
([
0x7E
])
and
((
len
(
self
.
_received
)
<
self
.
_receivedStart
+
6
)
or
not
self
.
_foundStart
):
self
.
_foundStart
=
True
self
.
_receivedStart
=
len
(
self
.
_received
)
# find ending flag of the packet
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment