Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tcp client service #377

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Septentrio Mosaic-X5 detection and configuration
- Reverse proxy server with Rtkbase authentication, for Mosaic-X5 web interface
- Added description below form input. #381
- rtcm tcp client service added (useful for the Rtkdirect service). #376
### Changed
### Deprecated
### Removed
Expand Down
Binary file modified images/internal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/internal_synoptic.odp
Binary file not shown.
20 changes: 19 additions & 1 deletion run_cast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ out_rtcm_svr="tcpsvr://:${rtcm_svr_port}#rtcm3 -msg ${rtcm_svr_msg} -p ${positio
#add receiver options if it exists
[[ ! -z "${rtcm_receiver_options}" ]] && out_rtcm_svr=""${out_rtcm_svr}" -opt "${rtcm_receiver_options}""

out_rtcm_client="tcpcli://${rtcm_client_addr}:${rtcm_client_port}#rtcm3 -msg ${rtcm_client_msg} -p ${position}"
#add receiver options if it exists
[[ ! -z "${rtcm_client_receiver_options}" ]] && out_rtcm_client=""${out_rtcm_client}" -opt "${rtcm_receiver_client_options}""

out_rtcm_udp_svr="udpsvr://:${rtcm_udp_svr_port}#rtcm3 -msg ${rtcm_udp_svr_msg} -p ${position}"
#add receiver options if it exists
[[ ! -z "${rtcm_udp_svr_receiver_options}" ]] && out_rtcm_udp_svr=""${out_rtcm_udp_svr}" -opt "${rtcm_udp_svr_receiver_options}""

out_rtcm_serial="serial://${out_com_port}:${out_com_port_settings}#rtcm3 -msg ${rtcm_serial_msg} -p ${position}"
#add receiver options if it exists
[[ ! -z "${rtcm_serial_receiver_options}" ]] && out_rtcm_serial=""${out_rtcm_serial}" -opt "${rtcm_serial_receiver_options}""
Expand Down Expand Up @@ -71,7 +79,17 @@ mkdir -p ${logdir}
#echo ${cast} -in ${!1} -out $out_rtcm_svr
${cast} -in ${!1} -out ${out_rtcm_svr} -i "${receiver_info}" -a "${antenna_info}" -t ${level} -fl ${logdir}/str2str_rtcm_svr.log &
;;


out_rtcm_client)
#echo ${cast} -in ${!1} -out $out_rtcm_client
${cast} -in ${!1} -out ${out_rtcm_client} -i "${receiver_info}" -a "${antenna_info}" -t ${level} -fl ${logdir}/str2str_rtcm_client.log &
;;

out_rtcm_udp_svr)
#echo ${cast} -in ${!1} -out $out_rtcm_udp_svr
${cast} -in ${!1} -out ${out_rtcm_udp_svr} -i "${receiver_info}" -a "${antenna_info}" -t ${level} -fl ${logdir}/str2str_rtcm_udp_svr.log &
;;

out_rtcm_serial)
#echo ${cast} -in ${!1} -out $out_rtcm_serial
${cast} -in ${!1} -out ${out_rtcm_serial} -i "${receiver_info}" -a "${antenna_info}" -t ${level} -fl ${logdir}/str2str_rtcm_serial.log &
Expand Down
36 changes: 36 additions & 0 deletions settings.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,42 @@ rtcm_svr_msg='1004,1005(10),1006,1008(10),1012,1019,1020,1033(10),1042,1045,1046
#Receiver dependent options
rtcm_receiver_options=''

[rtcm_client]

# RTCM client options

#port for rtcm client
rtcm_client_addr=''
rtcm_client_port='80'
#messages for rtcm client use
rtcm_client_msg='1004,1005(10),1006,1008(10),1012,1019,1020,1033(10),1042,1045,1046,1077,1087,1097,1107,1127,1230'
#Receiver dependent options
rtcm_client_receiver_options=''

[rtcm_udp_svr]

#RTCM UDP Server options

#port for rtcm UDP use
rtcm_udp_svr_port=''
#messages for rtcm udp use
rtcm_udp_svr_msg='1004,1005(10),1006,1008(10),1012,1019,1020,1033(10),1042,1045,1046,1077,1087,1097,1107,1127,1230'
#Receiver dependent options
rtcm_udp_svr_receiver_options=''

[rtcm_udp_client]

#RTCM UDP Client options

#address for rtcm UDP
rtcm_udp_client_addr=''
#port for rtcm UDP use
rtcm_udp_client_port=''
#messages for rtcm udp use
rtcm_udp_client_msg='1004,1005(10),1006,1008(10),1012,1019,1020,1033(10),1042,1045,1046,1077,1087,1097,1107,1127,1230'
#Receiver dependent options
rtcm_udp_client_receiver_options=''

[rtcm_serial]

