Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
593af951
Commit
593af951
authored
1 year ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add Athena WFI DE communication template
parent
22c23ff8
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
Ccs/scripts/wfi_de_communication.py
+46
-0
46 additions, 0 deletions
Ccs/scripts/wfi_de_communication.py
with
46 additions
and
0 deletions
Ccs/scripts/wfi_de_communication.py
0 → 100644
+
46
−
0
View file @
593af951
"""
Examples for Athena WFI DE communications
"""
import
communication
as
com
import
packet_config_ATHENA_DE
as
de
# set up socket and connect
decon
=
com
.
Connector
(
''
,
12345
,
msgdecoding
=
'
hex
'
)
decon
.
connect
()
# example commands
decon
.
send
(
b
'
\x20\xDE\xAD
'
)
# test echo interface (0x20)
decon
.
send
(
de
.
HkCmdRecv
(
0x1000
))
# get PCM MODE register
decon
.
send
(
de
.
CmdSend
(
0x3C00
,
1
))
# write sequencer register
decon
.
send
(
de
.
CmdSend
(
0x3C00
,
1
),
rx
=
False
)
# write sequencer register, but don't fetch cmd response from socket
decon
.
send
(
de
.
SciCmd
(
100
))
# set science data output rate
# dump cmd log (decon.log)
logfile
=
'
/path/to/de_cmd.log
'
decon
.
dump_log
(
logfile
)
# automatically log to file
decon
.
setup_storage
(
logfile
)
# run rx thread on socket, received data is put in recvd_data_buf queue
decon
.
start_receiver
()
decon
.
receiver
.
recvd_data_buf
# custom TM processing function; must take bytestring as arg *data*, and timestamp kwarg *ts*
def
msg_to_hex_string
(
data
,
ts
=
''
):
try
:
return
'
{}: {}
\n
'
.
format
(
ts
,
data
.
hex
(
'
'
,
1
))
except
Exception
as
err
:
print
(
err
)
return
'
# ERROR #
\n
'
# optionally, add custom TM processing
# this logs the received data hex-formatted in outfile
decon
.
start_receiver
(
procfunc
=
msg_to_hex_string
,
outfile
=
'
/path/to/de_rx.log
'
,
ofmode
=
'
w
'
)
# processed data is also collected in
decon
.
receiver
.
proc_data
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