Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
4f0b6df4
Commit
4f0b6df4
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-502
: Print all packets received on stdin, and support SST/XST/BST.
parent
ec6354fb
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!189
L2SS-502: Print all packets received on stdin, and support SST/XST/BST.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py
+36
-12
36 additions, 12 deletions
...trol/tangostationcontrol/devices/sdp/statistics_packet.py
with
36 additions
and
12 deletions
tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py
+
36
−
12
View file @
4f0b6df4
...
...
@@ -75,13 +75,13 @@ class StatisticsPacket(object):
"
Invalid SDP statistics packet: packet marker (first byte) is {}, not one of
'
SBX
'
.
"
.
format
(
self
.
marker
))
# format string for the header, see unpack below
header_format
=
"
>cBL HHB BHL BBH HQ
"
header_size
=
struct
.
calcsize
(
header_format
)
def
unpack
(
self
):
"""
Unpack the packet into properties of this object.
"""
# format string for the header, see unpack below
self
.
header_format
=
"
>cBL HHB BHL BBH HQ
"
self
.
header_size
=
struct
.
calcsize
(
self
.
header_format
)
# unpack fields
try
:
(
self
.
marker_raw
,
...
...
@@ -335,11 +335,35 @@ def main(args=None, **kwargs):
import
sys
import
pprint
# read all of stdin, even though we only parse the first packet. we're too lazy to intelligently decide when
# the packet is complete and can stop reading.
data
=
sys
.
stdin
.
buffer
.
read
()
packet
=
SSTPacket
(
data
)
# print header & payload
pprint
.
pprint
(
packet
.
header
())
pprint
.
pprint
(
packet
.
payload
)
# packet counter
nr
=
0
# byte offset in the stream
offset
=
0
while
True
:
# read just the header
header
=
sys
.
stdin
.
buffer
.
read
(
StatisticsPacket
.
header_size
)
if
not
header
:
break
# read the payload
packet
=
StatisticsPacket
(
header
)
payload_size
=
packet
.
expected_size
()
-
len
(
header
)
payload
=
sys
.
stdin
.
buffer
.
read
(
payload_size
)
# construct the packet based on type
if
packet
.
marker
==
'
S
'
:
packet
=
SSTPacket
(
header
+
payload
)
elif
packet
.
marker
==
'
X
'
:
packet
=
XSTPacket
(
header
+
payload
)
elif
packet
.
marker
==
'
B
'
:
packet
=
BSTPacket
(
header
+
payload
)
# print header
print
(
f
"
# Packet
{
nr
}
starting at offset
{
offset
}
"
)
pprint
.
pprint
(
packet
.
header
())
# increment counters
nr
+=
1
offset
+=
len
(
header
)
+
len
(
payload
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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