Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SRC OBDH TMTC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Robin Mueller
SRC OBDH TMTC
Commits
d3a516f1
Commit
d3a516f1
authored
4 years ago
by
Robin Mueller
Browse files
Options
Downloads
Patches
Plain Diff
changes applied manually
parent
0593851a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/tmtcc_com_config.py
+36
-2
36 additions, 2 deletions
config/tmtcc_com_config.py
tmtc_core
+1
-1
1 addition, 1 deletion
tmtc_core
with
37 additions
and
3 deletions
config/tmtcc_com_config.py
+
36
−
2
View file @
d3a516f1
"""
"""
Set-up function. Initiates the communication interface.
Set-up function. Initiates the communication interface.
"""
"""
import
json
import
os
import
sys
import
sys
from
typing
import
Union
from
typing
import
Union
import
serial
import
serial.tools.list_ports
from
tmtc_core.comIF.obsw_com_interface
import
CommunicationInterface
from
tmtc_core.comIF.obsw_com_interface
import
CommunicationInterface
from
tmtc_core.comIF.obsw_dummy_com_if
import
DummyComIF
from
tmtc_core.comIF.obsw_dummy_com_if
import
DummyComIF
from
tmtc_core.comIF.obsw_ethernet_com_if
import
EthernetComIF
from
tmtc_core.comIF.obsw_ethernet_com_if
import
EthernetComIF
...
@@ -13,7 +18,7 @@ from tmtc_core.comIF.obsw_qemu_com_if import QEMUComIF
...
@@ -13,7 +18,7 @@ from tmtc_core.comIF.obsw_qemu_com_if import QEMUComIF
from
tmtc_core.utility.obsw_logger
import
get_logger
from
tmtc_core.utility.obsw_logger
import
get_logger
from
tmtc_core.utility.obsw_tmtc_printer
import
TmTcPrinter
from
tmtc_core.utility.obsw_tmtc_printer
import
TmTcPrinter
import
config.
tmtcc
_config
as
g
import
config.
obsw
_config
as
g
LOGGER
=
get_logger
()
LOGGER
=
get_logger
()
...
@@ -33,8 +38,22 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
...
@@ -33,8 +38,22 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
elif
g
.
G_COM_IF
==
g
.
ComInterfaces
.
Serial
:
elif
g
.
G_COM_IF
==
g
.
ComInterfaces
.
Serial
:
serial_baudrate
=
g
.
G_SERIAL_BAUDRATE
serial_baudrate
=
g
.
G_SERIAL_BAUDRATE
serial_timeout
=
g
.
G_SERIAL_TIMEOUT
serial_timeout
=
g
.
G_SERIAL_TIMEOUT
com_port
=
""
if
g
.
G_COM_PORT
is
None
:
if
os
.
path
.
isfile
(
"
config/tmtcc_config.json
"
):
with
open
(
"
config/tmtcc_config.json
"
,
"
r
"
)
as
write
:
load_data
=
json
.
load
(
write
)
com_port
=
load_data
[
"
COM_PORT
"
]
else
:
com_port
=
prompt_com_port
()
save_to_json
=
input
(
"
Do you want to store serial port to configuration? (y/n)
"
)
if
save_to_json
.
lower
()
==
'
y
'
:
with
open
(
"
config/tmtcc_config.json
"
,
"
w
"
)
as
write
:
json
.
dump
(
dict
(
COM_PORT
=
com_port
),
write
,
indent
=
4
)
communication_interface
=
SerialComIF
(
communication_interface
=
SerialComIF
(
tmtc_printer
=
tmtc_printer
,
com_port
=
g
.
G_COM_PORT
,
baud_rate
=
serial_baudrate
,
tmtc_printer
=
tmtc_printer
,
com_port
=
com_port
,
baud_rate
=
serial_baudrate
,
serial_timeout
=
serial_timeout
,
serial_timeout
=
serial_timeout
,
ser_com_type
=
SerialCommunicationType
.
DLE_ENCODING
)
ser_com_type
=
SerialCommunicationType
.
DLE_ENCODING
)
communication_interface
.
set_dle_settings
(
communication_interface
.
set_dle_settings
(
...
@@ -49,9 +68,24 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
...
@@ -49,9 +68,24 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio
g
.
G_SERIAL_DLE_MAX_QUEUE_LEN
,
g
.
G_SERIAL_DLE_MAX_FRAME_SIZE
,
serial_timeout
)
g
.
G_SERIAL_DLE_MAX_QUEUE_LEN
,
g
.
G_SERIAL_DLE_MAX_FRAME_SIZE
,
serial_timeout
)
else
:
else
:
communication_interface
=
DummyComIF
(
tmtc_printer
=
tmtc_printer
)
communication_interface
=
DummyComIF
(
tmtc_printer
=
tmtc_printer
)
if
not
communication_interface
.
valid
:
LOGGER
.
warning
(
"
Invalid communication interface!
"
)
sys
.
exit
()
communication_interface
.
initialize
()
communication_interface
.
initialize
()
return
communication_interface
return
communication_interface
except
(
IOError
,
OSError
):
except
(
IOError
,
OSError
):
LOGGER
.
error
(
"
Error setting up communication interface
"
)
LOGGER
.
error
(
"
Error setting up communication interface
"
)
LOGGER
.
exception
(
"
Error
"
)
LOGGER
.
exception
(
"
Error
"
)
sys
.
exit
()
sys
.
exit
()
def
prompt_com_port
()
->
str
:
com_port
=
input
(
"
Serial Commuinication specified without COM port. Please enter COM Port
"
"
(enter h to display list of COM ports):
"
)
if
com_port
==
'
h
'
:
ports
=
serial
.
tools
.
list_ports
.
comports
()
for
port
,
desc
,
hwid
in
sorted
(
ports
):
print
(
"
{}: {} [{}]
"
.
format
(
port
,
desc
,
hwid
))
com_port
=
prompt_com_port
()
return
com_port
This diff is collapsed.
Click to expand it.
tmtc_core
@
d550621a
Compare
2407697e
...
d550621a
Subproject commit
2407697ea25ec1479df5f1308183f7c9f0d01a90
Subproject commit
d550621a799b9836f8bbb1c0760ef3a20cac99af
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