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
d2c3eed2
Commit
d2c3eed2
authored
4 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
nice roundtrip now actually works
parent
204e2322
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
ethercat.py
+14
-24
14 additions, 24 deletions
ethercat.py
with
14 additions
and
24 deletions
ethercat.py
+
14
−
24
View file @
d2c3eed2
...
...
@@ -99,11 +99,7 @@ class ObjectEntry:
def
datasize
(
args
,
data
):
out
=
0
for
arg
in
args
:
if
not
isinstance
(
arg
,
str
):
break
out
+=
calcsize
(
arg
)
out
=
sum
(
calcsize
(
arg
)
for
arg
in
args
if
isinstance
(
arg
,
str
))
if
isinstance
(
data
,
int
):
out
+=
data
elif
data
is
not
None
:
...
...
@@ -149,16 +145,11 @@ class EtherCat(Protocol, AsyncBase):
async
def
roundtrip
(
self
,
cmd
,
pos
,
offset
,
*
args
,
data
=
None
,
idx
=
0
):
future
=
Future
()
fmt
=
"
<
"
out
=
None
for
i
,
arg
in
enumerate
(
args
):
if
not
isinstance
(
arg
,
str
):
break
fmt
+=
arg
else
:
out
=
b
"
\0
"
*
calcsize
(
fmt
)
if
out
is
None
:
out
=
pack
(
fmt
,
*
args
[
i
:])
fmt
=
"
<
"
+
""
.
join
(
arg
for
arg
in
args
[:
-
1
]
if
isinstance
(
arg
,
str
))
out
=
pack
(
fmt
,
*
[
arg
for
arg
in
args
if
not
isinstance
(
arg
,
str
)])
if
args
and
isinstance
(
args
[
-
1
],
str
):
out
+=
b
"
\0
"
*
calcsize
(
args
[
-
1
])
fmt
+=
args
[
-
1
]
if
isinstance
(
data
,
int
):
out
+=
b
"
\0
"
*
data
elif
data
is
not
None
:
...
...
@@ -306,9 +297,8 @@ class Terminal:
return
MBXType
(
type
&
0xf
),
data
[:
dlen
]
async
def
read_ODlist
(
self
):
cmd
=
pack
(
"
<HBxHH
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
LIST_REQ
.
value
,
0
,
1
)
await
self
.
mbx_send
(
MBXType
.
COE
,
data
=
cmd
)
await
self
.
mbx_send
(
MBXType
.
COE
,
"
HBxHH
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
LIST_REQ
.
value
,
0
,
1
)
fragments
=
True
offset
=
8
# skip header in first packet
...
...
@@ -331,9 +321,9 @@ class Terminal:
ret
=
[]
for
index
in
indexes
:
cmd
=
pack
(
"
<HBxHH
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
OD_REQ
.
value
,
0
,
index
)
await
self
.
mbx_send
(
MBXType
.
COE
,
data
=
cmd
)
await
self
.
mbx_send
(
MBXType
.
COE
,
"
HBxHH
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
OD_REQ
.
value
,
0
,
index
)
type
,
data
=
await
self
.
mbx_recv
()
if
type
is
not
MBXType
.
COE
:
...
...
@@ -354,9 +344,9 @@ class Terminal:
for
od
in
ret
:
od
.
entries
=
[]
for
i
in
range
(
od
.
maxSub
):
cmd
=
pack
(
"
<HBxHHBB
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
OE_REQ
.
value
,
0
,
od
.
index
,
i
,
7
)
await
self
.
mbx_send
(
MBXType
.
COE
,
data
=
cmd
)
await
self
.
mbx_send
(
MBXType
.
COE
,
"
HBxHHBB
"
,
CoECmd
.
SDOINFO
.
value
<<
12
,
ODCmd
.
OE_REQ
.
value
,
0
,
od
.
index
,
i
,
7
)
type
,
data
=
await
self
.
mbx_recv
()
if
type
is
not
MBXType
.
COE
:
...
...
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