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
e3f6b3b1
"README.md" did not exist on "56bac4c9a04156bcf03a5e76d92ad228a8c4a7d8"
Commit
e3f6b3b1
authored
11 months ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
write more documentation
parent
548c35e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#136172
passed
11 months ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/ebpfcat.py
+73
-0
73 additions, 0 deletions
ebpfcat/ebpfcat.py
with
73 additions
and
0 deletions
ebpfcat/ebpfcat.py
+
73
−
0
View file @
e3f6b3b1
...
@@ -37,6 +37,18 @@ from .bpf import (
...
@@ -37,6 +37,18 @@ from .bpf import (
class
PacketDesc
:
class
PacketDesc
:
"""
A single value in a process data
This describes some data in the process data coming from or sent to
a terminal. This is the low-level version of :class:`ProcessDesc`, which
can be used if the terminal
'
s self-desciption is lacking.
:param sm: the sync manager, either :attr:`SyncManager.IN` or
:attr:`SyncManager.OUT`.
:param position: the byte position in the process data
:param size: either a :mod:`python:struct` definition of a data type,
or an integer denoting the bit within a byte to be adressed.
"""
def
__init__
(
self
,
sm
,
position
,
size
):
def
__init__
(
self
,
sm
,
position
,
size
):
self
.
sm
=
sm
self
.
sm
=
sm
self
.
position
=
position
self
.
position
=
position
...
@@ -147,6 +159,27 @@ class PacketVar(MemoryDesc):
...
@@ -147,6 +159,27 @@ class PacketVar(MemoryDesc):
class
TerminalVar
:
class
TerminalVar
:
"""
a device variable to be linked to a process variable
Whithin a :class:`Device`, one can refer to process variables that should
later be linked to process variables of a terminal. Within the device, one
can access the process variable generically. Upon instantiation one would
then assign a :class:`ProcessDesc` (or :class:`PacketDesc`) to it to link
the variable to an actual terminal.
For example::
class MyDevice(Device):
the_output = TerminalVar()
def program(self):
self.the_output = 5 # write 5 to whatever variable linked
terminal = MyTerminal()
device = MyDevice()
device.the_output = terminal.output5 # link the_output to output5
"""
def
__set__
(
self
,
instance
,
value
):
def
__set__
(
self
,
instance
,
value
):
if
isinstance
(
value
,
PacketVar
):
if
isinstance
(
value
,
PacketVar
):
instance
.
__dict__
[
self
.
name
]
=
value
instance
.
__dict__
[
self
.
name
]
=
value
...
@@ -172,6 +205,28 @@ class TerminalVar:
...
@@ -172,6 +205,28 @@ class TerminalVar:
class
DeviceVar
(
ArrayGlobalVarDesc
):
class
DeviceVar
(
ArrayGlobalVarDesc
):
"""
A variable in a device for higher-level use
define a variable within a device which the device
'
s user can
access. This is especially important for fast devices, this is the
way data is communicated to and from the EBPF program.
For non-fast devices, this acts like normal Python variables.
:param size: the size of a variable in :mod:`python:struct` letters
:param write: whether the variable will be written to by the user
For example::
class MyDevice(Device):
my_data = DeviceVar()
def program(self):
self.my_data = 7
device = MyDevice()
print(self.my_data) # should print 7 once the program is running
"""
def
__init__
(
self
,
size
=
"
I
"
,
write
=
False
):
def
__init__
(
self
,
size
=
"
I
"
,
write
=
False
):
super
().
__init__
(
FastSyncGroup
.
properties
,
size
)
super
().
__init__
(
FastSyncGroup
.
properties
,
size
)
self
.
write
=
write
self
.
write
=
write
...
@@ -287,6 +342,23 @@ class EBPFTerminal(Terminal):
...
@@ -287,6 +342,23 @@ class EBPFTerminal(Terminal):
class
EtherXDP
(
XDP
):
class
EtherXDP
(
XDP
):
"""
The EtherCat packet dispatcher
This class creates an EBPF program that receives EtherCAT packet
from the network and dispatches them to the sync group they belong
to, or passes them on to user space if they do not belong to them.
For each sync group, there are always two packets on the wire, one
that only reads value from the terminals, the other one also writes.
Usually only the read-write packet is handed over to the sync group
'
s
program. If, however, that packet gets lost, the next read-only
packet is handed over.
User space is supposed to constantly feed in new packets, and the
then-superfluous packets are sent back to user space. This way user
space can constantly read data independent of the EBPF program. It
cannot write, however, as this would cause priority issues.
"""
license
=
"
GPL
"
license
=
"
GPL
"
minimumPacketSize
=
30
minimumPacketSize
=
30
...
@@ -336,6 +408,7 @@ class SimpleEtherCat(EtherCat):
...
@@ -336,6 +408,7 @@ class SimpleEtherCat(EtherCat):
class
FastEtherCat
(
SimpleEtherCat
):
class
FastEtherCat
(
SimpleEtherCat
):
"""
An EtherCAT driver class for fast and slow sync groups
"""
MAX_PROGS
=
64
MAX_PROGS
=
64
def
__init__
(
self
,
network
):
def
__init__
(
self
,
network
):
...
...
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