# Serial output RTCM options
Expand Down
3 changes: 3 additions & 0 deletions tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ configure_gnss(){
sudo -u "${RTKBASE_USER}" sed -i s/^ntrip_b_receiver_options=.*/ntrip_b_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^local_ntripc_receiver_options=.*/local_ntripc_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^rtcm_receiver_options=.*/rtcm_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^rtcm_client_receiver_options=.*/rtcm_client_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^rtcm_udp_svr_receiver_options=.*/rtcm_udp_svr_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^rtcm_udp_client_receiver_options=.*/rtcm_udp_client_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^rtcm_serial_receiver_options=.*/rtcm_serial_receiver_options=\'-TADJ=1\'/ "${rtkbase_path}"/settings.conf && \
#remove SBAS Rtcm message (1107) as it is disabled in the F9P configuration.
sudo -u "${RTKBASE_USER}" sed -i -r '/^rtcm_/s/1107(\([0-9]+\))?,//' "${rtkbase_path}"/settings.conf && \
Expand Down
3 changes: 3 additions & 0 deletions tools/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ for service_name in str2str_tcp.service \
str2str_ntrip_B.service \
str2str_local_ntrip_caster \
str2str_rtcm_svr.service \
str2str_rtcm_client.service \
str2str_rtcm_udp_svr.service \
str2str_rtcm_udp_client.service \
str2str_rtcm_serial.service \
str2str_file.service \
rtkbase_web \
Expand Down
21 changes: 21 additions & 0 deletions unit/disabled/str2str_rtcm_udp_client.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=RTKBase RTCM UDP Client
#After=network-online.target
#Wants=network-online.target
Requires=str2str_tcp.service

[Service]
Type=forking
User={user}
ExecStart={script_path}/run_cast.sh in_tcp out_rtcm_udp_client
Restart=on-failure
RestartSec=30
#Limiting log to 1 msg per minute
LogRateLimitIntervalSec=1 minute
LogRateLimitBurst=1
ProtectHome=read-only
ProtectSystem=strict
ReadWritePaths={script_path}

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions unit/disabled/str2str_rtcm_udp_svr.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=RTKBase RTCM UDP Server
#After=network-online.target
#Wants=network-online.target
Requires=str2str_tcp.service

[Service]
Type=forking
User={user}
ExecStart={script_path}/run_cast.sh in_tcp out_rtcm_udp_svr
Restart=on-failure
RestartSec=30
#Limiting log to 1 msg per minute
LogRateLimitIntervalSec=1 minute
LogRateLimitBurst=1
ProtectHome=read-only
ProtectSystem=strict
ReadWritePaths={script_path}

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions unit/str2str_rtcm_client.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=RTKBase RTCM Client
#After=network-online.target
#Wants=network-online.target
Requires=str2str_tcp.service

[Service]
Type=forking
User={user}
ExecStart={script_path}/run_cast.sh in_tcp out_rtcm_client
Restart=on-failure
RestartSec=30
#Limiting log to 1 msg per minute
LogRateLimitIntervalSec=1 minute
LogRateLimitBurst=1
ProtectHome=read-only
ProtectSystem=strict
ReadWritePaths={script_path}

[Install]
WantedBy=multi-user.target
34 changes: 34 additions & 0 deletions web_app/RTKBaseConfigManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,37 @@ def get_rtcm_svr_settings(self):
ordered_rtcm_svr.append({key : self.config.get('rtcm_svr', key).strip("'")})
return ordered_rtcm_svr

def get_rtcm_client_settings(self):
"""
Get a subset of the settings from the file section in an ordered object
and remove the single quotes.
"""
ordered_rtcm_client = [{"source_section" : "rtcm_client"}]
for key in ("rtcm_client_addr", "rtcm_client_port", "rtcm_client_msg", "rtcm_client_receiver_options"):
ordered_rtcm_client.append({key : self.config.get('rtcm_client', key).strip("'")})
print("ORDERED RTCM CLIENT", ordered_rtcm_client)
return ordered_rtcm_client

def get_rtcm_udp_svr_settings(self):
"""
Get a subset of the settings from the file section in an ordered object
and remove the single quotes.
"""
ordered_rtcm_udp_svr = [{"source_section" : "rtcm_udp_svr"}]
for key in ("rtcm_udp_svr_port", "rtcm_udp_svr_msg", "rtcm_udp_svr_receiver_options"):
ordered_rtcm_udp_svr.append({key : self.config.get('rtcm_udp_svr', key).strip("'")})
return ordered_rtcm_udp_svr

def get_rtcm_udp_client_settings(self):
"""
Get a subset of the settings from the file section in an ordered object
and remove the single quotes.
"""
ordered_rtcm_udp_client = [{"source_section" : "rtcm_udp_client"}]
for key in ("rtcm_udp_client_addr", "rtcm_udp_client_port", "rtcm_udp_client_msg", "rtcm_udp_client_receiver_options"):
ordered_rtcm_udp_client.append({key : self.config.get('rtcm_udp_client', key).strip("'")})
return ordered_rtcm_udp_client

def get_rtcm_serial_settings(self):
"""
Get a subset of the settings from the file section in an ordered object
Expand All @@ -187,6 +218,9 @@ def get_ordered_settings(self):
ordered_settings['local_ntripc'] = self.get_local_ntripc_settings()
ordered_settings['file'] = self.get_file_settings()
ordered_settings['rtcm_svr'] = self.get_rtcm_svr_settings()
ordered_settings['rtcm_client'] = self.get_rtcm_client_settings()
ordered_settings['rtcm_udp_svr'] = self.get_rtcm_udp_svr_settings()
ordered_settings['rtcm_udp_client'] = self.get_rtcm_udp_client_settings()
ordered_settings['rtcm_serial'] = self.get_rtcm_serial_settings()
return ordered_settings

Expand Down
23 changes: 19 additions & 4 deletions web_app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
{"service_unit" : "str2str_ntrip_B.service", "name" : "ntrip_B"},
{"service_unit" : "str2str_local_ntrip_caster.service", "name" : "local_ntrip_caster"},
{"service_unit" : "str2str_rtcm_svr.service", "name" : "rtcm_svr"},
{"service_unit" : "str2str_rtcm_client.service", "name" : "rtcm_client"},
{"service_unit" : "str2str_rtcm_udp_svr.service", "name" : "rtcm_udp_svr"},
{'service_unit' : 'str2str_rtcm_udp_client.service', "name" : "rtcm_udp_client"},
{'service_unit' : 'str2str_rtcm_serial.service', "name" : "rtcm_serial"},
{"service_unit" : "str2str_file.service", "name" : "file"},
{'service_unit' : 'rtkbase_archive.timer', "name" : "archive_timer"},
Expand Down Expand Up @@ -405,17 +408,23 @@ def settings_page():
ntrip_A_settings = rtkbaseconfig.get_ntrip_A_settings()
ntrip_B_settings = rtkbaseconfig.get_ntrip_B_settings()
local_ntripc_settings = rtkbaseconfig.get_local_ntripc_settings()
file_settings = rtkbaseconfig.get_file_settings()
rtcm_svr_settings = rtkbaseconfig.get_rtcm_svr_settings()
rtcm_client_settings = rtkbaseconfig.get_rtcm_client_settings()
rtcm_udp_svr_settings = rtkbaseconfig.get_rtcm_udp_svr_settings()
rtcm_udp_client_settings = rtkbaseconfig.get_rtcm_udp_client_settings()
rtcm_serial_settings = rtkbaseconfig.get_rtcm_serial_settings()
file_settings = rtkbaseconfig.get_file_settings()

return render_template("settings.html", main_settings = main_settings,
ntrip_A_settings = ntrip_A_settings,
ntrip_B_settings = ntrip_B_settings,
local_ntripc_settings = local_ntripc_settings,
file_settings = file_settings,
rtcm_svr_settings = rtcm_svr_settings,
rtcm_client_settings = rtcm_client_settings,
rtcm_udp_svr_settings = rtcm_udp_svr_settings,
rtcm_udp_client_settings = rtcm_udp_client_settings,
rtcm_serial_settings = rtcm_serial_settings,
file_settings = file_settings,
os_infos = distro.info(),)

@app.route('/logs')
Expand Down Expand Up @@ -897,7 +906,7 @@ def update_settings(json_msg):

#Restart service if needed
if source_section == "main":
restartServices(("main", "ntrip_A", "ntrip_B", "local_ntrip_caster", "rtcm_svr", "file", "rtcm_serial"))
restartServices(("main", "ntrip_A", "ntrip_B", "local_ntrip_caster", "rtcm_svr", "rtcm_client", "rtcm_udp_svr", "rtcm_udp_client", "file", "rtcm_serial"))
elif source_section == "ntrip_A":
restartServices(("ntrip_A",))
elif source_section == "ntrip_B":
Expand All @@ -906,6 +915,12 @@ def update_settings(json_msg):
restartServices(("local_ntrip_caster",))
elif source_section == "rtcm_svr":
restartServices(("rtcm_svr",))
elif source_section == "rtcm_client":
restartServices(("rtcm_client",))
elif source_section == "rtcm_udp_svr":
restartServices(("rtcm_udp_svr",))
elif source_section == "rtcm_udp_client":
restartServices(("rtcm_udp_client",))
elif source_section == "rtcm_serial":
restartServices(("rtcm_serial",))
elif source_section == "local_storage":
Expand All @@ -927,7 +942,7 @@ def update_settings(json_msg):
#check if we run RTKBase for the first time after an update
#and restart some services to let them send the new release number.
if rtkbaseconfig.get("general", "updated", fallback="False").lower() == "true":
restartServices(["ntrip_A", "ntrip_B", "local_ntrip_caster", "rtcm_svr", "rtcm_serial"])
restartServices(["ntrip_A", "ntrip_B", "local_ntrip_caster", "rtcm_svr", "rtcm_client", "rtcm_udp_svr", "rtcm_udp_client", "rtcm_serial"])
rtkbaseconfig.remove_option("general", "updated")
rtkbaseconfig.write_file()
#Start a "manager" thread
Expand Down
Loading
Loading