Exemplo n.º 1
0
def main():
    # Parse arguments
    parser = argparse.ArgumentParser(description='Manages GNSS modem')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        dest='verbose',
                        help='be verbose, show debug output')

    parser.add_argument('action',
                        choices=['start', 'stop'],
                        help="selects action to perform")

    args = parser.parse_args()
    logger.setLevel(logging.INFO)
    if args.verbose:
        logger.setLevel(logging.DEBUG)

    # Create UBX library
    ubx = GnssUBlox('/dev/gnss0')
    ubx.setup()

    # Register the frame types we use
    ubx.register_frame(UbxMonVer)
    ubx.register_frame(UbxUpdSos)
    ubx.register_frame(UbxCfgNavx5)

    # Execute desired commands
    # show_version(ubx)

    if args.action == 'start':
        # Set UTC time so that recovery from 2D-DR also works
        enable_mga_ack(ubx)

        set_time(ubx)

        # Check if a backup was present
        res = check_sos_state(ubx)
        if res == 2:
            remove_backup(ubx)

    elif args.action == 'stop':
        stop_receiver(ubx)
        create_backup(ubx)
    else:
        logger.warning(f'unknown command {args.action}')

    ubx.cleanup()
Exemplo n.º 2
0
def main():
    # Parse arguments
    parser = argparse.ArgumentParser(
        description='Detects current UART bitrate of GNSS modem')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        dest='verbose',
                        help='be verbose, show debug output')

    parser.add_argument('current',
                        help="current bitrate of receiver",
                        type=int)

    parser.add_argument('new', help="new bitrate to set", type=int)

    args = parser.parse_args()
    logger.setLevel(logging.INFO)
    if args.verbose:
        logger.setLevel(logging.DEBUG)

    # Create UBX library
    # Note: tty and baudrate must match current receiver configuration
    ubx = GnssUBlox(TTY, args.current)
    ubx.setup()

    # Get current tty port settings from modem
    poll_cfg = UbxCfgPrtPoll()
    poll_cfg.f.PortId = UbxCfgPrtPoll.PORTID_Uart

    port_cfg = ubx.poll(poll_cfg)
    if port_cfg:
        print(f'Current port config is\n{port_cfg}')
        print(f'Current modem bitrate is {port_cfg.f.baudRate} bps')

        assert args.current == port_cfg.f.baudRate

        # Set new bitrate
        print(f'Changing bitrate to {args.new}')
        port_cfg.f.baudRate = args.new

        # Note: usually we would use ubx.set() to send the request and wait for an ack
        # Unfortunately the modem changes the bitrate immediately so the ACK is not
        # received.
        ubx.fire_and_forget(port_cfg)

        print('Done, please use detect_bitrate.py to check')
    else:
        print("No answer from modem. Is current bitrate correct?")
        # No answer...
        pass

    ubx.cleanup()
Exemplo n.º 3
0
def main():
    # Parse arguments
    parser = argparse.ArgumentParser(
        description='Detects current UART bitrate of GNSS modem')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        dest='verbose',
                        help='be verbose, show debug output')

    parser.add_argument('method',
                        choices=['passive', 'active'],
                        help="selects the scan method")

    args = parser.parse_args()
    logger.setLevel(logging.INFO)
    if args.verbose:
        logger.setLevel(logging.DEBUG)

    ubx = GnssUBlox(TTY)
    ubx.setup()

    if 'active' in args.method:
        baud = detect_bitrate_active(ubx)
    else:
        baud = detect_bitrate_passive(ubx)

    print(f'baudrate is {baud} bps')

    ubx.cleanup()
Exemplo n.º 4
0
# from ubxlib.ubx_cfg_nav5 import UbxCfgNav5, UbxCfgNav5Poll
from ubxlib.ubx_cfg_nmea import UbxCfgNmea, UbxCfgNmeaPoll
# from ubxlib.ubx_cfg_rst import UbxCfgRstAction
from ubxlib.ubx_cfg_tp5 import UbxCfgTp5, UbxCfgTp5Poll
from ubxlib.ubx_esf_alg import UbxEsfAlg, UbxEsfAlgPoll
from ubxlib.ubx_esf_status import UbxEsfStatus, UbxEsfStatusPoll
from ubxlib.ubx_mon_ver import UbxMonVer, UbxMonVerPoll
from ubxlib.ubx_nav_status import UbxNavStatus, UbxNavStatusPoll

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.DEBUG)

# Create UBX library
ubx = GnssUBlox('/dev/gnss0')
# ubx = GnssUBlox()

ready = ubx.setup()
assert ready

# Register the frame types we use
protocols = [UbxMonVer, UbxEsfStatus, UbxEsfAlg, UbxNavStatus]
for p in protocols:
    ubx.register_frame(p)

# ubx.register_frame(UbxMonVer)
# ubx.register_frame(UbxEsfStatus)
ubx.register_frame(UbxCfgTp5)
ubx.register_frame(UbxCfgNmea)
# ubx.register_frame(UbxCfgNav5)
Exemplo n.º 5
0
# from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox     # TTY direct backend
from ubxlib.ubx_cfg_gnss import UbxCfgGnssPoll, UbxCfgGnss


FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)


# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBlox('/dev/gnss0', 115200)
ubx.setup()

# Register the frame types we use
ubx.register_frame(UbxCfgGnss)

# Query modem for current protocol settings
poll_nmea_cfg = UbxCfgGnssPoll()
res = ubx.poll(poll_nmea_cfg)
if res:
    print(res)

    # Change the GNSS systems
    # res.gps_glonass()
    res.gps_galileo_beidou()
