Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ebpfCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
karaboDevices
ebpfCAT
Commits
1bd5250e
Commit
1bd5250e
authored
1 year ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
do not send to big packets
parent
a6bd832a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/ethercat.py
+25
-11
25 additions, 11 deletions
ebpfcat/ethercat.py
with
25 additions
and
11 deletions
ebpfcat/ethercat.py
+
25
−
11
View file @
1bd5250e
...
...
@@ -215,7 +215,7 @@ class Packet:
packets. We implicitly add a datagram in the front which later serves
as an identifier for the packet.
"""
MAXSIZE
=
1
0
00
# maximum size we use for an EtherCAT packet
MAXSIZE
=
1
5
00
# maximum size we use for an EtherCAT packet
ETHERNET_HEADER
=
14
PACKET_HEADER
=
16
DATAGRAM_HEADER
=
10
...
...
@@ -236,8 +236,15 @@ class Packet:
Depending on the command, one or two more parameters represent the
address, either terminal and offset for position or node addressing,
or one value for logical addressing.
"""
newsize
=
self
.
size
+
len
(
data
)
+
self
.
DATAGRAM_HEADER
\
+
self
.
DATAGRAM_TAIL
if
newsize
>
self
.
MAXSIZE
:
raise
OverflowError
(
"
ethercat packet size too big
"
)
elif
len
(
self
.
data
)
>
14
:
raise
OverflowError
(
"
Too many datagrams per packet
"
)
self
.
data
.
append
((
cmd
,
data
,
idx
)
+
address
)
self
.
size
+
=
len
(
data
)
+
self
.
DATAGRAM_HEADER
+
self
.
DATAGRAM_TAIL
self
.
size
=
newsize
def
assemble
(
self
,
index
):
"""
Assemble the datagrams into a packet
...
...
@@ -306,17 +313,24 @@ class EtherCat(Protocol):
to be sent from a queue, packs them in a packet and ships them
out.
"""
try
:
packet
=
Packet
()
dgrams
=
[]
packet
=
Packet
()
sent
=
True
while
True
:
*
dgram
,
future
=
await
self
.
send_queue
.
get
()
lastsize
=
packet
.
size
packet
.
append
(
*
dgram
)
dgrams
.
append
((
lastsize
+
10
,
packet
.
size
-
2
,
future
))
if
packet
.
full
()
or
self
.
send_queue
.
empty
():
ensure_future
(
self
.
process_packet
(
dgrams
,
packet
))
dgrams
=
[]
packet
=
Packet
()
if
sent
:
*
dgram
,
future
=
await
self
.
send_queue
.
get
()
try
:
lastsize
=
packet
.
size
packet
.
append
(
*
dgram
)
dgrams
.
append
((
lastsize
+
10
,
packet
.
size
-
2
,
future
))
sent
=
True
if
not
self
.
send_queue
.
empty
():
continue
except
OverflowError
:
sent
=
False
ensure_future
(
self
.
process_packet
(
dgrams
,
packet
))
dgrams
=
[]
packet
=
Packet
()
except
CancelledError
:
raise
except
Exception
:
...
...
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