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
50a88abf
Commit
50a88abf
authored
4 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
support serial connections
parent
ff0a0914
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
+1
-0
1 addition, 0 deletions
ebpfcat/ebpfcat.py
ebpfcat/serial.py
+82
-0
82 additions, 0 deletions
ebpfcat/serial.py
ebpfcat/terminals.py
+20
-0
20 additions, 0 deletions
ebpfcat/terminals.py
with
103 additions
and
0 deletions
ebpfcat/ebpfcat.py
+
1
−
0
View file @
50a88abf
...
@@ -321,6 +321,7 @@ class SyncGroup(SyncGroupBase):
...
@@ -321,6 +321,7 @@ class SyncGroup(SyncGroupBase):
self
.
current_data
=
bytearray
(
data
)
self
.
current_data
=
bytearray
(
data
)
for
dev
in
self
.
devices
:
for
dev
in
self
.
devices
:
dev
.
update
()
dev
.
update
()
await
sleep
(
0
)
def
start
(
self
):
def
start
(
self
):
self
.
allocate
()
self
.
allocate
()
...
...
This diff is collapsed.
Click to expand it.
ebpfcat/serial.py
0 → 100644
+
82
−
0
View file @
50a88abf
from
asyncio
import
ensure_future
,
Event
,
Queue
,
StreamReader
,
gather
from
.ebpfcat
import
Device
,
TerminalVar
class
Serial
(
Device
):
channel
=
TerminalVar
()
def
__init__
(
self
,
channel
):
self
.
buffer
=
Queue
()
self
.
channel
=
channel
self
.
data_arrived
=
Event
()
def
write
(
self
,
data
):
self
.
buffer
.
put_nowait
(
data
)
def
connect
(
self
):
self
.
task
=
ensure_future
(
self
.
run
())
self
.
reader
=
StreamReader
()
return
self
.
reader
,
self
async
def
run
(
self
):
while
not
self
.
channel
.
init_accept
:
self
.
channel
.
init_request
=
True
await
self
.
data_arrived
.
wait
()
self
.
channel
.
init_request
=
False
while
self
.
channel
.
init_accept
:
await
self
.
data_arrived
.
wait
()
await
gather
(
self
.
receive
(),
self
.
transmit
())
async
def
receive
(
self
):
ra
=
self
.
channel
.
receive_accept
while
True
:
rr
=
self
.
channel
.
receive_request
while
rr
==
self
.
channel
.
receive_request
:
self
.
channel
.
receive_accept
=
ra
await
self
.
data_arrived
.
wait
()
self
.
reader
.
feed_data
(
self
.
channel
.
in_string
)
ra
=
not
ra
async
def
transmit
(
self
):
remainder
=
b
""
async
def
inner
():
nonlocal
remainder
s
=
remainder
size
=
len
(
remainder
)
while
not
self
.
buffer
.
empty
()
or
size
==
0
:
if
size
+
len
(
s
)
>
22
:
remainder
=
s
[
22
-
size
:]
yield
s
[:
22
-
size
]
return
else
:
yield
s
size
+=
len
(
s
)
s
=
await
self
.
buffer
.
get
()
while
True
:
ta
=
self
.
channel
.
transmit_accept
tr
=
self
.
channel
.
transmit_request
chunk
=
b
""
.
join
([
s
async
for
s
in
inner
()])
while
ta
==
self
.
channel
.
transmit_accept
:
self
.
channel
.
out_string
=
chunk
self
.
channel
.
transmit_request
=
not
tr
await
self
.
data_arrived
.
wait
()
def
update
(
self
):
self
.
data_arrived
.
set
()
self
.
data_arrived
.
clear
()
def
get_chunk
(
self
):
def
inner
():
size
=
0
while
size
<
22
and
len
(
self
.
buffer
):
s
=
self
.
buffer
.
popleft
()
if
size
+
len
(
s
)
>
22
:
self
.
buffer
.
appendleft
(
s
[
22
-
size
:])
yield
s
[:
22
-
size
]
else
:
yield
l
+=
len
(
s
)
return
b
""
.
join
(
inner
())
This diff is collapsed.
Click to expand it.
ebpfcat/terminals.py
+
20
−
0
View file @
50a88abf
...
@@ -32,3 +32,23 @@ class EK1814(EBPFTerminal):
...
@@ -32,3 +32,23 @@ class EK1814(EBPFTerminal):
ch6
=
PacketDesc
((
1
,
0
),
1
)
ch6
=
PacketDesc
((
1
,
0
),
1
)
ch7
=
PacketDesc
((
1
,
0
),
2
)
ch7
=
PacketDesc
((
1
,
0
),
2
)
ch8
=
PacketDesc
((
1
,
0
),
3
)
ch8
=
PacketDesc
((
1
,
0
),
3
)
class
EL6022
(
EBPFTerminal
):
class
Channel
(
Struct
):
transmit_accept
=
PacketDesc
((
0
,
0
),
0
)
receive_request
=
PacketDesc
((
0
,
0
),
1
)
init_accept
=
PacketDesc
((
0
,
0
),
2
)
status
=
PacketDesc
((
0
,
0
),
"
H
"
)
in_string
=
PacketDesc
((
0
,
1
),
"
23p
"
)
wkc1
=
PacketDesc
((
0
,
24
),
"
H
"
)
transmit_request
=
PacketDesc
((
1
,
0
),
0
)
receive_accept
=
PacketDesc
((
1
,
0
),
1
)
init_request
=
PacketDesc
((
1
,
0
),
2
)
control
=
PacketDesc
((
1
,
0
),
"
H
"
)
out_string
=
PacketDesc
((
1
,
1
),
"
23p
"
)
wkc2
=
PacketDesc
((
0
,
24
),
"
H
"
)
channel1
=
Channel
(
0
,
0
)
channel2
=
Channel
(
24
,
24
)
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