Exemplo n.º 6
0
python3 -m examples.show_version_tty
"""
import logging

from ubxlib.server_tty import GnssUBlox  # TTY direct backend
from ubxlib.ubx_mon_ver import UbxMonVerPoll

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
# logger.setLevel(logging.DEBUG)

# Create UBX library
# Note: tty and baudrate must match current receiver configuration
ubx = GnssUBlox('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Poll version from modem
poll_version = UbxMonVerPoll()
res = ubx.poll(poll_version)
if res:
    # Simple print of received answer frame
    print(f'Received answer from modem\n{res}')

    # Can also access fields of UbxMonVer via .f member
    print()
    print(f'SW Version: {res.f.swVersion}')
Exemplo n.º 7
0
import logging

from ubxlib.server_tty import GnssUBlox     # TTY direct backend
from ubxlib.ubx_mon_ver import UbxMonVerPoll, UbxMonVer


FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
# logger.setLevel(logging.DEBUG)


# Create UBX library
# Note: tty and baudrate must match current receiver configuration
ubx = GnssUBlox('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxMonVer)

# Poll version from modem
poll_version = UbxMonVerPoll()
res = ubx.poll(poll_version)
if res:
    # Simple print of received answer frame
    print(f'Received answer from modem\n{res}')
Exemplo n.º 8
0
"""
import logging

# from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox  # TTY direct backend
from ubxlib.ubx_cfg_gnss import UbxCfgGnssPoll, UbxCfgGnss

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBlox('/dev/gnss0', 115200)
ubx.setup()

# Query modem for current protocol settings
poll_nmea_cfg = UbxCfgGnssPoll()
res = ubx.poll(poll_nmea_cfg)
if res:
    print(res)

    # Change the GNSS systems
    # res.gps_glonass()
    res.gps_galileo_beidou()

    ####
    # By adding the following line an incorrect system constellation is selected
    # The receiver will reject this request with a NAK
Exemplo n.º 9
0
from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox as GnssUBloxTTY    # TTY direct backend
from ubxlib.ubx_esf_status import UbxEsfStatusPoll


FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)


# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Get state and print in full once
res = ubx.poll(UbxEsfStatusPoll())
print(f'Received answer from modem\n{res}')

print('Checking state, press CTRL+C to abort')

try:
    esf_status_request = UbxEsfStatusPoll()
    while True:
        res = ubx.poll(esf_status_request)
Exemplo n.º 10
0
"""
import logging

from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox as GnssUBloxTTY  # TTY direct backend
from ubxlib.ubx_cfg_prt import UbxCfgPrtPoll, UbxCfgPrtUart

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
# logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxCfgPrtUart)

# Poll version from modem
poll_cfg = UbxCfgPrtPoll()
poll_cfg.f.PortId = UbxCfgPrtPoll.PORTID_Uart
res = ubx.poll(poll_cfg)
if res:
    # Simple print of received answer frame
    print(f'Received answer from modem\n{res}')
Exemplo n.º 11
0
from ubxlib.ubx_cfg_nav5 import UbxCfgNav5Poll
from ubxlib.ubx_cfg_nmea import UbxCfgNmeaPoll
# from ubxlib.ubx_cfg_rst import UbxCfgRstAction
from ubxlib.ubx_cfg_tp5 import UbxCfgTp5Poll
from ubxlib.ubx_esf_alg import UbxEsfAlgPoll
from ubxlib.ubx_esf_status import UbxEsfStatusPoll
from ubxlib.ubx_mon_ver import UbxMonVerPoll
from ubxlib.ubx_nav_status import UbxNavStatusPoll

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.DEBUG)

# Create UBX library
ubx = GnssUBlox('/dev/gnss0')
# ubx = GnssUBlox()

ready = ubx.setup()
assert ready


m = UbxMonVerPoll()
res = ubx.poll(m)
print(res)

m = UbxCfgNmeaPoll()
res = ubx.poll(m)
print(res)

"""
Exemplo n.º 12
0
import logging
import time

from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox as GnssUBloxTTY  # TTY direct backend
from ubxlib.ubx_esf_status import UbxEsfStatusPoll, UbxEsfStatus

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxEsfStatus)

# Get state and print in full once
res = ubx.poll(UbxEsfStatusPoll())
print(f'Received answer from modem\n{res}')

print('Checking state, press CTRL+C to abort')

try:
Exemplo n.º 13
0
"""
import logging

from ubxlib.server import GnssUBlox
from ubxlib.server_tty import GnssUBlox as GnssUBloxTTY  # TTY direct backend
from ubxlib.ubx_cfg_nmea import UbxCfgNmeaPoll, UbxCfgNmea

FORMAT = '%(asctime)-15s %(levelname)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('ubxlib')
logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)

# Create UBX library
# ubx = GnssUBlox()
ubx = GnssUBloxTTY('/dev/gnss0', 115200)
res = ubx.setup()
if not res:
    print('Cannot setup library')
    quit(10)

# Register the frame types we use
ubx.register_frame(UbxCfgNmea)

# Query modem for current protocol settings
poll_nmea_cfg = UbxCfgNmeaPoll()
res = ubx.poll(poll_nmea_cfg)
if res:
    proto_ver = res.f.nmeaVersion // 16  # Protocol is encoded in high/low nibble
    proto_rev = res.f.nmeaVersion % 16  # e.g. 0x40 = 4.0
    print(f'current NMEA protocol version is {proto_ver}.{proto_rev}')