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
5bdbdbad
Commit
5bdbdbad
authored
4 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
bla
parent
9b012c20
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ethercat.py
+30
-8
30 additions, 8 deletions
ethercat.py
with
30 additions
and
8 deletions
ethercat.py
+
30
−
8
View file @
5bdbdbad
...
...
@@ -118,8 +118,15 @@ class Terminal:
async
def
to_operational
(
self
):
"""
try to bring the terminal to operational state
"""
order
=
[
0x11
,
1
,
2
,
4
,
8
]
ret
,
=
await
self
.
ec
.
roundtrip
(
4
,
self
.
position
,
0x0130
,
"
H
"
)
order
=
[
1
,
2
,
4
,
8
]
ret
,
error
=
await
self
.
ec
.
roundtrip
(
4
,
self
.
position
,
0x0130
,
"
H2xH
"
)
print
(
ret
,
error
)
if
ret
&
0x10
:
await
self
.
ec
.
roundtrip
(
5
,
self
.
position
,
0x0120
,
"
H
"
,
0x11
)
ret
,
error
=
await
self
.
ec
.
roundtrip
(
4
,
self
.
position
,
0x0130
,
"
H2xH
"
)
print
(
"
B
"
,
ret
,
error
)
pos
=
order
.
index
(
ret
)
s
=
0x11
for
state
in
order
[
pos
:]:
...
...
@@ -133,18 +140,33 @@ class Terminal:
async
def
get_error
(
self
):
return
(
await
self
.
ec
.
roundtrip
(
4
,
self
.
position
,
0x0134
,
"
H
"
))[
0
]
async
def
read
(
self
,
start
,
fmt
):
return
(
await
self
.
ec
.
roundtrip
(
4
,
self
.
position
,
start
,
fmt
))
async
def
write
(
self
,
start
,
fmt
,
*
args
):
return
(
await
self
.
ec
.
roundtrip
(
5
,
self
.
position
,
start
,
fmt
,
*
args
))
async
def
main
():
ec
=
await
EtherCat
(
"
eth0
"
)
tin
=
Terminal
(
ec
)
tout
=
Terminal
(
ec
)
tdigi
=
Terminal
(
ec
)
await
tin
.
initialize
(
-
1
,
5
)
await
tout
.
initialize
(
-
2
,
6
)
await
tdigi
.
initialize
(
0
,
22
)
await
tin
.
to_operational
()
await
tout
.
to_operational
()
await
tdigi
.
to_operational
()
await
gather
(
tin
.
initialize
(
-
1
,
5
),
tout
.
initialize
(
-
2
,
6
),
tdigi
.
initialize
(
0
,
22
),
)
print
(
"
tin
"
)
await
tin
.
to_operational
(),
print
(
"
tout
"
)
await
tout
.
to_operational
(),
print
(
"
tdigi
"
)
await
tdigi
.
to_operational
(),
print
(
tout
.
eeprom
[
10
])
print
(
await
tout
.
write
(
0x1100
,
"
HHHH
"
,
10000
,
20000
,
30000
,
40000
))
print
(
await
tin
.
read
(
0x1180
,
"
HHHHHHHH
"
))
if
__name__
==
"
__main__
"
:
loop
=
get_event_loop
()
...
...
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