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
Model registry
Operate
Environments
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
Martin Teichmann
ebpfCAT
Commits
6deb6bb0
Commit
6deb6bb0
authored
1 year ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
parallelize keeping operational
now we can keep many terminals operational within the same EtherCAT roundtrip
parent
0a452dc5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ebpfcat/ebpfcat.py
+16
-10
16 additions, 10 deletions
ebpfcat/ebpfcat.py
ebpfcat/ethercat.py
+3
-5
3 additions, 5 deletions
ebpfcat/ethercat.py
ebpfcat/ethercat_test.py
+0
-4
0 additions, 4 deletions
ebpfcat/ethercat_test.py
with
19 additions
and
19 deletions
ebpfcat/ebpfcat.py
+
16
−
10
View file @
6deb6bb0
...
...
@@ -534,16 +534,22 @@ class SyncGroup(SyncGroupBase):
return
self
.
current_data
async
def
to_operational
(
self
):
r
=
await
gather
(
*
[
t
.
to_operational
()
for
t
in
self
.
terminals
])
while
True
:
for
t
in
self
.
terminals
:
state
,
error
=
await
t
.
get_state
()
if
state
!=
8
:
# operational
logging
.
warning
(
"
terminal is not operational, state is %i
"
,
error
)
await
t
.
to_operational
()
await
sleep
(
1
)
try
:
await
gather
(
*
[
t
.
to_operational
()
for
t
in
self
.
terminals
])
while
True
:
r
=
await
gather
(
*
[
t
.
to_operational
()
for
t
in
self
.
terminals
])
for
t
,
(
state
,
error
,
status
)
in
zip
(
self
.
terminals
,
r
):
if
state
is
not
MachineState
.
OPERATIONAL
:
logging
.
warning
(
"
terminal %s was not operational, status was %i
"
,
t
,
status
)
await
sleep
(
1
)
except
CancelledError
:
raise
except
Exception
:
logging
.
exception
(
'
to_operational failed
'
)
raise
def
start
(
self
):
self
.
allocate
()
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/ethercat.py
+
3
−
5
View file @
6deb6bb0
...
...
@@ -609,17 +609,15 @@ class Terminal:
await
self
.
ec
.
roundtrip
(
ECCmd
.
FPWR
,
self
.
position
,
0x0120
,
"
H
"
,
0x11
)
state
=
MachineState
.
INIT
pos
=
order
.
index
(
state
)
+
1
state
=
None
for
current
in
order
[
pos
:]:
for
current
in
order
[
order
.
index
(
state
)
+
1
:]:
if
state
.
value
>=
target
.
value
:
return
ret
await
self
.
ec
.
roundtrip
(
ECCmd
.
FPWR
,
self
.
position
,
0x0120
,
"
H
"
,
current
.
value
)
while
current
is
not
state
:
state
,
error
,
status
=
await
self
.
get_state
()
if
error
:
raise
EtherCatError
(
f
"
AL register error
{
status
}
"
)
if
state
.
value
>=
target
.
value
:
return
ret
async
def
read
(
self
,
start
,
*
args
,
**
kwargs
):
"""
read data from the terminal at offset `start`
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/ethercat_test.py
+
0
−
4
View file @
6deb6bb0
...
...
@@ -162,7 +162,6 @@ class Tests(TestCase):
"
04000200801110000000000000000000000000000000000000000000
"
"
3333
"
),
# padding
0x66554433
,
# index
(
ECCmd
.
FPRD
,
2
,
304
,
'
H2xH
'
),
# get_state
H
(
"
2a10
"
# EtherCAT Header, length & type
"
0000334455660280000000000000
"
# ID datagram
# in datagram
...
...
@@ -176,7 +175,6 @@ class Tests(TestCase):
# in datagram
"
04000400801110000000123456780000000000000000000000000100
"
"
3333
"
),
# padding
(
8
,
0
),
# return state 8, no error
]
with
self
.
assertNoLogs
():
await
self
.
new_data
()
...
...
@@ -217,7 +215,6 @@ class Tests(TestCase):
"
0500030000110800000000000000000000000000
"
# out datagram
"
33333333333333333333
"
),
# padding
0x55443322
,
# index
(
ECCmd
.
FPRD
,
3
,
304
,
'
H2xH
'
),
# get_state
H
(
"
2210
"
# EtherCAT Header, length & type
"
0000223344550280000000000000
"
# ID datagram
"
0500030000110800000076980000000000000000
"
# out datagram
...
...
@@ -234,7 +231,6 @@ class Tests(TestCase):
"
0000223344550280000000000000
"
# ID datagram
"
0500030000110800000000000000000000000100
"
# out datagram
"
33333333333333333333
"
),
# padding
(
8
,
0
),
# return state 8, no error
H
(
"
2210
"
# EtherCAT Header, length & type
"
0000223344550280000000000000
"
# ID datagram
"
0500030000110800000000000000000000000100
"
# out datagram
...
...
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