Skip to content

Commit

Permalink
add retry to the mosaic sept_tool and during the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefal committed Jun 13, 2024
1 parent 77defa9 commit a8f39e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
12 changes: 5 additions & 7 deletions tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -528,20 +528,18 @@ configure_gnss(){
sudo -u "${RTKBASE_USER}" sed -i -r '/^rtcm_/s/1107(\([0-9]+\))?,//' "${rtkbase_path}"/settings.conf && \
return $?

elif [[ $(python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command get_model) =~ 'mosaic-X5' ]]
elif [[ $(python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command get_model --retry 5) =~ 'mosaic-X5' ]]
then
#get mosaic-X5 firmware release
firmware="$(python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command get_firmware)" || firmware='?'
firmware="$(python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command get_firmware --retry 5)" || firmware='?'
echo 'Mosaic-X5 Firmware: ' "${firmware}"
sudo -u "${RTKBASE_USER}" sed -i s/^receiver_firmware=.*/receiver_firmware=\'${firmware}\'/ "${rtkbase_path}"/settings.conf
#configure the mosaic-X5 for RTKBase
echo 'Resetting the mosaic-X5 settings....'
python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command reset
sleep_time=60
echo 'Waiting '$sleep_time's for mosaic-X5 reboot'
sleep $sleep_time
python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command reset --retry 5
sleep_time=20 ; echo 'Waiting '$sleep_time's for mosaic-X5 reboot' ; sleep $sleep_time
echo 'Sending settings....'
python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command send_config_file "${rtkbase_path}"/receiver_cfg/Septentrio_Mosaic-X5.cfg --store
python3 "${rtkbase_path}"/tools/sept_tool.py --port /dev/ttyGNSS_CTRL --baudrate ${com_port_settings%%:*} --command send_config_file "${rtkbase_path}"/receiver_cfg/Septentrio_Mosaic-X5.cfg --store --retry 5
systemctl enable --now rtkbase_gnss_web_proxy.service #won't work during installation but, needed after a detect&configure from the gui.
sudo -u "${RTKBASE_USER}" sed -i s/^com_port_settings=.*/com_port_settings=\'115200:8:n:1\'/ "${rtkbase_path}"/settings.conf && \
sudo -u "${RTKBASE_USER}" sed -i s/^receiver=.*/receiver=\'Septentrio_Mosaic-X5\'/ "${rtkbase_path}"/settings.conf && \
Expand Down
24 changes: 17 additions & 7 deletions tools/sept_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def arg_parse():
parser.add_argument("-b", "--baudrate", help="port baudrate", default=115200, type=int)
parser.add_argument("-c", "--command", nargs='+', help="Command to send to the gnss receiver", type=str)
parser.add_argument("-s", "--store", action='store_true', help="Store settings as permanent", default=False)
parser.add_argument("-r", "--retry", help="set a number of retry if the command fails", default=0, type=int)
parser.add_argument("--version", action="version", version="%(prog)s 0.1")
args = parser.parse_args()
#print(args)
Expand All @@ -32,10 +33,19 @@ def arg_parse():
args = arg_parse()
#print(args)
command = args.command[0]
with SeptGnss(args.port, baudrate=args.baudrate, timeout=30, debug=False) as gnss:
res = methodcaller(CmdMapping[command].value, *args.command[1:])(gnss)
if type(res) is str:
print(res)
if args.store:
gnss.set_config_permanent()
#methodcaller(args.command[0])(gnss)
retries = 0
retry_delay = 10
while retries <= args.retry:
try:
with SeptGnss(args.port, baudrate=args.baudrate, timeout=30, debug=False) as gnss:
res = methodcaller(CmdMapping[command].value, *args.command[1:])(gnss)
if type(res) is str:
print(res)
if args.store:
gnss.set_config_permanent()
#methodcaller(args.command[0])(gnss)
break
except:
retries += 1
print("Retrying in {}s".format(retry_delay))
time.sleep(retry_delay)

0 comments on commit a8f39e1

Please sign in to comment.