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
7c6e2a2d
Commit
7c6e2a2d
authored
2 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
improve error messages
parent
34bb022c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ebpfcat/ebpfcat.py
+3
-8
3 additions, 8 deletions
ebpfcat/ebpfcat.py
ebpfcat/ethercat.py
+12
-3
12 additions, 3 deletions
ebpfcat/ethercat.py
with
15 additions
and
11 deletions
ebpfcat/ebpfcat.py
+
3
−
8
View file @
7c6e2a2d
...
...
@@ -211,18 +211,13 @@ class EBPFTerminal(Terminal):
compatibility
=
None
position_offset
=
0
,
0
def
__init_subclass__
(
cls
):
cls
.
pdo
=
{}
for
c
in
cls
.
__mro__
[::
-
1
]:
for
k
,
v
in
c
.
__dict__
.
items
():
if
isinstance
(
v
,
PacketDesc
):
cls
.
pdo
[
k
]
=
v
async
def
initialize
(
self
,
relative
,
absolute
):
await
super
().
initialize
(
relative
,
absolute
)
if
(
self
.
compatibility
is
not
None
and
(
self
.
vendorId
,
self
.
productCode
)
not
in
self
.
compatibility
):
raise
RuntimeError
(
f
"
Incompatible Terminal:
{
self
.
vendorId
}
:
{
self
.
productCode
}
(
{
relative
}
,
{
absolute
}
)
"
)
raise
RuntimeError
(
f
"
Incompatible Terminal:
{
self
.
vendorId
}
:
{
self
.
productCode
}
"
f
"
(
{
relative
}
,
{
absolute
}
)
"
)
def
allocate
(
self
,
packet
,
readonly
):
if
self
.
pdo_in_sz
:
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/ethercat.py
+
12
−
3
View file @
7c6e2a2d
...
...
@@ -334,7 +334,8 @@ class EtherCat(Protocol):
out
+=
b
"
\0
"
*
data
elif
data
is
not
None
:
out
+=
data
assert
isinstance
(
pos
,
int
)
and
isinstance
(
offset
,
int
)
assert
isinstance
(
pos
,
int
)
and
isinstance
(
offset
,
int
),
\
f
"
pos:
{
pos
}
offset:
{
offset
}
"
self
.
send_queue
.
put_nowait
((
cmd
,
out
,
idx
,
pos
,
offset
,
future
))
ret
=
await
future
if
data
is
None
:
...
...
@@ -531,11 +532,15 @@ class Terminal:
return
eeprom
eeprom
[
hd
]
=
await
get_data
(
ws
*
2
)
def
has_mailbox
(
self
):
return
self
.
mbx_out_off
is
not
None
and
self
.
mbx_in_off
is
not
None
async
def
mbx_send
(
self
,
type
,
*
args
,
data
=
None
,
address
=
0
,
priority
=
0
,
channel
=
0
):
"""
send data to the mailbox
"""
status
,
=
await
self
.
read
(
0x805
,
"
B
"
)
# always using mailbox 0, OK?
if
status
&
8
:
raise
RuntimeError
(
"
mailbox full, read first
"
)
assert
self
.
mbx_out_off
is
not
None
,
"
not send mailbox defined
"
await
self
.
write
(
self
.
mbx_out_off
,
"
HHBB
"
,
datasize
(
args
,
data
),
address
,
channel
|
priority
<<
6
,
...
...
@@ -551,6 +556,7 @@ class Terminal:
while
status
&
8
==
0
:
# always using mailbox 1, OK?
status
,
=
await
self
.
read
(
0x80D
,
"
B
"
)
assert
self
.
mbx_in_off
is
not
None
,
"
not receive mailbox defined
"
dlen
,
address
,
prio
,
type
,
data
=
await
self
.
read
(
self
.
mbx_in_off
,
"
HHBB
"
,
data
=
self
.
mbx_in_sz
-
6
)
return
MBXType
(
type
&
0xf
),
data
[:
dlen
]
...
...
@@ -586,7 +592,9 @@ class Terminal:
raise
RuntimeError
(
f
"
expected CoE, got
{
type
}
"
)
coecmd
,
sdocmd
,
idx
,
subidx
,
size
=
unpack
(
"
<HBHBI
"
,
data
[:
10
])
if
coecmd
>>
12
!=
CoECmd
.
SDORES
.
value
:
raise
RuntimeError
(
f
"
expected CoE SDORES (3), got
{
coecmd
>>
12
:
x
}
"
)
raise
RuntimeError
(
f
"
expected CoE SDORES (3), got
{
coecmd
>>
12
:
x
}
"
f
"
for
{
index
:
X
}
:
{
9
if
subindex
is
None
else
subindex
:
02
X
}
"
)
if
idx
!=
index
:
raise
RuntimeError
(
f
"
requested index
{
index
}
, got
{
idx
}
"
)
if
sdocmd
&
2
:
...
...
@@ -605,7 +613,8 @@ class Terminal:
raise
RuntimeError
(
f
"
expected CoE, got
{
type
}
"
)
coecmd
,
sdocmd
=
unpack
(
"
<HB
"
,
data
[:
3
])
if
coecmd
>>
12
!=
CoECmd
.
SDORES
.
value
:
raise
RuntimeError
(
f
"
expected CoE cmd SDORES, got
{
coecmd
}
"
)
raise
RuntimeError
(
f
"
expected CoE cmd SDORES, got
{
coecmd
}
"
)
if
sdocmd
&
0xe0
!=
0
:
raise
RuntimeError
(
f
"
requested index
{
index
}
, got
{
idx
}
"
)
if
sdocmd
&
1
and
len
(
data
)
==
7
:
...
...
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