-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from Stefal/mosaic-x5
Septentrio Mosaic-x5 support
- Loading branch information
Showing
18 changed files
with
545 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Config file for using a Septentrio Mosaic X5 with RTKBase | ||
setSBFOutput, Stream1, USB1 | ||
setSBFOutput, Stream1, , , sec1 | ||
setSBFOutput, Stream1, , MeasEpoch+MeasExtra+EndOfMeas | ||
setSBFOutput, Stream1, , +GPSRawCA+GPSRawL2C+GPSRawL5 | ||
setSBFOutput, Stream1, , +GLORawCA | ||
setSBFOutput, Stream1, , +GALRawFNAV+GALRawINAV+GALRawCNAV | ||
setSBFOutput, Stream1, , +BDSRaw+BDSRawB1C+BDSRawB2a+BDSRawB2b | ||
setSBFOutput, Stream1, , +QZSRawL1CA+QZSRawL2C+QZSRawL5 | ||
setSBFOutput, Stream1, , +NAVICRaw | ||
setSBFOutput, Stream1, , +GEORawL1+GEORawL5 | ||
setSignalTracking, GPSL1CA+GPSL1PY+GPSL2PY+GPSL2C+GPSL5+GLOL1CA+GLOL2P+GLOL2CA+GLOL3+GALL1BC+GALE6BC+GALE5a+GALE5b+GALE5+GEOL1+GEOL5+BDSB1I+BDSB2I+BDSB3I+BDSB1C+BDSB2a+BDSB2b+QZSL1CA+QZSL2C+QZSL5+QZSL1CB+NAVICL5 | ||
setSBFOutput, Stream1, , +PVTGeodetic+ChannelStatus+ReceiverStatus+SatVisibility+ReceiverTime | ||
setPVTMode, Static | ||
setPPSParameters, sec1, Low2High, , UTC | ||
setUSBInternetAccess, on | ||
#END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import argparse | ||
from septentrio.septentrio_cmd import * | ||
from enum import Enum | ||
from operator import methodcaller | ||
|
||
class CmdMapping(Enum): | ||
"""Mapping human command to septentrio methods""" | ||
|
||
#get_model = methodcaller('get_receiver_model') | ||
get_model = 'get_receiver_model' | ||
get_firmware = 'get_receiver_firmware' | ||
get_ip = 'get_receiver_ip' | ||
reset = 'set_factory_default' | ||
test = 'test' | ||
send_config_file = 'send_config_file' | ||
|
||
def arg_parse(): | ||
""" Parse the command line you use to launch the script """ | ||
|
||
parser= argparse.ArgumentParser(prog='Septentrio tool', description="A tool to send comment to a Septentrio GNSS receiver") | ||
parser.add_argument("-p", "--port", help="Port to connect to", type=str) | ||
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("--version", action="version", version="%(prog)s 0.1") | ||
args = parser.parse_args() | ||
#print(args) | ||
return args | ||
|
||
if __name__ == '__main__': | ||
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) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#! /usr/bin/env python3 | ||
from . serial_comm import SerialComm | ||
from enum import Enum | ||
from logging import getLogger | ||
import xml.etree.ElementTree as ET | ||
import time | ||
#Code inspired by https://github.com/jonamat/sim-modem | ||
|
||
class SeptGnss: | ||
"""Class for sending command to Septentrio Gnss receivers""" | ||
|
||
def __init__( | ||
self, | ||
address, | ||
baudrate=115200, | ||
timeout=2, | ||
cmd_delay=0.1, | ||
debug=False, | ||
): | ||
self.comm = SerialComm( | ||
address=address, | ||
baudrate=baudrate, | ||
timeout=timeout, | ||
cmd_delay=cmd_delay, | ||
connection_descriptor='USB2>', | ||
) | ||
self.debug = debug | ||
self.connect() | ||
|
||
def connect(self) -> None: | ||
self.comm.send('exeEchoMessage, COM1, "A:HELLO", none') | ||
read = self.comm.read_raw(1000) | ||
try: | ||
check_hello = b"A:HELLO" in read | ||
res_descriptor = read.decode().split()[-1] | ||
check_descriptor = 'COM' in res_descriptor or 'USB' in res_descriptor or 'IP1' in res_descriptor | ||
if check_hello and check_descriptor: | ||
self.comm.connection_descriptor = read.decode().split()[-1] | ||
else: | ||
raise Exception | ||
if self.debug: | ||
print("GNSS receiver connected, debug mode enabled") | ||
print("Connection descriptor: {}".format(self.comm.connection_descriptor)) | ||
except Exception: | ||
print("GNSS receiver did not respond correctly") | ||
if self.debug: | ||
print(read) | ||
self.close() | ||
|
||
def close(self) -> None: | ||
self.comm.close() | ||
|
||
def __enter__(self): | ||
return self | ||
|
||
def __exit__(self, exception_type, exception_value, exception_traceback): | ||
self.close() | ||
|
||
# --------------------------------- Common methods --------------------------------- # | ||
|
||
def get_receiver_model(self) -> str: | ||
read = self.send_read_until('lstInternalFile', 'Identification') | ||
model = self.__parse_rcv_info(read, 'hwplatform', 'product') | ||
return model | ||
|
||
def get_receiver_firmware(self) -> str: | ||
read = self.send_read_until('lstInternalFile', 'Identification') | ||
firmware = self.__parse_rcv_info(read, 'firmware', 'version') | ||
return firmware | ||
|
||
def get_receiver_ip(self) -> str: | ||
read = self.send_read_until('lstInternalFile', 'IPParameters') | ||
ip_addr = self.__parse_rcv_info(read, 'inet', 'addr') | ||
return ip_addr | ||
|
||
def __parse_rcv_info(self, pseudo_xml, element_tag, info) -> str: | ||
''' | ||
This methode will try to parse the xml file received | ||
when we send the lstInternalFile command | ||
''' | ||
pseudo_xml = [line for line in pseudo_xml[2:-1] if not (line.startswith('$') or line == '---->')] | ||
e = ET.ElementTree(ET.fromstring(''.join(pseudo_xml))) | ||
res_info = None | ||
for element in e.iter(): | ||
#print(element.tag, element.attrib, element.text) | ||
res_info = element.get(info) if element_tag in element.tag and element.get(info) else res_info | ||
return res_info | ||
|
||
def get_port_applications(self, port) -> str: | ||
read = self.send_read_until('getRegisteredApplications', port) | ||
return read[-2].split(',')[-1].replace('"','').strip() | ||
|
||
def set_port_applications(self, port, applications_name) -> None: | ||
read = self.send_read_until('exeRegisteredApplications', port, applications_name) | ||
|
||
def set_factory_default(self) -> None: | ||
''' | ||
Reset receiver settings to factory defaults and restart it | ||
Connection will be closed | ||
''' | ||
if self.debug: | ||
print("Sending: 'exeResetReceiver, Soft, Config'") | ||
self.comm.send('exeResetReceiver, Soft, Config') | ||
read = self.comm.read_until('STOP>') | ||
if self.debug: | ||
print("Receiving: {}".format(read)) | ||
if read[-1] != 'STOP>' or read[0].startswith('$R?'): | ||
raise Exception("Command failed!\nSent: 'exeResetReceiver, Soft, Config'\nReceived: {}".format(read)) | ||
self.close() | ||
print("Connection closed") | ||
|
||
def send_config_file(self, file, perm=False) -> None: | ||
''' | ||
Send user commands from a txt file, line by line | ||
Set perm to True if you want to set these settings permanent | ||
''' | ||
with open(file, 'r') as f: | ||
for line in f: | ||
if line.strip() != '' and not line.startswith('#'): | ||
cmd,*args = line.split(',') | ||
#print(cmd, args) | ||
self.send_read_until(cmd + ', ' + ', '.join(args)) | ||
if perm: | ||
self.set_config_permanent() | ||
|
||
def set_config_permanent(self) -> None: | ||
''' | ||
Save current settings to boot config | ||
''' | ||
read = self.send_read_until('exeCopyConfigFile', 'Current', 'Boot') | ||
|
||
# ----------------------------------- OTHERS --------------------------------- # | ||
|
||
def send_read_lines(self, cmd, *args) -> list: | ||
if self.debug: | ||
print("Sending: {}{}{}".format(cmd, ', ' if args else '', ', '.join(args))) | ||
self.comm.send("{}{}{}".format(cmd, ', ' if args else '', ', '.join(args))) | ||
read = self.comm.read_lines() | ||
if self.debug: | ||
print("Receiving: {}".format(read)) | ||
if read[-1] != self.comm.connection_descriptor or read[0].startswith('$R?'): | ||
raise Exception("Command failed!\nSent: {}\nReceived: {}".format((cmd + ', ' + ', '.join(args)), read)) | ||
return read | ||
|
||
def send_read_until(self, cmd, *args) -> list: | ||
if self.debug: | ||
print("Sending: {}{}{}".format(cmd, ', ' if args else '', ', '.join(args))) | ||
self.comm.send("{}{}{}".format(cmd, ', ' if args else '', ', '.join(args))) | ||
read = self.comm.read_until() | ||
if self.debug: | ||
print("Receiving: {}".format(read)) | ||
if read[-1] != self.comm.connection_descriptor or read[0].startswith('$R?'): | ||
raise Exception("Command failed!\nSent: {}\nReceived: {}".format((cmd + ', ' + ', '.join(args)), read)) | ||
return read |
Oops, something went wrong.