├── .gitignore ├── .travis.yml ├── README.md ├── docs ├── Makefile ├── requirements.txt ├── scripts │ └── generate_messages.py └── source │ ├── _static │ └── .gitignore │ ├── _templates │ └── .gitignore │ ├── conf.py │ ├── images │ └── schematic.svg │ └── index.rst ├── requirements.txt ├── scripts └── ubxstats ├── setup.py ├── test ├── __init__.py ├── test_checksum.py ├── test_descriptions.py ├── test_message_class.py ├── test_message_id.py ├── test_rawmessage.py └── test_utils.py └── ubx ├── __init__.py ├── checksum.py ├── descriptions ├── __init__.py ├── ack_ack.py ├── ack_nack.py ├── aid_alm.py ├── aid_aop.py ├── aid_eph.py ├── aid_hui.py ├── aid_ini.py ├── cfg_ant.py ├── cfg_batch.py ├── cfg_cfg.py ├── cfg_dat.py ├── cfg_dgnss.py ├── cfg_dosc.py ├── cfg_dynseed.py ├── cfg_esrc.py ├── cfg_fixseed.py ├── cfg_geofence.py ├── cfg_gnss.py ├── cfg_hnr.py ├── cfg_inf.py ├── cfg_itfm.py ├── cfg_logfilter.py ├── cfg_msg.py ├── cfg_nav5.py ├── cfg_navx5.py ├── cfg_nmea.py ├── cfg_odo.py ├── cfg_pm2.py ├── cfg_pms.py ├── cfg_prt.py ├── cfg_pwr.py ├── cfg_rate.py ├── cfg_rinv.py ├── cfg_rst.py ├── cfg_rxm.py ├── cfg_sbas.py ├── cfg_smgr.py ├── cfg_tmode2.py ├── cfg_tmode3.py ├── cfg_tp5.py ├── cfg_txslot.py ├── cfg_usb.py ├── esf_ins.py ├── esf_raw.py ├── esf_status.py ├── hnr_pvt.py ├── inf_debug.py ├── inf_error.py ├── inf_notice.py ├── inf_test.py ├── inf_warning.py ├── log_batch.py ├── log_create.py ├── log_erase.py ├── log_findtime.py ├── log_info.py ├── log_retrieve.py ├── log_retrievebatch.py ├── log_retrievepos.py ├── log_retrieveposextra.py ├── log_retrievestring.py ├── log_string.py ├── mga_ack.py ├── mga_ano.py ├── mga_bds.py ├── mga_dbd.py ├── mga_flash.py ├── mga_gal.py ├── mga_glo.py ├── mga_gps.py ├── mga_ini.py ├── mga_qzss.py ├── mon_batch.py ├── mon_gnss.py ├── mon_hw.py ├── mon_hw2.py ├── mon_io.py ├── mon_msgpp.py ├── mon_patch.py ├── mon_rxbuf.py ├── mon_rxr.py ├── mon_smgr.py ├── mon_txbuf.py ├── mon_ver.py ├── nav_aopstatus.py ├── nav_att.py ├── nav_clock.py ├── nav_dgps.py ├── nav_dop.py ├── nav_eoe.py ├── nav_geofence.py ├── nav_hpposecef.py ├── nav_hpposllh.py ├── nav_odo.py ├── nav_orb.py ├── nav_posecef.py ├── nav_posllh.py ├── nav_pvt.py ├── nav_relposned.py ├── nav_resetodo.py ├── nav_sat.py ├── nav_sbas.py ├── nav_sol.py ├── nav_status.py ├── nav_svin.py ├── nav_svinfo.py ├── nav_timedbs.py ├── nav_timegal.py ├── nav_timeglo.py ├── nav_timegps.py ├── nav_timels.py ├── nav_timeutc.py ├── nav_velecef.py ├── nav_velned.py ├── rxm_imes.py ├── rxm_measx.py ├── rxm_pmreq.py ├── rxm_rawx.py ├── rxm_rlm.py ├── rxm_rtcm.py ├── rxm_sfrbx.py ├── rxm_svsi.py ├── sec_sign.py ├── sec_uniqid.py ├── tim_dosc.py ├── tim_fchg.py ├── tim_hoc.py ├── tim_smeas.py ├── tim_svin.py ├── tim_tm2.py ├── tim_tos.py ├── tim_tp.py ├── tim_vcocal.py └── tim_vrfy.py ├── message.py ├── message_class.py ├── message_id.py ├── parser.py ├── payload.py ├── printing ├── __init__.py ├── base.py └── rst.py ├── rawmessage.py ├── reader.py ├── statistics.py ├── syncchars.py └── utils.py /.gitignore: -------------------------------------------------------------------------------- 1 | docs/source/generated/message_descriptions 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | os: 4 | - "linux" 5 | # - "osx" 6 | 7 | python: 8 | - "2.7" 9 | - "3.5" 10 | - "3.6" 11 | 12 | cache: pip 13 | 14 | before_install: 15 | 16 | install: 17 | - pip install travis-sphinx 18 | - pip install codecov 19 | - pip install -r requirements.txt 20 | - git clone https://github.com/bastikr/ubx-testdata.git 21 | - export PYTHONPATH=$PYTHONPATH:`pwd` 22 | - cd docs 23 | - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then 24 | python scripts/generate_messages.py; 25 | fi 26 | - cd .. 27 | 28 | script: 29 | # - python -m unittest discover test 30 | - coverage run --source . setup.py test 31 | - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then 32 | travis-sphinx build; 33 | fi 34 | 35 | after_success: 36 | - travis-sphinx deploy 37 | - codecov 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-UBX 2 | 3 | [![Latest Docs][docs-latest-img]][docs-latest-url] 4 | [![Travis build status][travis-img]][travis-url] 5 | [![Test coverage status on codecov][codecov-img]][codecov-url] 6 | 7 | A python library implementing the binary u-blox UBX protocol. 8 | 9 | 10 | 11 | [travis-url]: https://travis-ci.org/bastikr/python-ubx 12 | [travis-img]: https://travis-ci.org/bastikr/python-ubx.svg?branch=master 13 | [docs-latest-img]:https://img.shields.io/badge/docs-latest-blue.svg 14 | [docs-latest-url]:https://bastikr.github.io/python-ubx/ 15 | [codecov-url]: https://codecov.io/gh/bastikr/python-ubx 16 | [codecov-img]: https://codecov.io/gh/bastikr/python-ubx/branch/master/graph/badge.svg 17 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = Python-UBX 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | SCRIPTSDIR = scripts 11 | 12 | # Put it first so that "make" without argument is like "make help". 13 | help: 14 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 15 | 16 | .PHONY: help Makefile 17 | 18 | # Catch-all target: route all unknown targets to Sphinx using the new 19 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 20 | %: Makefile 21 | python $(SCRIPTSDIR)/generate_messages.py 22 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 23 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx -------------------------------------------------------------------------------- /docs/scripts/generate_messages.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | 4 | import ubx 5 | 6 | # Make sure target directory exists 7 | sourcedir = "source/" 8 | if not os.path.exists(sourcedir): 9 | raise ValueError("sourcedir not found at {}".format( 10 | os.path.abspath(sourcedir))) 11 | 12 | targetdir = os.path.join(sourcedir, "generated/message_descriptions") 13 | if os.path.exists(targetdir): 14 | shutil.rmtree(targetdir) 15 | os.makedirs(targetdir) 16 | 17 | description_links = {} 18 | 19 | for description in ubx.descriptions.default: 20 | name = description.name 21 | output = [] 22 | output.append(".. _message-description-{}:\n".format(name)) 23 | output.append(name) 24 | output.append("-"*len(name) + "\n") 25 | if not description.message_class.name in description_links: 26 | description_links[description.message_class.name] = [] 27 | description_link = ":ref:`message-description-{}`".format(name) 28 | description_links[description.message_class.name].append((name, description_link)) 29 | 30 | output.append(ubx.printing.RST().print_dispatch(description)) 31 | output.append("\n") 32 | 33 | targetpath = os.path.join(targetdir, name + ".rst") 34 | with open(targetpath, "w") as f: 35 | f.write("\n".join(output)) 36 | # break 37 | 38 | name = "message_descriptions.rst" 39 | targetpath = os.path.join(targetdir, name) 40 | with open(targetpath, "w") as f: 41 | f.write(".. _message_descriptions:\n\n") 42 | f.write("---------------------\n") 43 | f.write("Message Descriptions\n") 44 | f.write("---------------------\n\n") 45 | f.write(".. toctree::\n") 46 | f.write(" :maxdepth: 1\n") 47 | f.write(" :hidden:\n\n") 48 | 49 | toctree_entries = [] 50 | content = [] 51 | for key in sorted(description_links.keys()): 52 | content.append("\n" + key + "\n" + "-"*len(key)) 53 | for name, link in sorted(description_links[key]): 54 | toctree_entries.append(" " + name) 55 | content.append("* " + link) 56 | 57 | f.write("\n".join(toctree_entries)) 58 | f.write("\n\n") 59 | f.write("\n\n".join(content)) 60 | -------------------------------------------------------------------------------- /docs/source/_static/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastikr/python-ubx/eb12056091e1551ffc43396ef80540b3a59bac8c/docs/source/_static/.gitignore -------------------------------------------------------------------------------- /docs/source/_templates/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastikr/python-ubx/eb12056091e1551ffc43396ef80540b3a59bac8c/docs/source/_templates/.gitignore -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/stable/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | # import os 16 | # import sys 17 | # sys.path.insert(0, os.path.abspath('.')) 18 | 19 | 20 | # -- Project information ----------------------------------------------------- 21 | 22 | project = 'Python-UBX' 23 | copyright = '2018, Sebastian Krämer' 24 | author = 'Sebastian Krämer' 25 | 26 | # The short X.Y version 27 | version = '' 28 | # The full version, including alpha/beta/rc tags 29 | release = '' 30 | 31 | 32 | # -- General configuration --------------------------------------------------- 33 | 34 | # If your documentation needs a minimal Sphinx version, state it here. 35 | # 36 | # needs_sphinx = '1.0' 37 | 38 | # Add any Sphinx extension module names here, as strings. They can be 39 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 40 | # ones. 41 | extensions = [ 42 | 'sphinx.ext.autodoc', 43 | 'sphinx.ext.doctest', 44 | 'sphinx.ext.coverage', 45 | 'sphinx.ext.mathjax', 46 | 'sphinx.ext.viewcode', 47 | 'sphinx.ext.githubpages', 48 | ] 49 | 50 | # Add any paths that contain templates here, relative to this directory. 51 | templates_path = ['_templates'] 52 | 53 | # The suffix(es) of source filenames. 54 | # You can specify multiple suffix as a list of string: 55 | # 56 | # source_suffix = ['.rst', '.md'] 57 | source_suffix = '.rst' 58 | 59 | # The master toctree document. 60 | master_doc = 'index' 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = None 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | # This pattern also affects html_static_path and html_extra_path . 72 | exclude_patterns = [] 73 | 74 | # The name of the Pygments (syntax highlighting) style to use. 75 | pygments_style = 'sphinx' 76 | 77 | 78 | # -- Options for HTML output ------------------------------------------------- 79 | 80 | # The theme to use for HTML and HTML Help pages. See the documentation for 81 | # a list of builtin themes. 82 | # 83 | html_theme = 'alabaster' 84 | 85 | # Theme options are theme-specific and customize the look and feel of a theme 86 | # further. For a list of options available for each theme, see the 87 | # documentation. 88 | # 89 | # html_theme_options = {} 90 | 91 | # Add any paths that contain custom static files (such as style sheets) here, 92 | # relative to this directory. They are copied after the builtin static files, 93 | # so a file named "default.css" will overwrite the builtin "default.css". 94 | html_static_path = ['_static'] 95 | 96 | # Custom sidebar templates, must be a dictionary that maps document names 97 | # to template names. 98 | # 99 | # The default sidebars (for documents that don't match any pattern) are 100 | # defined by theme itself. Builtin themes are using these templates by 101 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 102 | # 'searchbox.html']``. 103 | # 104 | # html_sidebars = {} 105 | 106 | 107 | # -- Options for HTMLHelp output --------------------------------------------- 108 | 109 | # Output file base name for HTML help builder. 110 | htmlhelp_basename = 'Python-UBXdoc' 111 | 112 | 113 | # -- Options for LaTeX output ------------------------------------------------ 114 | 115 | latex_elements = { 116 | # The paper size ('letterpaper' or 'a4paper'). 117 | # 118 | # 'papersize': 'letterpaper', 119 | 120 | # The font size ('10pt', '11pt' or '12pt'). 121 | # 122 | # 'pointsize': '10pt', 123 | 124 | # Additional stuff for the LaTeX preamble. 125 | # 126 | # 'preamble': '', 127 | 128 | # Latex figure (float) alignment 129 | # 130 | # 'figure_align': 'htbp', 131 | } 132 | 133 | # Grouping the document tree into LaTeX files. List of tuples 134 | # (source start file, target name, title, 135 | # author, documentclass [howto, manual, or own class]). 136 | latex_documents = [ 137 | (master_doc, 'Python-UBX.tex', 'Python-UBX Documentation', 138 | 'Sebastian Krämer', 'manual'), 139 | ] 140 | 141 | 142 | # -- Options for manual page output ------------------------------------------ 143 | 144 | # One entry per manual page. List of tuples 145 | # (source start file, name, description, authors, manual section). 146 | man_pages = [ 147 | (master_doc, 'python-ubx', 'Python-UBX Documentation', 148 | [author], 1) 149 | ] 150 | 151 | 152 | # -- Options for Texinfo output ---------------------------------------------- 153 | 154 | # Grouping the document tree into Texinfo files. List of tuples 155 | # (source start file, target name, title, author, 156 | # dir menu entry, description, category) 157 | texinfo_documents = [ 158 | (master_doc, 'Python-UBX', 'Python-UBX Documentation', 159 | author, 'Python-UBX', 'One line description of project.', 160 | 'Miscellaneous'), 161 | ] 162 | 163 | 164 | # -- Extension configuration ------------------------------------------------- -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Python-UBX 2 | ========== 3 | 4 | A python library implementing the binary u-blox UBX protocol. 5 | 6 | .. image:: images/schematic.svg 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | :caption: Contents: 11 | 12 | generated/message_descriptions/message_descriptions 13 | 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | bitarray -------------------------------------------------------------------------------- /scripts/ubxstats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import sys 5 | import os 6 | import time 7 | 8 | import ubx 9 | 10 | 11 | argparser = argparse.ArgumentParser(description="Analyze a UBX stream") 12 | argparser.add_argument("input", help="file or socket") 13 | argparser.add_argument("--progress", help="show progress", action="store_true") 14 | argparser.add_argument("--fast", help="disable counting bytes read", action="store_true") 15 | 16 | args = argparser.parse_args() 17 | 18 | if ":" in args.input: 19 | raise NotImplementedError() 20 | else: 21 | if not os.path.exists(args.input): 22 | raise ValueError("Given argument is neither a path nor a socket.") 23 | f = open(args.input, "rb") 24 | read_raw = f.read 25 | 26 | 27 | stats = ubx.Statistics() 28 | 29 | 30 | class ReadWrapper: 31 | def __init__(self, read_raw): 32 | self._read_raw = read_raw 33 | self.t = -float("inf") 34 | 35 | def _read(self, n): 36 | stats.add_bytesread_try(n) 37 | result = self._read_raw(n) 38 | stats.add_bytesread_success(len(result)) 39 | return result 40 | 41 | if args.progress: 42 | def read(self, n): 43 | result = self._read(n) 44 | t = time.time() 45 | if t - self.t > 0.05: 46 | sys.stdout.write("Bytes read: {}\r".format(stats.bytes_read_success)) 47 | sys.stdout.flush() 48 | self.t = t 49 | return result 50 | else: 51 | def read(self, n): 52 | return self._read(n) 53 | 54 | if args.fast: 55 | reader = ubx.Reader(read_raw) 56 | else: 57 | readwrapper = ReadWrapper(read_raw) 58 | reader = ubx.Reader(readwrapper.read) 59 | 60 | parser = ubx.default_parser 61 | 62 | 63 | def run(): 64 | while True: 65 | try: 66 | rawmessage = reader.read_rawmessage() 67 | except ubx.ChecksumError: 68 | stats.add_checksumerror() 69 | continue 70 | except EOFError: 71 | break 72 | else: 73 | stats.add_rawmessage(rawmessage) 74 | 75 | try: 76 | message = parser.parse(rawmessage) 77 | except KeyError: 78 | stats.add_unknownmessage(rawmessage) 79 | continue 80 | except ubx.PayloadError: 81 | stats.add_payloaderror( 82 | ubx.Message(parser.descriptions[rawmessage.key], None)) 83 | continue 84 | else: 85 | stats.add_message(message) 86 | 87 | 88 | try: 89 | run() 90 | except KeyboardInterrupt: 91 | pass 92 | 93 | if args.progress: 94 | sys.stdout.write(" " * 50 + "\r") 95 | sys.stdout.flush() 96 | 97 | print(stats) 98 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from setuptools import setup 5 | 6 | 7 | setup(name='python-ubx', 8 | version='0.1', 9 | description='A python library implementing the binary u-blox UBX protocol.', 10 | author='Sebastian Krämer', 11 | author_email='basti.kr@gmail.com', 12 | url='https://github.com/bastikr/python-ubx', 13 | packages=['ubx', 'ubx.descriptions'], 14 | scripts=['scripts/ubxstats'], 15 | install_requires=["bitarray"] 16 | ) 17 | -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastikr/python-ubx/eb12056091e1551ffc43396ef80540b3a59bac8c/test/__init__.py -------------------------------------------------------------------------------- /test/test_checksum.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import ubx 4 | 5 | 6 | class TestChecksum(unittest.TestCase): 7 | def test_creation(self): 8 | c = ubx.Checksum(1, 2) 9 | self.assertEqual(c.a, 1) 10 | self.assertEqual(c.b, 2) 11 | 12 | c = ubx.Checksum(257, 258) 13 | self.assertEqual(c.a, 1) 14 | self.assertEqual(c.b, 2) 15 | 16 | a = 256**20 + 7 17 | b = 256**15 + 3 18 | c = ubx.Checksum(a, b) 19 | self.assertEqual(c.a, 7) 20 | self.assertEqual(c.b, 3) 21 | 22 | with self.assertRaises(TypeError): 23 | ubx.Checksum(b"\x31", 1) 24 | with self.assertRaises(TypeError): 25 | ubx.Checksum(1, b"\x31") 26 | with self.assertRaises(TypeError): 27 | ubx.Checksum(b"\x31", b"\x02") 28 | 29 | def test_frombytestring(self): 30 | c = ubx.Checksum.from_bytestrings(b"\xfe", b"\x0f", b"\x05") 31 | a = (254 + 15 + 5) % 256 32 | b = (254*3 + 15*2 + 5) % 256 33 | self.assertEqual(c.a, a) 34 | self.assertEqual(c.b, b) 35 | 36 | def test_update(self): 37 | c = ubx.Checksum(254, 254) 38 | c.update(b"\x0f") 39 | c.update(b"\x05") 40 | a = (254 + 15 + 5) % 256 41 | b = (254*3 + 15*2 + 5) % 256 42 | self.assertEqual(c.a, a) 43 | self.assertEqual(c.b, b) 44 | 45 | def test_equality(self): 46 | c0 = ubx.Checksum(2, 5) 47 | c1 = ubx.Checksum(2, 6) 48 | c2 = ubx.Checksum(1, 5) 49 | 50 | self.assertTrue(c0==c0) 51 | self.assertFalse(c0!=c0) 52 | self.assertTrue(c1==c1) 53 | self.assertFalse(c1!=c1) 54 | self.assertTrue(c2==c2) 55 | self.assertFalse(c2!=c2) 56 | 57 | self.assertFalse(c0==c1) 58 | self.assertFalse(c0==c2) 59 | self.assertFalse(c1==c2) 60 | 61 | def test_bytes(self): 62 | c = ubx.Checksum.from_bytestrings(b"\xfe", b"\x0f", b"\x05") 63 | self.assertEqual(c.bytes(), b"\x12\x1d") 64 | 65 | def test_check_equal(self): 66 | with self.assertRaises(ubx.ChecksumError): 67 | ubx.Checksum(0, 1).check_equal(ubx.Checksum(0, 0)) 68 | 69 | 70 | if __name__ == '__main__': 71 | unittest.main() 72 | -------------------------------------------------------------------------------- /test/test_descriptions.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import os 4 | import codecs 5 | 6 | import ubx 7 | from ubx.descriptions import mon_hw 8 | from ubx.descriptions import rxm_rawx 9 | 10 | 11 | class TestPrinting(unittest.TestCase): 12 | def test_AtomicVariable(self): 13 | self.assertEqual(str(ubx.U1), "U1") 14 | self.assertEqual(str(ubx.U2), "U2") 15 | self.assertEqual(str(ubx.U4), "U4") 16 | self.assertEqual(str(ubx.U8), "U8") 17 | 18 | self.assertEqual(str(ubx.I1), "I1") 19 | self.assertEqual(str(ubx.I2), "I2") 20 | self.assertEqual(str(ubx.I4), "I4") 21 | self.assertEqual(str(ubx.I8), "I8") 22 | 23 | self.assertEqual(str(ubx.X1), "Bitfield(1)") 24 | self.assertEqual(str(ubx.X2), "Bitfield(2)") 25 | self.assertEqual(str(ubx.X4), "Bitfield(4)") 26 | self.assertEqual(str(ubx.X8), "Bitfield(8)") 27 | 28 | self.assertEqual(str(ubx.R4), "R4") 29 | self.assertEqual(str(ubx.R8), "R8") 30 | 31 | def test_List(self): 32 | self.assertEqual(str(ubx.List(["a", "b"])), "[\n a,\n b\n]") 33 | self.assertEqual(str(ubx.List(["a", ubx.List("b")])), 34 | "[\n" 35 | " a,\n" 36 | " [\n" 37 | " b\n" 38 | " ]\n" 39 | "]") 40 | 41 | def test_Fields(self): 42 | field1 = ("a", "va") 43 | field2 = ("b", "vb") 44 | field3 = ("c", "vc") 45 | fields1 = ubx.Fields(field1, field2) 46 | self.assertEqual(str(fields1), 47 | "Fields(length=?) {\n" 48 | " a: va,\n" 49 | " b: vb\n" 50 | "}") 51 | fields2 = ubx.Fields(("fields", fields1), field3) 52 | self.assertEqual(str(fields2), 53 | "Fields(length=?) {\n" 54 | " fields:\n" 55 | " Fields(length=?) {\n" 56 | " a: va,\n" 57 | " b: vb\n" 58 | " },\n" 59 | " c: vc\n" 60 | "}") 61 | 62 | def test_Loop(self): 63 | field1 = ("a", "va") 64 | field2 = ("b", "vb") 65 | field3 = ("c", "vc") 66 | self.assertEqual(str(ubx.KeyLoop("k", "va")), 67 | "Loop(key=\"k\"):\n" 68 | "| va") 69 | self.assertEqual(str(ubx.KeyLoop("k", ubx.Fields(field1, field2, field3))), 70 | "Loop(key=\"k\"):\n" 71 | "| Fields(length=?) {\n" 72 | "| a: va,\n" 73 | "| b: vb,\n" 74 | "| c: vc\n" 75 | "| }") 76 | 77 | 78 | 79 | class TestDescriptions(unittest.TestCase): 80 | pass 81 | 82 | 83 | def make_test_read_serialize(directory, name): 84 | _, message_class, message_id, length, checksum = name[:-4].split("-") 85 | classbyte = ubx.utils.hexstring2byte(message_class) 86 | try: 87 | message_class = ubx.message_class.get_by_byte(classbyte) 88 | except ValueError: 89 | message_class = ubx.message_class.MessageClass("?", classbyte) 90 | message_id = codecs.decode(message_id.encode("utf-8"), "hex") 91 | checksum = codecs.decode(checksum.encode("utf-8"), "hex") 92 | def test(self): 93 | with open(os.path.join(directory, name), "rb") as f: 94 | reader = ubx.Reader(f.read) 95 | msg = reader.read_rawmessage() 96 | self.assertEqual(message_class, msg.message_class) 97 | self.assertEqual(message_id, msg.message_id) 98 | self.assertEqual(int(length), len(msg)) 99 | self.assertEqual(checksum, msg.checksum().bytes()) 100 | with open(os.path.join(directory, name), "rb") as f: 101 | data = f.read() 102 | self.assertEqual(data, msg.serialize()) 103 | return test 104 | 105 | 106 | testdir = "ubx-testdata/data" 107 | names = os.listdir(testdir) 108 | for name in names: 109 | if not name.endswith("ubx"): 110 | continue 111 | f = make_test_read_serialize(testdir, name) 112 | setattr(TestDescriptions, 'test_{0}'.format(name[:-4]), f) 113 | 114 | 115 | if __name__ == '__main__': 116 | unittest.main() 117 | -------------------------------------------------------------------------------- /test/test_message_class.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import ubx 4 | 5 | 6 | class TestMessageClass(unittest.TestCase): 7 | def test_creation(self): 8 | m = ubx.MessageClass("TEST", b"\x01") 9 | self.assertEqual(m.name, "TEST") 10 | self.assertEqual(m.byte, b"\x01") 11 | 12 | with self.assertRaises(TypeError): 13 | ubx.MessageClass("TEST", 1) 14 | 15 | def test_equality(self): 16 | m0 = ubx.MessageClass("TEST", b"\x01") 17 | m1 = ubx.MessageClass("TEST", b"\x01") 18 | m2 = ubx.MessageClass("TEST2", b"\x01") 19 | m3 = ubx.MessageClass("TEST", b"\x02") 20 | self.assertTrue(m0==m0) 21 | self.assertTrue(m0==m1) 22 | self.assertTrue(m2==m2) 23 | self.assertTrue(m3==m3) 24 | self.assertFalse(m0!=m0) 25 | self.assertFalse(m0!=m1) 26 | self.assertFalse(m2!=m2) 27 | self.assertFalse(m3!=m3) 28 | 29 | self.assertFalse(m0==m2) 30 | self.assertFalse(m0==m3) 31 | self.assertTrue(m0!=m2) 32 | self.assertTrue(m0!=m3) 33 | 34 | def test_repr(self): 35 | m = ubx.MessageClass("TEST", b"\x01") 36 | self.assertEqual(str(m), "MessageClass(name=TEST, byte=0x01)") 37 | 38 | def test_getbyname(self): 39 | m = ubx.MessageClass("NAV", b"\x01") 40 | self.assertEqual(m, ubx.message_class.get_by_name("NAV")) 41 | with self.assertRaises(ValueError): 42 | ubx.message_class.get_by_name("FOO") 43 | 44 | def test_getbybyte(self): 45 | m = ubx.MessageClass("NAV", b"\x01") 46 | self.assertEqual(m, ubx.message_class.get_by_byte(b"\x01")) 47 | with self.assertRaises(TypeError): 48 | ubx.message_class.get_by_byte(1) 49 | with self.assertRaises(ValueError): 50 | ubx.message_class.get_by_byte(b"\xfe") 51 | 52 | 53 | if __name__ == '__main__': 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /test/test_message_id.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import ubx 4 | 5 | 6 | class TestMessageId(unittest.TestCase): 7 | def test_creation(self): 8 | m = ubx.MessageId("TEST", b"\x01") 9 | self.assertEqual(m.name, "TEST") 10 | self.assertEqual(m.byte, b"\x01") 11 | 12 | with self.assertRaises(TypeError): 13 | ubx.MessageId("TEST", 1) 14 | 15 | def test_equality(self): 16 | m0 = ubx.MessageId("TEST", b"\x01") 17 | m1 = ubx.MessageId("TEST", b"\x01") 18 | m2 = ubx.MessageId("TEST", b"\x01", "SUB") 19 | m3 = ubx.MessageId("TEST", b"\x02") 20 | self.assertTrue(m0==m0) 21 | self.assertTrue(m0==m1) 22 | self.assertTrue(m2==m2) 23 | self.assertTrue(m3==m3) 24 | self.assertFalse(m0!=m0) 25 | self.assertFalse(m0!=m1) 26 | self.assertFalse(m2!=m2) 27 | self.assertFalse(m3!=m3) 28 | 29 | self.assertFalse(m0==m2) 30 | self.assertFalse(m0==m3) 31 | self.assertTrue(m0!=m2) 32 | self.assertTrue(m0!=m3) 33 | 34 | def test_repr(self): 35 | m = ubx.MessageId("TEST", b"\x01") 36 | self.assertEqual(str(m), "MessageId(name=TEST, byte=0x01)") 37 | m = ubx.MessageId("TEST", b"\x01", "SUB") 38 | self.assertEqual(str(m), "MessageId(name=TEST, subname=SUB, byte=0x01)") 39 | 40 | 41 | if __name__ == '__main__': 42 | unittest.main() 43 | -------------------------------------------------------------------------------- /test/test_rawmessage.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import ubx 4 | 5 | 6 | class TestRawMessage(unittest.TestCase): 7 | def test_length(self): 8 | msg_class = b"\x01" 9 | msg_id = b"\x02" 10 | msg = ubx.RawMessage(msg_class, msg_id, b"") 11 | self.assertEqual(len(msg), 0) 12 | msg = ubx.RawMessage(msg_class, msg_id, b"\x02\xf1") 13 | self.assertEqual(len(msg), 2) 14 | 15 | def test_lengthbytes(self): 16 | msg_class = b"\x01" 17 | msg_id = b"\x02" 18 | msg = ubx.RawMessage(msg_class, msg_id, b"") 19 | self.assertEqual(msg.lengthbytes, b"\x00\x00") 20 | msg = ubx.RawMessage(msg_class, msg_id, b"\x02\xf1") 21 | self.assertEqual(msg.lengthbytes, b"\x02\x00") 22 | -------------------------------------------------------------------------------- /test/test_utils.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import ubx 3 | 4 | 5 | class TestByteHexConversion(unittest.TestCase): 6 | def test_conversion(self): 7 | byte = b"\x03" 8 | hexstring = ubx.utils.byte2hexstring(byte) 9 | self.assertEqual(hexstring, "03") 10 | self.assertEqual(byte, ubx.utils.hexstring2byte(hexstring)) 11 | 12 | def test_exceptions_hexstring2bytestring(self): 13 | with self.assertRaises(TypeError): 14 | ubx.utils.byte2hexstring(u"a") 15 | with self.assertRaises(TypeError): 16 | ubx.utils.byte2hexstring(3) 17 | with self.assertRaises(ValueError): 18 | ubx.utils.byte2hexstring(b"\x04\x03") 19 | 20 | def test_exceptions_bytestring2hexstring(self): 21 | with self.assertRaises(ValueError): 22 | ubx.utils.hexstring2byte("4512") 23 | 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /ubx/__init__.py: -------------------------------------------------------------------------------- 1 | from . import syncchars 2 | from . import message_class 3 | from . import message_id 4 | 5 | from .message_class import MessageClass 6 | from .message_id import MessageId 7 | from .checksum import Checksum, ChecksumError 8 | from .rawmessage import RawMessage 9 | from .message import Message 10 | 11 | from .payload import Empty, AtomicVariable,\ 12 | U1, U2, U4, U8,\ 13 | I1, I2, I4, I8,\ 14 | R4, R8,\ 15 | Bitfield, BitfieldEntry,\ 16 | X1, X2, X4, X8,\ 17 | Fields, List, KeyLoop, MatchedLoop, Options,\ 18 | PayloadError 19 | 20 | from . import descriptions 21 | 22 | from .reader import Reader, ReaderException 23 | from .parser import Parser 24 | from .statistics import Statistics 25 | 26 | default_parser = Parser(*descriptions.default) 27 | 28 | from . import printing 29 | -------------------------------------------------------------------------------- /ubx/checksum.py: -------------------------------------------------------------------------------- 1 | """Checksum using the 8-Bit Fletcher Algorithm with modulo 256.""" 2 | 3 | import sys 4 | import struct 5 | 6 | 7 | if sys.version_info > (3,): 8 | long = int 9 | 10 | 11 | class ChecksumError(Exception): 12 | """Checksums don't match.""" 13 | 14 | def __init__(self, checksum0, checksum1): 15 | Exception.__init__(self, "Checksums differ: {} vs {}".format( 16 | hex(checksum0.a) + hex(checksum0.a), 17 | hex(checksum1.a) + hex(checksum1.b))) 18 | self.checksum0 = checksum0 19 | self.checksum1 = checksum1 20 | 21 | 22 | class Checksum: 23 | """Checksum using a 8-Bit Fletcher algorithm with modulo 256.""" 24 | 25 | checksum_struct = struct.Struct(" (3,): 38 | @staticmethod 39 | def from_bytestrings(*args): 40 | """Calculate a combined Checksum for the given bytestrings.""" 41 | a = 0 42 | b = 0 43 | for arg in args: 44 | for x in arg: 45 | a += x 46 | b += a 47 | return Checksum(a & 0xFF, b & 0xFF) 48 | else: 49 | @staticmethod 50 | def from_bytestrings(*args): 51 | """Calculate a combined Checksum for the given bytestrings.""" 52 | a = 0 53 | b = 0 54 | for arg in args: 55 | for byte in arg: 56 | a += ord(byte) 57 | b += a 58 | return Checksum(a & 0xFF, b & 0xFF) 59 | 60 | def update(self, byte): 61 | """Update the Checksum using te given single byte.""" 62 | self.a = (self.a + ord(byte)) & 0xFF 63 | self.b = (self.b + self.a) & 0xFF 64 | 65 | def __repr__(self): 66 | return "Checksum({}, {})".format(self.a, self.b) 67 | 68 | def __eq__(self, other): 69 | return self.a == other.a and self.b == other.b 70 | 71 | def __ne__(self, other): 72 | return not self == other 73 | 74 | def bytes(self): 75 | """Return a byte representation of this Checksum.""" 76 | return self.checksum_struct.pack(self.a)\ 77 | + self.checksum_struct.pack(self.b) 78 | 79 | def check_equal(self, other): 80 | """Raise a ChecksumError if the two Checksums are not equal.""" 81 | if self != other: 82 | raise ChecksumError(self, other) 83 | -------------------------------------------------------------------------------- /ubx/descriptions/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import importlib 3 | 4 | default = [] 5 | 6 | for name in os.listdir(os.path.dirname(__file__)): 7 | if name.startswith("_") or not name.endswith(".py"): 8 | continue 9 | name = name[:-3] 10 | importlib.import_module("." + name, "ubx.descriptions") 11 | default.append(globals()[name].description) 12 | -------------------------------------------------------------------------------- /ubx/descriptions/ack_ack.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("clsID", U1), 9 | ("msgID", U1) 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=ACK, 14 | message_id=MessageId("ACK", b"\x01"), 15 | payload_description=payload_description0 16 | ) 17 | -------------------------------------------------------------------------------- /ubx/descriptions/ack_nack.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("clsID", U1), 9 | ("msgID", U1) 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=ACK, 14 | message_id=MessageId("NACK", b"\x00"), 15 | payload_description=payload_description0 16 | ) 17 | -------------------------------------------------------------------------------- /ubx/descriptions/aid_alm.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("svid", U1) 9 | ) 10 | 11 | payload_description1 = Fields( 12 | ("svid", U4), 13 | ("week", U4), 14 | ) 15 | 16 | payload_description2 = Fields( 17 | ("svid", U4), 18 | ("week", U4), 19 | ("dwrd", 8*U4) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=AID, 24 | message_id=MessageId("ALM", b"\x30"), 25 | payload_description=Options( 26 | Empty, 27 | payload_description0, 28 | payload_description1, 29 | payload_description2, 30 | ) 31 | ) 32 | -------------------------------------------------------------------------------- /ubx/descriptions/aid_aop.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("svid", U1), 9 | ) 10 | 11 | payload_description1 = Fields( 12 | ("gnssId", U1), 13 | ("svId", U1), 14 | ("reserved1", 2*U1), 15 | ("data", 64*U1) 16 | ) 17 | 18 | description = MessageDescription( 19 | message_class=AID, 20 | message_id=MessageId("AOP", b"\x33"), 21 | payload_description=Options( 22 | Empty, 23 | payload_description0, 24 | payload_description1 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/aid_eph.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("svid", U1) 9 | ) 10 | 11 | payload_description1 = Fields( 12 | ("svid", U4), 13 | ("how", U4), 14 | ) 15 | 16 | payload_description2 = Fields( 17 | ("svid", U4), 18 | ("how", U4), 19 | ("sf1d", 8*U4), 20 | ("sf2d", 8*U4), 21 | ("sf3d", 8*U4) 22 | ) 23 | 24 | description = MessageDescription( 25 | message_class=AID, 26 | message_id=MessageId("EPH", b"\x31"), 27 | payload_description=Options( 28 | Empty, 29 | payload_description0, 30 | payload_description1, 31 | payload_description2, 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /ubx/descriptions/aid_hui.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(4, entries=[ 8 | BitfieldEntry("healthValid", 0), 9 | BitfieldEntry("utcValid", 1), 10 | BitfieldEntry("klobValid", 2) 11 | ]) 12 | 13 | payload_description0 = Fields( 14 | ("health", X4), 15 | ("utcA0", R8), 16 | ("utcA1", R8), 17 | ("utcTOW", I4), 18 | ("utcWNT", I2), 19 | ("utcLS", I2), 20 | ("utcWNF", I2), 21 | ("utcDN", I2), 22 | ("utcLSF", I2), 23 | ("utcSpare", I2), 24 | ("klobA0", R4), 25 | ("klobA1", R4), 26 | ("klobA2", R4), 27 | ("klobA3", R4), 28 | ("klobB0", R4), 29 | ("klobB1", R4), 30 | ("klobB2", R4), 31 | ("klobB3", R4), 32 | ("flags", flags) 33 | ) 34 | 35 | description = MessageDescription( 36 | message_class=AID, 37 | message_id=MessageId("HUI", b"\x02"), 38 | payload_description=Options( 39 | Empty, 40 | payload_description0 41 | ) 42 | ) 43 | -------------------------------------------------------------------------------- /ubx/descriptions/aid_ini.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | tmCfg = Bitfield(2, [ 8 | BitfieldEntry("fEdge", 1), 9 | BitfieldEntry("tm1", 4), 10 | BitfieldEntry("f1", 6) 11 | ]) 12 | 13 | flags = Bitfield(4, [ 14 | BitfieldEntry("pos", 0), 15 | BitfieldEntry("time", 1), 16 | BitfieldEntry("clockD", 2), 17 | BitfieldEntry("tp", 3), 18 | BitfieldEntry("clockF", 4), 19 | BitfieldEntry("lla", 5), 20 | BitfieldEntry("altInv", 6), 21 | BitfieldEntry("prevTm", 7), 22 | BitfieldEntry("utc", 10), 23 | ]) 24 | 25 | payload_description0 = Fields( 26 | ("ecefXOrLat", I4), 27 | ("ecefYOrLon", I4), 28 | ("ecefZOrAlt", I4), 29 | ("posAcc", U4), 30 | ("tmCfg", tmCfg), 31 | ("wnoOrDate", U2), 32 | ("towOrTime", U4), 33 | ("towNs", I4), 34 | ("tAccMs", U4), 35 | ("tAccNs", U4), 36 | ("clkDOrFreq", I4), 37 | ("clkDAccOrFreqAcc", U4), 38 | ("flags", flags) 39 | ) 40 | 41 | 42 | description = MessageDescription( 43 | message_class=AID, 44 | message_id=MessageId("INI", b"\x01"), 45 | payload_description=Options( 46 | Empty, 47 | payload_description0, 48 | ) 49 | ) 50 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_ant.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, entries=[ 8 | BitfieldEntry("scvs", 0), 9 | BitfieldEntry("scd", 1), 10 | BitfieldEntry("ocd", 2), 11 | BitfieldEntry("pdwnOnSCD", 3), 12 | BitfieldEntry("recovery", 4), 13 | ]) 14 | 15 | pins = Bitfield(2, entries=[ 16 | BitfieldEntry("pinSwitch", slice(0, 5)), 17 | BitfieldEntry("pinSCD", slice(5, 10)), 18 | BitfieldEntry("pinOCD", slice(10, 15)), 19 | BitfieldEntry("reconfig", 15) 20 | ]) 21 | 22 | payload_description0 = Fields( 23 | ("flags", flags), 24 | ("pins", pins), 25 | ) 26 | 27 | description = MessageDescription( 28 | message_class=CFG, 29 | message_id=MessageId("ANT", b"\x13"), 30 | payload_description=Options( 31 | Empty, 32 | payload_description0, 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_batch.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, entries=[ 8 | BitfieldEntry("enable", 0), 9 | BitfieldEntry("extraPvt", 2), 10 | BitfieldEntry("extraOdo", 3), 11 | BitfieldEntry("pioEnable", 5), 12 | BitfieldEntry("pioActiveLow", 6) 13 | 14 | ]) 15 | 16 | payload_description0 = Fields( 17 | ("version", U1), 18 | ("flags", flags), 19 | ("bufSize", U2), 20 | ("notifThrs", U2), 21 | ("pioId", U1), 22 | ("reserved1", U1) 23 | ) 24 | 25 | description = MessageDescription( 26 | message_class=CFG, 27 | message_id=MessageId("BATCH", b"\x93"), 28 | payload_description=Options( 29 | Empty, 30 | payload_description0, 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_cfg.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | mask = Bitfield(4, entries=[ 8 | BitfieldEntry("ioPort", 0), 9 | BitfieldEntry("msgConf", 1), 10 | BitfieldEntry("infMsg", 2), 11 | BitfieldEntry("navConf", 3), 12 | BitfieldEntry("rxmConf", 4), 13 | BitfieldEntry("senConf", 8), 14 | BitfieldEntry("rinvConf", 9), 15 | BitfieldEntry("antConf", 10), 16 | BitfieldEntry("logConf", 11), 17 | BitfieldEntry("ftsConf", 12) 18 | ]) 19 | 20 | deviceMask = Bitfield(1, entries=[ 21 | BitfieldEntry("devBBR", 0), 22 | BitfieldEntry("devFlash", 1), 23 | BitfieldEntry("devEEPROM", 2), 24 | BitfieldEntry("devSpiFlash", 4) 25 | ]) 26 | 27 | payload_description0 = Fields( 28 | ("clearMask", mask), 29 | ("saveMask", mask), 30 | ("loadMask", mask) 31 | ) 32 | 33 | payload_description1 = Fields( 34 | ("clearMask", mask), 35 | ("saveMask", mask), 36 | ("loadMask", mask), 37 | ("deviceMask", deviceMask) 38 | ) 39 | 40 | description = MessageDescription( 41 | message_class=CFG, 42 | message_id=MessageId("CFG", b"\x09"), 43 | payload_description=Options( 44 | payload_description0, 45 | payload_description1, 46 | ) 47 | ) 48 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_dat.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("majA", R8), 9 | ("flat", R8), 10 | ("dX", R4), 11 | ("dY", R4), 12 | ("dZ", R4), 13 | ("rotX", R4), 14 | ("rotY", R4), 15 | ("rotZ", R4), 16 | ("scale", R4) 17 | ) 18 | 19 | payload_description1 = Fields( 20 | ("datumNum", U2), 21 | ("datumName", Chars(6)), 22 | ("majA", R8), 23 | ("flat", R8), 24 | ("dX", R4), 25 | ("dY", R4), 26 | ("dZ", R4), 27 | ("rotX", R4), 28 | ("rotY", R4), 29 | ("rotZ", R4), 30 | ("scale", R4) 31 | ) 32 | 33 | description = MessageDescription( 34 | message_class=CFG, 35 | message_id=MessageId("DAT", b"\x06"), 36 | payload_description=Options( 37 | Empty, 38 | payload_description0, 39 | payload_description1, 40 | ) 41 | ) 42 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_dgnss.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("dgnssMode", U1), 9 | ("reserved1", 3*U1), 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=CFG, 14 | message_id=MessageId("DGNSS", b"\x70"), 15 | payload_description=Options( 16 | Empty, 17 | payload_description0, 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_dosc.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, [ 8 | BitfieldEntry("isCalibrated", 0), 9 | BitfieldEntry("controlIf", slice(1, 5)) 10 | ]) 11 | 12 | osc = Fields( 13 | ("oscId", U1), 14 | ("reserved2", U1), 15 | ("flags", flags), 16 | ("freq", U4), 17 | ("phaseOffset", I4), 18 | ("withTemp", U4), 19 | ("withAge", U4), 20 | ("timeToTemp", U2), 21 | ("reserved3", 2*U1), 22 | ("gainVco", I4), 23 | ("gainUncertainty", U1), 24 | ("reserved4", 3*U1), 25 | ) 26 | 27 | payload_description0 = Fields( 28 | ("version", U1), 29 | ("numOsc", U1), 30 | ("reserved1", 2*U1), 31 | ("osc", KeyLoop("numOsc", osc)) 32 | ) 33 | 34 | description = MessageDescription( 35 | message_class=CFG, 36 | message_id=MessageId("DOSC", b"\x61"), 37 | payload_description=Options( 38 | Empty, 39 | payload_description0, 40 | ) 41 | ) 42 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_dynseed.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("seedHi", U4), 11 | ("seedLo", U4), 12 | ) 13 | 14 | description = MessageDescription( 15 | message_class=CFG, 16 | message_id=MessageId("DYNSEED", b"\x85"), 17 | payload_description=Options( 18 | payload_description0, 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_esrc.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, [ 8 | BitfieldEntry("polarity", 0), 9 | BitfieldEntry("gnssUtc", 1) 10 | ]) 11 | 12 | sources = Fields( 13 | ("extInt", U1), 14 | ("sourceType", U1), 15 | ("flags", flags), 16 | ("freq", U4), 17 | ("reserved2", 4*U1), 18 | ("withTemp", U4), 19 | ("withAge", U4), 20 | ("timeToTemp", U2), 21 | ("maxDevLifeTime", U2), 22 | ("offset", I4), 23 | ("offsetUncertainty", U4), 24 | ("jitter", U4), 25 | ) 26 | 27 | payload_description0 = Fields( 28 | ("version", U1), 29 | ("numSources", U1), 30 | ("reserved1", 2*U1), 31 | ("sources", KeyLoop("numSources", sources)) 32 | ) 33 | 34 | description = MessageDescription( 35 | message_class=CFG, 36 | message_id=MessageId("ESRC", b"\x60"), 37 | payload_description=Options( 38 | Empty, 39 | payload_description0, 40 | ) 41 | ) 42 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_fixseed.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | ids = Fields( 8 | ("classId", U1), 9 | ("msgId", U1), 10 | ) 11 | 12 | payload_description0 = Fields( 13 | ("version", U1), 14 | ("length", U1), 15 | ("reserved1", 2*U1), 16 | ("seedHi", U4), 17 | ("seedLo", U4), 18 | ("ids", KeyLoop("length", ids)) 19 | ) 20 | 21 | description = MessageDescription( 22 | message_class=CFG, 23 | message_id=MessageId("FIXSEED", b"\x84"), 24 | payload_description=Options( 25 | payload_description0, 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_geofence.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | fences = Fields( 8 | ("lat", I4), 9 | ("lon", I4), 10 | ("radius", U4) 11 | ) 12 | 13 | payload_description0 = Fields( 14 | ("version", U1), 15 | ("numFences", U1), 16 | ("confLvl", U1), 17 | ("reserved1", U1), 18 | ("pioEnabled", U1), 19 | ("pinPolarity", U1), 20 | ("pin", U1), 21 | ("reserved2", U1), 22 | ("fences", KeyLoop("numFences", fences)) 23 | ) 24 | 25 | description = MessageDescription( 26 | message_class=CFG, 27 | message_id=MessageId("GEOFENCE", b"\x69"), 28 | payload_description=Options( 29 | Empty, 30 | payload_description0, 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_gnss.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(4, [ 8 | BitfieldEntry("enable", 0), 9 | BitfieldEntry("sigCfgMask", slice(16, 24)) 10 | ]) 11 | 12 | cfgBlocks = Fields( 13 | ("gnssId", U1), 14 | ("resTrkCh", U1), 15 | ("maxTrkCh", U1), 16 | ("reserved1", U1), 17 | ("flags", flags) 18 | ) 19 | 20 | payload_description0 = Fields( 21 | ("msgVer", U1), 22 | ("numTrkChHw", U1), 23 | ("numTrkChUse", U1), 24 | ("numCfgBlocks", U1), 25 | ("cfgBlocks", KeyLoop("numCfgBlocks", cfgBlocks)) 26 | ) 27 | 28 | description = MessageDescription( 29 | message_class=CFG, 30 | message_id=MessageId("GNSS", b"\x3e"), 31 | payload_description=Options( 32 | Empty, 33 | payload_description0, 34 | ) 35 | ) 36 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_hnr.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("highNavRate", U1), 9 | ("reserved1", 3*U1), 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=CFG, 14 | message_id=MessageId("HNR", b"\x5c"), 15 | payload_description=Options( 16 | Empty, 17 | payload_description0, 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_inf.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("protocolID", U1), 9 | ) 10 | 11 | infMsgMask = Bitfield(1, entries=[ 12 | BitfieldEntry("ERROR", 0), 13 | BitfieldEntry("WARNING", 1), 14 | BitfieldEntry("NOTICE", 2), 15 | BitfieldEntry("TEST", 3), 16 | BitfieldEntry("DEBUG", 4), 17 | ]) 18 | 19 | payload_description1 = MatchedLoop( 20 | Fields( 21 | ("protocolID", U1), 22 | ("reserved1", 3*U1), 23 | ("infMsgMask", 6*infMsgMask) 24 | ) 25 | ) 26 | 27 | description = MessageDescription( 28 | message_class=CFG, 29 | message_id=MessageId("INF", b"\x02"), 30 | payload_description=Options( 31 | payload_description0, 32 | payload_description1, 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_itfm.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | config = Bitfield(4, entries=[ 8 | BitfieldEntry("bbThreshold", slice(0, 4)), 9 | BitfieldEntry("cwThreshold", slice(4, 9)), 10 | BitfieldEntry("algorithmBits", slice(9, 32)), 11 | BitfieldEntry("enable", 31) 12 | ]) 13 | 14 | config2 = Bitfield(4, entries=[ 15 | BitfieldEntry("generalBits", slice(0, 12)), 16 | BitfieldEntry("antSetting", slice(12, 14)), 17 | BitfieldEntry("enable2", 14) 18 | ]) 19 | 20 | payload_description0 = Fields( 21 | ("config", config), 22 | ("config2", config2), 23 | ) 24 | 25 | description = MessageDescription( 26 | message_class=CFG, 27 | message_id=MessageId("ITFM", b"\x39"), 28 | payload_description=Options( 29 | Empty, 30 | payload_description0 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_logfilter.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("recordEnabled", 0), 9 | BitfieldEntry("psmOncePerWakupEnabled", 1), 10 | BitfieldEntry("applyAllFilterSettings", 2), 11 | ]) 12 | 13 | payload_description0 = Fields( 14 | ("version", U1), 15 | ("flags", flags), 16 | ("minInterval", U2), 17 | ("timeThreshold", U2), 18 | ("speedThreshold", U2), 19 | ("positionThreshold", U4), 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=CFG, 24 | message_id=MessageId("LOGFILTER", b"\x47"), 25 | payload_description=Options( 26 | Empty, 27 | payload_description0 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_msg.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("msgClass", U1), 9 | ("msgID", U1) 10 | ) 11 | 12 | payload_description1 = Fields( 13 | ("msgClass", U1), 14 | ("msgID", U1), 15 | ("rate", 6*U1) 16 | ) 17 | 18 | payload_description2 = Fields( 19 | ("msgClass", U1), 20 | ("msgID", U1), 21 | ("rate", U1) 22 | ) 23 | 24 | description = MessageDescription( 25 | message_class=CFG, 26 | message_id=MessageId("MSG", b"\x01"), 27 | payload_description=Options( 28 | payload_description0, 29 | payload_description1, 30 | payload_description2 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_nav5.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | mask = Bitfield(2, entries=[ 8 | BitfieldEntry("dyn", 0), 9 | BitfieldEntry("minEl", 1), 10 | BitfieldEntry("posFixMode", 2), 11 | BitfieldEntry("drLim", 3), 12 | BitfieldEntry("posMask", 4), 13 | BitfieldEntry("timeMask", 5), 14 | BitfieldEntry("staticHoldMask", 6), 15 | BitfieldEntry("dgpsMask", 7), 16 | BitfieldEntry("cnoThreshold", 8), 17 | BitfieldEntry("utc", 10), 18 | ]) 19 | 20 | payload_description0 = Fields( 21 | ("mask", mask), 22 | ("dynModel", U1), 23 | ("fixMode", U1), 24 | ("fixedAlt", I4), 25 | ("fixedAltVar", U4), 26 | ("minElev", I1), 27 | ("drLimit", U1), 28 | ("pDop", U2), 29 | ("tDop", U2), 30 | ("pAcc", U2), 31 | ("tAcc", U2), 32 | ("staticHoldThresh", U1), 33 | ("dgnssTimeout", U1), 34 | ("cnoThreshNumSVs", U1), 35 | ("cnoThresh", U1), 36 | ("reserved1", 2*U1), 37 | ("staticHoldMaxDist", U2), 38 | ("utcStandard", U1), 39 | ("reserved2", 5*U1) 40 | ) 41 | 42 | description = MessageDescription( 43 | message_class=CFG, 44 | message_id=MessageId("NAV5", b"\x24"), 45 | payload_description=Options( 46 | Empty, 47 | payload_description0 48 | ) 49 | ) 50 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_navx5.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | mask1 = Bitfield(2, entries=[ 8 | BitfieldEntry("minMax", 2), 9 | BitfieldEntry("minCno", 3), 10 | BitfieldEntry("initial3dfix", 6), 11 | BitfieldEntry("wknRoll", 9), 12 | BitfieldEntry("ackAid", 10), 13 | BitfieldEntry("ppp", 13), 14 | BitfieldEntry("aop", 14), 15 | ]) 16 | 17 | mask2_0 = Bitfield(4, entries=[ 18 | BitfieldEntry("adr", 6) 19 | ]) 20 | 21 | aopCfg = Bitfield(1, entries=[ 22 | BitfieldEntry("useAOP", 0) 23 | ]) 24 | 25 | # Version 15 - 17 26 | payload_description0 = Fields( 27 | ("version", U2), 28 | ("mask1", mask1), 29 | ("mask2", mask2_0), 30 | ("reserved1", 2*U1), 31 | ("minSVs", U1), 32 | ("maxSVs", U1), 33 | ("minCNO", U1), 34 | ("reserved2", U1), 35 | ("iniFix3D", U1), 36 | ("reserved3", 2*U1), 37 | ("ackAiding", U1), 38 | ("wknRollover", U2), 39 | ("reserved4", 6*U1), 40 | ("usePPP", U1), 41 | ("aopCfg", aopCfg), 42 | ("reserved5", 2*U1), 43 | ("aopOrbMaxErr", U2), 44 | ("reserved6", 4*U1), 45 | ("reserved7", 3*U1), 46 | ("useAddr", U1) 47 | ) 48 | 49 | 50 | mask2_1 = Bitfield(4, entries=[ 51 | BitfieldEntry("adr", 6), 52 | BitfieldEntry("sigAttenComp", 6) 53 | ]) 54 | 55 | # Version 18 - 23.01 56 | payload_description1 = Fields( 57 | ("version", U2), 58 | ("mask1", mask1), 59 | ("mask2", mask2_1), 60 | ("reserved1", 2*U1), 61 | ("minSVs", U1), 62 | ("maxSVs", U1), 63 | ("minCNO", U1), 64 | ("reserved2", U1), 65 | ("iniFix3D", U1), 66 | ("reserved3", 2*U1), 67 | ("ackAiding", U1), 68 | ("wknRollover", U2), 69 | ("sigAttenCompMode", U1), 70 | ("reserved4", U1), 71 | ("reserved5", 2*U1), 72 | ("reserved6", 2*U1), 73 | ("usePPP", U1), 74 | ("aopCfg", aopCfg), 75 | ("reserved7", 2*U1), 76 | ("aopOrbMaxErr", U2), 77 | ("reserved8", 4*U1), 78 | ("reserved9", 3*U1), 79 | ("useAddr", U1) 80 | ) 81 | 82 | 83 | # Version 19.1 84 | payload_description2 = Fields( 85 | ("version", U2), 86 | ("mask1", mask1), 87 | ("mask2", mask2_1), 88 | ("reserved1", 2*U1), 89 | ("minSVs", U1), 90 | ("maxSVs", U1), 91 | ("minCNO", U1), 92 | ("reserved2", U1), 93 | ("iniFix3D", U1), 94 | ("reserved3", 2*U1), 95 | ("ackAiding", U1), 96 | ("wknRollover", U2), 97 | ("sigAttenCompMode", U1), 98 | ("reserved4", U1), 99 | ("reserved5", 2*U1), 100 | ("reserved6", 2*U1), 101 | ("usePPP", U1), 102 | ("aopCfg", aopCfg), 103 | ("reserved7", 2*U1), 104 | ("aopOrbMaxErr", U2), 105 | ("reserved8", 4*U1), 106 | ("reserved9", 3*U1), 107 | ("useAddr", U1), 108 | ("reserved10", 2*U1), 109 | ("reserved11", 2*U1) 110 | ) 111 | 112 | 113 | description = MessageDescription( 114 | message_class=CFG, 115 | message_id=MessageId("NAVX5", b"\x23"), 116 | payload_description=Options( 117 | Empty, 118 | payload_description2, 119 | payload_description1, 120 | payload_description0 121 | ) 122 | ) 123 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_nmea.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | filterflags = Bitfield(1, entries=[ 8 | BitfieldEntry("posFilt", 0), 9 | BitfieldEntry("mskPosFilt", 1), 10 | BitfieldEntry("timeFilt", 2), 11 | BitfieldEntry("dateFilt", 3), 12 | BitfieldEntry("gpsOnlyFilter", 4), 13 | BitfieldEntry("trackFilt", 5), 14 | ]) 15 | 16 | flags = Bitfield(1, entries=[ 17 | BitfieldEntry("compat", 0), 18 | BitfieldEntry("consider", 1), 19 | BitfieldEntry("limit82", 2), 20 | BitfieldEntry("highPrec", 3) 21 | ]) 22 | 23 | gnssToFilter = Bitfield(4, entries=[ 24 | BitfieldEntry("gps", 0), 25 | BitfieldEntry("sbas", 1), 26 | BitfieldEntry("qzss", 4), 27 | BitfieldEntry("glonass", 5), 28 | BitfieldEntry("beidou", 6), 29 | ]) 30 | 31 | payload_description0 = Fields( 32 | ("filter", filterflags), 33 | ("nmeaVersion", U1), 34 | ("numSV", U1), 35 | ("flags", flags) 36 | ) 37 | 38 | payload_description1 = Fields( 39 | ("filter", filterflags), 40 | ("nmeaVersion", U1), 41 | ("numSV", U1), 42 | ("flags", flags), 43 | ("gnssToFilter", gnssToFilter), 44 | ("svNumbering", U1), 45 | ("mainTalkerIf", U1), 46 | ("gsvTalkerId", U1), 47 | ("version", U1), 48 | ) 49 | 50 | payload_description2 = Fields( 51 | ("filter", filterflags), 52 | ("nmeaVersion", U1), 53 | ("numSV", U1), 54 | ("flags", flags), 55 | ("gnssToFilter", gnssToFilter), 56 | ("svNumbering", U1), 57 | ("mainTalkerIf", U1), 58 | ("gsvTalkerId", U1), 59 | ("version", U1), 60 | ("bdsTalkerId", Chars(2)), 61 | ("reserved1", 6*U1) 62 | ) 63 | 64 | description = MessageDescription( 65 | message_class=CFG, 66 | message_id=MessageId("NMEA", b"\x17"), 67 | payload_description=Options( 68 | Empty, 69 | payload_description0, 70 | payload_description1, 71 | payload_description2 72 | ) 73 | ) 74 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_odo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("useODO", 0), 9 | BitfieldEntry("useCOG", 1), 10 | BitfieldEntry("outLPVel", 2), 11 | BitfieldEntry("outLPCog", 3) 12 | ]) 13 | 14 | odoCfg = Bitfield(1, entries=[ 15 | BitfieldEntry("profile", slice(0, 3)), 16 | ]) 17 | 18 | payload_description0 = Fields( 19 | ("version", U1), 20 | ("reserved1", 3*U1), 21 | ("flags", flags), 22 | ("odoCfg", odoCfg), 23 | ("reserved2", 6*U1), 24 | ("cogMaxSpeed", U1), 25 | ("cogMaxPosAcc", U1), 26 | ("reserved3", 2*U1), 27 | ("velLpGain", U1), 28 | ("cogLpGain", U1), 29 | ("reserved4", 2*U1) 30 | ) 31 | 32 | description = MessageDescription( 33 | message_class=CFG, 34 | message_id=MessageId("ODO", b"\x1e"), 35 | payload_description=Options( 36 | Empty, 37 | payload_description0 38 | ) 39 | ) 40 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_pm2.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags0 = Bitfield(4, entries=[ 8 | BitfieldEntry("extintSel", 4), 9 | BitfieldEntry("extintWake", 5), 10 | BitfieldEntry("extintBackup", 6), 11 | BitfieldEntry("limitPeakCurr", slice(8, 10)), 12 | BitfieldEntry("waitTimeFix", 10), 13 | BitfieldEntry("updateRTC", 11), 14 | BitfieldEntry("updateEPH", 12), 15 | BitfieldEntry("doNotEnterOff", 16), 16 | BitfieldEntry("mode", slice(17, 19)), 17 | ]) 18 | 19 | payload_description0 = Fields( 20 | ("version", U1), 21 | ("reserved1", U1), 22 | ("maxStartupStateDur", U1), 23 | ("reserved2", U1), 24 | ("flags", flags0), 25 | ("updatePeriod", U4), 26 | ("searchPeriod", U4), 27 | ("gridOffset", U4), 28 | ("onTime", U2), 29 | ("minAcqTime", U2), 30 | ("reserved3", 20*U1), 31 | ) 32 | 33 | 34 | flags1 = Bitfield(4, entries=[ 35 | BitfieldEntry("optTarget", slice(1, 4)), 36 | BitfieldEntry("extintSel", 4), 37 | BitfieldEntry("extintWake", 5), 38 | BitfieldEntry("extintBackup", 6), 39 | BitfieldEntry("extintInactive", 7), 40 | BitfieldEntry("limitPeakCurr", slice(8, 10)), 41 | BitfieldEntry("waitTimeFix", 10), 42 | BitfieldEntry("updateRTC", 11), 43 | BitfieldEntry("updateEPH", 12), 44 | BitfieldEntry("doNotEnterOff", 16), 45 | BitfieldEntry("mode", slice(17, 19)), 46 | ]) 47 | 48 | payload_description1 = Fields( 49 | ("version", U1), 50 | ("reserved1", U1), 51 | ("maxStartupStateDur", U1), 52 | ("reserved2", U1), 53 | ("flags", flags1), 54 | ("updatePeriod", U4), 55 | ("searchPeriod", U4), 56 | ("gridOffset", U4), 57 | ("onTime", U2), 58 | ("minAcqTime", U2), 59 | ("reserved3", 20*U1), 60 | ("extintInactivityMs", U4) 61 | ) 62 | 63 | 64 | 65 | description = MessageDescription( 66 | message_class=CFG, 67 | message_id=MessageId("PM2", b"\x3b"), 68 | payload_description=Options( 69 | Empty, 70 | payload_description0, 71 | payload_description1, 72 | ) 73 | ) 74 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_pms.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("powerSetupValue", U1), 10 | ("period", U2), 11 | ("onTime", U2), 12 | ("reserved1", 2*U1) 13 | ) 14 | 15 | 16 | description = MessageDescription( 17 | message_class=CFG, 18 | message_id=MessageId("PMS", b"\x86"), 19 | payload_description=Options( 20 | Empty, 21 | payload_description0, 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_prt.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("PortID", U1) 9 | ) 10 | 11 | txReady = Bitfield(2, entries=[ 12 | BitfieldEntry("en", 0), 13 | BitfieldEntry("pol", 1), 14 | BitfieldEntry("pin", slice(2, 7)), 15 | BitfieldEntry("thres", slice(7, 16)) 16 | ]) 17 | 18 | # mode_uart = Bitfield(4, entries=[ 19 | # BitfieldEntry("charLen", slice(6, 8)), 20 | # BitfieldEntry("parity", slice(9, 12)), 21 | # BitfieldEntry("nStopBits", slice(12, 14)) 22 | # ]) 23 | 24 | # mode_usb = 8*U1 25 | 26 | # mode_spi = Bitfield(2, entries=[ 27 | # BitfieldEntry("spiMode", slice(1, 3)), 28 | # BitfieldEntry("ffCnt", slice(8, 14)) 29 | # ]) 30 | 31 | # mode_ddc = Bitfield(2, entries=[ 32 | # BitfieldEntry("slaveAddr", slice(1, 8)) 33 | # ]) 34 | 35 | inProtoMask = Bitfield(2, entries=[ 36 | BitfieldEntry("inUbx", 0), 37 | BitfieldEntry("inNmea", 1), 38 | BitfieldEntry("inRtcm", 2), 39 | BitfieldEntry("inRtcm3", 5) 40 | ]) 41 | 42 | outProtoMask = Bitfield(2, entries=[ 43 | BitfieldEntry("outUbx", 0), 44 | BitfieldEntry("outNmea", 1), 45 | BitfieldEntry("outRtcm3", 5) 46 | ]) 47 | 48 | flags = Bitfield(2, entries=[ 49 | BitfieldEntry("extendedTxTimeout", 1) 50 | ]) 51 | 52 | payload_description1 = Fields( 53 | ("portID", U1), 54 | ("reserved1", U1), 55 | ("txReady", txReady), 56 | ("mode", X4), 57 | ("baudRate", U4), 58 | ("inProtoMask", inProtoMask), 59 | ("outProtoMask", outProtoMask), 60 | ("flags", flags), 61 | ("reserved2", 2*U1) 62 | ) 63 | 64 | 65 | description = MessageDescription( 66 | message_class=CFG, 67 | message_id=MessageId("PRT", b"\x00"), 68 | payload_description=Options( 69 | payload_description0, 70 | payload_description1 71 | ) 72 | ) 73 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_pwr.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("state", U4), 11 | ) 12 | 13 | description = MessageDescription( 14 | message_class=CFG, 15 | message_id=MessageId("PWR", b"\x57"), 16 | payload_description=Options( 17 | Empty, 18 | payload_description0, 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_rate.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("measRate", U2), 9 | ("navRate", U2), 10 | ("timeRef", U2), 11 | ) 12 | 13 | description = MessageDescription( 14 | message_class=CFG, 15 | message_id=MessageId("RATE", b"\x08"), 16 | payload_description=Options( 17 | Empty, 18 | payload_description0, 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_rinv.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | flags = Bitfield(1, entries=[ 7 | BitfieldEntry("dump", 0), 8 | BitfieldEntry("binary", 1), 9 | ]) 10 | 11 | payload_description0 = Fields( 12 | ("flags", flags), 13 | ("data", MatchedLoop(U1)) 14 | ) 15 | 16 | description = MessageDescription( 17 | message_class=CFG, 18 | message_id=MessageId("RINV", b"\x34"), 19 | payload_description=Options( 20 | Empty, 21 | payload_description0, 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_rst.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | navBbrMask = Bitfield(1, entries=[ 8 | BitfieldEntry("eph", 0), 9 | BitfieldEntry("alm", 1), 10 | BitfieldEntry("health", 2), 11 | BitfieldEntry("klob", 3), 12 | BitfieldEntry("pos", 4), 13 | BitfieldEntry("clkd", 5), 14 | BitfieldEntry("osc", 6), 15 | BitfieldEntry("utc", 7), 16 | BitfieldEntry("rtc", 8), 17 | BitfieldEntry("aop", 15), 18 | ]) 19 | 20 | payload_description0 = Fields( 21 | ("navBbrMask", navBbrMask), 22 | ("resetMode", U1) 23 | ) 24 | 25 | description = MessageDescription( 26 | message_class=CFG, 27 | message_id=MessageId("RST", b"\x04"), 28 | payload_description=Options( 29 | Empty, 30 | payload_description0, 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_rxm.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("reserved1", U1), 9 | ("lpMode", U1) 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=CFG, 14 | message_id=MessageId("RXM", b"\x11"), 15 | payload_description=Options( 16 | Empty, 17 | payload_description0, 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_sbas.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | mode = Bitfield(1, entries=[ 8 | BitfieldEntry("enabled", 0), 9 | BitfieldEntry("test", 1) 10 | ]) 11 | 12 | usage = Bitfield(1, entries=[ 13 | BitfieldEntry("range", 0), 14 | BitfieldEntry("diffCor", 1), 15 | BitfieldEntry("integrity", 2) 16 | ]) 17 | 18 | scanmode2 = Bitfield(1, entries=[ 19 | BitfieldEntry("PRN152", 0), 20 | BitfieldEntry("PRN153", 1), 21 | BitfieldEntry("PRN154", 3), 22 | BitfieldEntry("PRN155", 4), 23 | BitfieldEntry("PRN156", 5), 24 | BitfieldEntry("PRN157", 6), 25 | BitfieldEntry("PRN158", 7), 26 | ]) 27 | 28 | scanmode1 = Bitfield(4, entries=[ 29 | BitfieldEntry("PRN120", 0), 30 | BitfieldEntry("PRN121", 1), 31 | BitfieldEntry("PRN123", 3), 32 | BitfieldEntry("PRN124", 4), 33 | BitfieldEntry("PRN125", 5), 34 | BitfieldEntry("PRN126", 6), 35 | BitfieldEntry("PRN127", 7), 36 | BitfieldEntry("PRN128", 8), 37 | BitfieldEntry("PRN129", 9), 38 | BitfieldEntry("PRN130", 10), 39 | BitfieldEntry("PRN131", 11), 40 | BitfieldEntry("PRN133", 13), 41 | BitfieldEntry("PRN134", 14), 42 | BitfieldEntry("PRN135", 15), 43 | BitfieldEntry("PRN136", 16), 44 | BitfieldEntry("PRN137", 17), 45 | BitfieldEntry("PRN138", 18), 46 | BitfieldEntry("PRN139", 19), 47 | BitfieldEntry("PRN140", 20), 48 | BitfieldEntry("PRN141", 21), 49 | BitfieldEntry("PRN143", 23), 50 | BitfieldEntry("PRN144", 24), 51 | BitfieldEntry("PRN145", 25), 52 | BitfieldEntry("PRN146", 26), 53 | BitfieldEntry("PRN147", 27), 54 | BitfieldEntry("PRN148", 28), 55 | BitfieldEntry("PRN149", 29), 56 | BitfieldEntry("PRN150", 30), 57 | BitfieldEntry("PRN151", 31), 58 | ]) 59 | 60 | payload_description0 = Fields( 61 | ("mode", mode), 62 | ("usage", usage), 63 | ("maxSBAS", U1), 64 | ("scanmode2", scanmode2), 65 | ("scanmode1", scanmode1), 66 | ) 67 | 68 | description = MessageDescription( 69 | message_class=CFG, 70 | message_id=MessageId("SBAS", b"\x16"), 71 | payload_description=Options( 72 | Empty, 73 | payload_description0, 74 | ) 75 | ) 76 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_smgr.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | messageCfg = Bitfield(2, entries=[ 8 | BitfieldEntry("measInternal", 0), 9 | BitfieldEntry("measGNSS", 1), 10 | BitfieldEntry("measEXTINT0", 2), 11 | BitfieldEntry("measEXTINT1", 3), 12 | ]) 13 | 14 | flags = Bitfield(2, entries=[ 15 | BitfieldEntry("disableInternal", 0), 16 | BitfieldEntry("disableExternal", 1), 17 | BitfieldEntry("preferenceMode", 2), 18 | BitfieldEntry("enableGNSS", 3), 19 | BitfieldEntry("enableEXTINT0", 4), 20 | BitfieldEntry("enableEXTINT1", 5), 21 | BitfieldEntry("enableHostMeasInt", 6), 22 | BitfieldEntry("enableHostMeasExt", 7), 23 | BitfieldEntry("useAnyFix", 10), 24 | BitfieldEntry("disableMaxSlewRate", 11), 25 | BitfieldEntry("issueFreqWarning", 12), 26 | BitfieldEntry("issueTimeWarning", 13), 27 | BitfieldEntry("TPCoherent", slice(14, 16)), 28 | BitfieldEntry("disableOffset", 16), 29 | 30 | ]) 31 | 32 | payload_description0 = Fields( 33 | ("version", U1), 34 | ("miGNSSFix", U1), 35 | ("maxFreqChangeRate", U2), 36 | ("maxPhaseCorrRate", U2), 37 | ("reserved1", 2*U1), 38 | ("freqTolerance", U2), 39 | ("timeTolerance", U2), 40 | ("messageCfg", messageCfg), 41 | ("maxSlewRate", U2), 42 | ("flags", flags) 43 | ) 44 | 45 | description = MessageDescription( 46 | message_class=CFG, 47 | message_id=MessageId("SMGR", b"\x62"), 48 | payload_description=Options( 49 | Empty, 50 | payload_description0, 51 | ) 52 | ) 53 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_tmode2.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, entries=[ 8 | BitfieldEntry("lla", 0), 9 | BitfieldEntry("altInv", 1), 10 | ]) 11 | 12 | payload_description0 = Fields( 13 | ("timeMode", U1), 14 | ("reserved1", U1), 15 | ("flags", flags), 16 | ("ecefXOrLat", I4), 17 | ("ecefYOrLon", I4), 18 | ("ecefZOrAlt", I4), 19 | ("fixedPosAcc", U4), 20 | ("svinMinDur", U4), 21 | ("svinAccLim", U4) 22 | ) 23 | 24 | description = MessageDescription( 25 | message_class=CFG, 26 | message_id=MessageId("TMODE2", b"\x3d"), 27 | payload_description=Options( 28 | Empty, 29 | payload_description0, 30 | ) 31 | ) 32 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_tmode3.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, entries=[ 8 | BitfieldEntry("mode", slice(0, 8)), 9 | BitfieldEntry("lla", 8), 10 | ]) 11 | 12 | payload_description0 = Fields( 13 | ("version", U1), 14 | ("reserved1", U1), 15 | ("flags", flags), 16 | ("ecefXOrLat", I4), 17 | ("ecefYOrLon", I4), 18 | ("ecefZOrAlt", I4), 19 | ("ecefXOrLatHP", I1), 20 | ("ecefYOrLonHP", I1), 21 | ("ecefZOrAltHP", I1), 22 | ("reserved2", U1), 23 | ("fixedPosAcc", U4), 24 | ("svinMinDur", U4), 25 | ("svinAccLimit", U4), 26 | ("reserved3", 8*U1), 27 | ) 28 | 29 | description = MessageDescription( 30 | message_class=CFG, 31 | message_id=MessageId("TMODE3", b"\x71"), 32 | payload_description=Options( 33 | Empty, 34 | payload_description0, 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_tp5.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | # flags = Bitfield(4, entries=[ 8 | # BitfieldEntry("active", 0), 9 | # BitfieldEntry("lockGpsFreq", 1), 10 | # BitfieldEntry("lockedOtherSet", 2), 11 | # BitfieldEntry("isFreq", 3), 12 | # BitfieldEntry("isLength", 4), 13 | # BitfieldEntry("alignToTow", 5), 14 | # BitfieldEntry("polarity", 6), 15 | # BitfieldEntry("gridUtcGps", 7), 16 | # ]) 17 | 18 | flags = Bitfield(4, entries=[ 19 | BitfieldEntry("active", 0), 20 | BitfieldEntry("lockGpsFreq", 1), 21 | BitfieldEntry("lockedOtherSet", 2), 22 | BitfieldEntry("isFreq", 3), 23 | BitfieldEntry("isLength", 4), 24 | BitfieldEntry("alignToTow", 5), 25 | BitfieldEntry("polarity", 6), 26 | BitfieldEntry("gridUtcGnss", slice(7, 11)), 27 | BitfieldEntry("syncMode", slice(11, 13)), 28 | ]) 29 | 30 | payload_description0 = Fields( 31 | ("tpIdx", U1) 32 | ) 33 | 34 | payload_description1 = Fields( 35 | ("tpIdx", U1), 36 | ("version", U1), 37 | ("reserved1", 2*U1), 38 | ("antCableDelay", I2), 39 | ("rfGroupDelay", I2), 40 | ("freqPeriod", U4), 41 | ("freqPeriodLock", U4), 42 | ("pulseLenRation", U4), 43 | ("pulseLenRationLock", U4), 44 | ("userConfigDelay", I4), 45 | ("flags", flags) 46 | ) 47 | 48 | description = MessageDescription( 49 | message_class=CFG, 50 | message_id=MessageId("TP5", b"\x31"), 51 | payload_description=Options( 52 | Empty, 53 | payload_description0, 54 | payload_description1, 55 | ) 56 | ) 57 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_txslot.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | enable = Bitfield(1, entries=[ 8 | BitfieldEntry("DDC", 0), 9 | BitfieldEntry("UART1", 1), 10 | BitfieldEntry("UART2", 2), 11 | BitfieldEntry("USB", 3), 12 | BitfieldEntry("SPI", 4) 13 | ]) 14 | 15 | payload_description0 = Fields( 16 | ("version", U1), 17 | ("enable", enable), 18 | ("refTp", U1), 19 | ("reserved1", U1), 20 | ("end", 4*U4) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=CFG, 25 | message_id=MessageId("TXSLOT", b"\x53"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description0, 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/cfg_usb.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(2, entries=[ 8 | BitfieldEntry("reEnum", 0), 9 | BitfieldEntry("powerMode", 1), 10 | ]) 11 | 12 | payload_description0 = Fields( 13 | ("vendorID", U2), 14 | ("productID", U2), 15 | ("reserved1", 2*U1), 16 | ("reserved2", 2*U1), 17 | ("powerConsumption", U2), 18 | ("flags", flags), 19 | ("vendorString", Chars(32)), 20 | ("productString", Chars(32)), 21 | ("serialNumber", Chars(32)), 22 | ) 23 | 24 | description = MessageDescription( 25 | message_class=CFG, 26 | message_id=MessageId("USB", b"\x1b"), 27 | payload_description=Options( 28 | Empty, 29 | payload_description0, 30 | ) 31 | ) 32 | -------------------------------------------------------------------------------- /ubx/descriptions/esf_ins.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | bitfield0 = Bitfield(4, entries=[ 8 | BitfieldEntry("version", slice(0, 8)), 9 | BitfieldEntry("xAngRateValid", 8), 10 | BitfieldEntry("yAngRateValid", 9), 11 | BitfieldEntry("zAngRateValid", 10), 12 | BitfieldEntry("xAccelValid", 11), 13 | BitfieldEntry("yAccelValid", 12), 14 | BitfieldEntry("zAccelValid", 13), 15 | ]) 16 | 17 | payload_description0 = Fields( 18 | ("bitfield0", bitfield0), 19 | ("reserved1", 4*U1), 20 | ("iTOW", U4), 21 | ("xAngRate", I4), 22 | ("yAngRate", I4), 23 | ("zAngRate", I4), 24 | ("xAccel", I4), 25 | ("yAccel", I4), 26 | ("zAccel", I4), 27 | ) 28 | 29 | description = MessageDescription( 30 | message_class=ESF, 31 | message_id=MessageId("INS", b"\x15"), 32 | payload_description=Options( 33 | Empty, 34 | payload_description0, 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /ubx/descriptions/esf_raw.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | data = Bitfield(4, entries=[ 8 | BitfieldEntry("dataField", slice(0, 24)), 9 | BitfieldEntry("dataType", slice(24, 32)) 10 | ]) 11 | 12 | measurement = Fields( 13 | ("data", data), 14 | ("sTtag", U4) 15 | ) 16 | 17 | payload_description0 = Fields( 18 | ("reserved1", 4*U1), 19 | ("measurements", MatchedLoop(measurement)) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=ESF, 24 | message_id=MessageId("RAW", b"\x03"), 25 | payload_description=Options( 26 | Empty, 27 | payload_description0, 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /ubx/descriptions/esf_status.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | sensStatus1 = Bitfield(1, entries=[ 8 | BitfieldEntry("type", slice(0, 6)), 9 | BitfieldEntry("used", 6), 10 | BitfieldEntry("ready", 7), 11 | ]) 12 | 13 | sensStatus2 = Bitfield(1, entries=[ 14 | BitfieldEntry("calibStatus", slice(0, 2)), 15 | BitfieldEntry("timeStatus", slice(2, 4)) 16 | ]) 17 | 18 | faults = Bitfield(1, entries=[ 19 | BitfieldEntry("badMeas", 0), 20 | BitfieldEntry("badTTag", 1), 21 | BitfieldEntry("missingMeas", 2), 22 | BitfieldEntry("noisyMeas", 3), 23 | ]) 24 | 25 | sens = Fields( 26 | ("sensStatus1", sensStatus1), 27 | ("sensStatus2", sensStatus2), 28 | ("freq", U1), 29 | ("faults", faults) 30 | ) 31 | 32 | payload_description0 = Fields( 33 | ("iTOW", U4), 34 | ("version", U1), 35 | ("reserved1", 7*U1), 36 | ("fusionMode", U1), 37 | ("reserved2", 2*U1), 38 | ("numSens", U1), 39 | ("sens", KeyLoop("numSens", sens)) 40 | ) 41 | 42 | description = MessageDescription( 43 | message_class=ESF, 44 | message_id=MessageId("STATUS", b"\x10"), 45 | payload_description=Options( 46 | Empty, 47 | payload_description0, 48 | ) 49 | ) 50 | -------------------------------------------------------------------------------- /ubx/descriptions/hnr_pvt.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("validDate", 0), 9 | BitfieldEntry("validTime", 1), 10 | BitfieldEntry("fullyResolved", 2) 11 | ]) 12 | 13 | flags = Bitfield(1, entries=[ 14 | BitfieldEntry("GPSfixOK", 0), 15 | BitfieldEntry("DiffSoln", 1), 16 | BitfieldEntry("WKNSET", 2), 17 | BitfieldEntry("TOWSET", 3), 18 | BitfieldEntry("headVehValid", 4) 19 | ]) 20 | 21 | payload_description0 = Fields( 22 | ("iTOW", U4), 23 | ("year", U2), 24 | ("month", U1), 25 | ("day", U1), 26 | ("hour", U1), 27 | ("min", U1), 28 | ("sec", U1), 29 | ("valid", valid), 30 | ("nano", I4), 31 | ("gpsFix", U1), 32 | ("flags", flags), 33 | ("reserved1", 2*U1), 34 | ("lon", I4), 35 | ("lat", I4), 36 | ("height", I4), 37 | ("hMSL", I4), 38 | ("gSpeed", I4), 39 | ("speed", I4), 40 | ("headMot", I4), 41 | ("headVeh", I4), 42 | ("hAcc", U4), 43 | ("vAcc", U4), 44 | ("sAcc", U4), 45 | ("headAcc", U4), 46 | ("reserved2", 4*U1) 47 | ) 48 | 49 | description = MessageDescription( 50 | message_class=HNR, 51 | message_id=MessageId("PVT", b"\x00"), 52 | payload_description=Options( 53 | Empty, 54 | payload_description0, 55 | ) 56 | ) 57 | -------------------------------------------------------------------------------- /ubx/descriptions/inf_debug.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("str", Chars(None)), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=INF, 13 | message_id=MessageId("DEBUG", b"\x04"), 14 | payload_description=Options( 15 | payload_description0, 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/inf_error.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("str", Chars(None)), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=INF, 13 | message_id=MessageId("ERROR", b"\x00"), 14 | payload_description=Options( 15 | payload_description0, 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/inf_notice.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("str", Chars(None)), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=INF, 13 | message_id=MessageId("NOTICE", b"\x02"), 14 | payload_description=Options( 15 | payload_description0, 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/inf_test.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("str", Chars(None)), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=INF, 13 | message_id=MessageId("TEST", b"\x03"), 14 | payload_description=Options( 15 | payload_description0, 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/inf_warning.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("str", Chars(None)), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=INF, 13 | message_id=MessageId("WARNING", b"\x01"), 14 | payload_description=Options( 15 | payload_description0, 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/log_batch.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | contentValid = Bitfield(1, entries=[ 8 | BitfieldEntry("extraPvt", 0), 9 | BitfieldEntry("extraOdo", 1) 10 | ]) 11 | 12 | valid = Bitfield(1, entries=[ 13 | BitfieldEntry("validDate", 0), 14 | BitfieldEntry("validTime", 1) 15 | ]) 16 | 17 | flags = Bitfield(1, entries=[ 18 | BitfieldEntry("gnssFixOK", 0), 19 | BitfieldEntry("diffSoln", 1), 20 | BitfieldEntry("psmState", slice(2, 5)), 21 | ]) 22 | 23 | payload_description = Fields( 24 | ("version", U1), 25 | ("contentValid", contentValid), 26 | ("msgCnt", U2), 27 | ("iTOW", U4), 28 | ("year", U2), 29 | ("month", U1), 30 | ("day", U1), 31 | ("hour", U1), 32 | ("min", U1), 33 | ("sec", U1), 34 | ("valid", valid), 35 | ("tAcc", U4), 36 | ("fracSec", I4), 37 | ("fixType", U1), 38 | ("flags", flags), 39 | ("flags2", X1), 40 | ("numSV", U1), 41 | ("lon", I4), 42 | ("lat", I4), 43 | ("height", I4), 44 | ("hMSL", I4), 45 | ("hAcc", U4), 46 | ("vAcc", U4), 47 | ("velN", I4), 48 | ("velE", I4), 49 | ("velD", I4), 50 | ("gSpeed", I4), 51 | ("headMot", I4), 52 | ("sAcc", U4), 53 | ("headAcc", U4), 54 | ("pDOP", U2), 55 | ("reserved1", 2*U1), 56 | ("distance", U4), 57 | ("totalDistance", U4), 58 | ("distanceStd", U4), 59 | ("reserved2", 4*U1) 60 | ) 61 | 62 | description = MessageDescription( 63 | message_class=LOG, 64 | message_id=MessageId("BATCH", b"\x11"), 65 | payload_description=Options( 66 | Empty, 67 | payload_description 68 | ) 69 | ) 70 | -------------------------------------------------------------------------------- /ubx/descriptions/log_create.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | logCfg = Bitfield(1, entries=[ 8 | BitfieldEntry("circular", 0) 9 | ]) 10 | 11 | payload_description = Fields( 12 | ("version", U1), 13 | ("logCfg", logCfg), 14 | ("reserved1", U1), 15 | ("logSize", U1), 16 | ("userDefinedSize", U4) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=LOG, 21 | message_id=MessageId("CREATE", b"\x07"), 22 | payload_description=Options( 23 | payload_description 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /ubx/descriptions/log_erase.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | description = MessageDescription( 8 | message_class=LOG, 9 | message_id=MessageId("ERASE", b"\x03"), 10 | payload_description=Options( 11 | Empty 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /ubx/descriptions/log_findtime.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | # Request 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("type", U1), 10 | ("reserved1", 2*U1), 11 | ("year", U2), 12 | ("month", U1), 13 | ("day", U1), 14 | ("hour", U1), 15 | ("minute", U1), 16 | ("second", U1), 17 | ("reserved2", U1) 18 | ) 19 | 20 | # Response 21 | payload_description1 = Fields( 22 | ("version", U1), 23 | ("type", U1), 24 | ("reserved1", 2*U1), 25 | ("entryNumber", U4), 26 | ) 27 | 28 | description = MessageDescription( 29 | message_class=LOG, 30 | message_id=MessageId("FINDTIME", b"\x0e"), 31 | payload_description=Options( 32 | payload_description0, 33 | payload_description1 34 | ) 35 | ) 36 | -------------------------------------------------------------------------------- /ubx/descriptions/log_info.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | status = Bitfield(1, entries=[ 8 | BitfieldEntry("recording", 3), 9 | BitfieldEntry("inactive", 4), 10 | BitfieldEntry("circular", 5) 11 | ]) 12 | 13 | payload_description = Fields( 14 | ("version", U1), 15 | ("reserved1", 3*U1), 16 | ("filestoreCapacity", U4), 17 | ("reserved2", 8*U1), 18 | ("currentMaxLogSize", U4), 19 | ("currentLogSize", U4), 20 | ("entryCount", U4), 21 | ("oldestYear", U2), 22 | ("oldestMonth", U1), 23 | ("oldestDay", U1), 24 | ("oldestHour", U1), 25 | ("oldestMinute", U1), 26 | ("oldestSecond", U1), 27 | ("reserved3", U1), 28 | ("newestYear", U2), 29 | ("newestMonth", U1), 30 | ("newestDay", U1), 31 | ("newestHour", U1), 32 | ("newestMinute", U1), 33 | ("newestSecond", U1), 34 | ("reserved4", U1), 35 | ("status", status), 36 | ("reserved5", 3*U1) 37 | ) 38 | 39 | description = MessageDescription( 40 | message_class=LOG, 41 | message_id=MessageId("INFO", b"\x08"), 42 | payload_description=Options( 43 | Empty, 44 | payload_description 45 | ) 46 | ) 47 | -------------------------------------------------------------------------------- /ubx/descriptions/log_retrieve.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("startNumber", U4), 9 | ("entryCount", U4), 10 | ("version", U1), 11 | ("reserved1", 3*U1) 12 | ) 13 | 14 | description = MessageDescription( 15 | message_class=LOG, 16 | message_id=MessageId("RETRIEVE", b"\x09"), 17 | payload_description=Options( 18 | payload_description 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /ubx/descriptions/log_retrievebatch.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("sendMonFirst", 0) 9 | ]) 10 | 11 | payload_description = Fields( 12 | ("version", U1), 13 | ("flags", flags), 14 | ("reserved1", 2*U1) 15 | ) 16 | 17 | description = MessageDescription( 18 | message_class=LOG, 19 | message_id=MessageId("RETRIEVEBATCH", b"\x10"), 20 | payload_description=Options( 21 | payload_description 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /ubx/descriptions/log_retrievepos.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("entryIndex", U4), 9 | ("lon", I4), 10 | ("lat", I4), 11 | ("hMSL", I4), 12 | ("hAcc", U4), 13 | ("gSpeed", U4), 14 | ("heading", U4), 15 | ("version", U1), 16 | ("fixType", U1), 17 | ("year", U2), 18 | ("month", U1), 19 | ("day", U1), 20 | ("hour", U1), 21 | ("minute", U1), 22 | ("second", U1), 23 | ("reserved1", U1), 24 | ("numSV", U1), 25 | ("reserved2", U1) 26 | ) 27 | 28 | description = MessageDescription( 29 | message_class=LOG, 30 | message_id=MessageId("RETRIEVEPOS", b"\x0b"), 31 | payload_description=Options( 32 | payload_description 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /ubx/descriptions/log_retrieveposextra.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("entryIndex", U4), 9 | ("version", U1), 10 | ("reserved1", U1), 11 | ("year", U2), 12 | ("month", U1), 13 | ("day", U1), 14 | ("hour", U1), 15 | ("minute", U1), 16 | ("second", U1), 17 | ("reserved2", 3*U1), 18 | ("distance", U4), 19 | ("reserved3", 12*U1) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=LOG, 24 | message_id=MessageId("RETRIEVEPOSEXTRA", b"\x0f"), 25 | payload_description=Options( 26 | payload_description 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/descriptions/log_retrievestring.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("entryIndex", U4), 9 | ("version", U1), 10 | ("reserved1", U1), 11 | ("year", U2), 12 | ("month", U1), 13 | ("day", U1), 14 | ("hour", U1), 15 | ("minute", U1), 16 | ("second", U1), 17 | ("reserved2", U1), 18 | ("byteCount", U2), 19 | ("bytes", KeyLoop("byteCount", U1)) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=LOG, 24 | message_id=MessageId("RETRIEVESTRING", b"\x0d"), 25 | payload_description=Options( 26 | payload_description 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/descriptions/log_string.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("bytes", MatchedLoop(U1)) 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=LOG, 13 | message_id=MessageId("STRING", b"\x04"), 14 | payload_description=Options( 15 | payload_description 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_ack.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("infoCode", U1), 11 | ("msgId", U1), 12 | ("msgPayloadStart", 4*U1) 13 | ) 14 | 15 | description = MessageDescription( 16 | message_class=MGA, 17 | message_id=MessageId("ACK", b"\x60"), 18 | payload_description=Options( 19 | payload_description 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_ano.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("gnssId", U1), 12 | ("year", U1), 13 | ("month", U1), 14 | ("day", U1), 15 | ("reserved1", U1), 16 | ("data", 64*U1), 17 | ("reserved2", 4*U1) 18 | ) 19 | 20 | description = MessageDescription( 21 | message_class=MGA, 22 | message_id=MessageId("ANO", b"\x20"), 23 | payload_description=Options( 24 | payload_description 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_bds.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_eph = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("satH1", U1), 13 | ("IODC", U1), 14 | ("a2", I2), 15 | ("a1", I4), 16 | ("a0", I4), 17 | ("toc", U4), 18 | ("TGD1", I2), 19 | ("URAI", U1), 20 | ("IODE", U1), 21 | ("toe", U4), 22 | ("sqrtA", U4), 23 | ("e", U4), 24 | ("omega", I4), 25 | ("Deltan", I2), 26 | ("IDOT", I2), 27 | ("M0", I4), 28 | ("Omega0", I4), 29 | ("OmegaDot", I4), 30 | ("i0", I4), 31 | ("Cuc", I4), 32 | ("Cus", I4), 33 | ("Crc", I4), 34 | ("Crs", I4), 35 | ("Cic", I4), 36 | ("Cis", I4), 37 | ("reserved2", 4*U1) 38 | ) 39 | 40 | payload_description_alm = Fields( 41 | ("type", U1), 42 | ("version", U1), 43 | ("svId", U1), 44 | ("reserved1", U1), 45 | ("Wna", U1), 46 | ("toa", U1), 47 | ("deltaI", I2), 48 | ("sqrtA", U4), 49 | ("e", U4), 50 | ("omega", I4), 51 | ("M0", I4), 52 | ("Omega0", I4), 53 | ("OmegaDot", I4), 54 | ("a0", I2), 55 | ("a1", I2), 56 | ("reserved2", 4*U1) 57 | ) 58 | 59 | payload_description_health = Fields( 60 | ("type", U1), 61 | ("version", U1), 62 | ("reserved1", 2*U1), 63 | ("healthCode", 30*U2), 64 | ("reserved2", 4*U1) 65 | ) 66 | 67 | payload_description_utc = Fields( 68 | ("type", U1), 69 | ("version", U1), 70 | ("reserved1", 2*U1), 71 | ("a0UTC", I4), 72 | ("a1UTC", I4), 73 | ("dtLS", I1), 74 | ("reserved2", U1), 75 | ("wnRec", U1), 76 | ("wnLSF", U1), 77 | ("dN", U1), 78 | ("dtLSF", I1), 79 | ("reserved3", 2*U1) 80 | ) 81 | 82 | payload_description_iono = Fields( 83 | ("type", U1), 84 | ("version", U1), 85 | ("reserved1", 2*U1), 86 | ("alpha0", I1), 87 | ("alpha1", I1), 88 | ("alpha2", I1), 89 | ("alpha3", I1), 90 | ("beta0", I1), 91 | ("beta1", I1), 92 | ("beta2", I1), 93 | ("beta3", I1), 94 | ("reserved2", 4*U1) 95 | ) 96 | 97 | description = MessageDescription( 98 | message_class=MGA, 99 | message_id=MessageId("BDS", b"\x03"), 100 | payload_description=Options( 101 | payload_description_eph, 102 | payload_description_alm, 103 | payload_description_health, 104 | payload_description_utc, 105 | payload_description_iono 106 | ) 107 | ) 108 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_dbd.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("reserved1", 12*U1), 9 | ("data", MatchedLoop(U1)) 10 | ) 11 | 12 | description = MessageDescription( 13 | message_class=MGA, 14 | message_id=MessageId("DBD", b"\x80"), 15 | payload_description=Options( 16 | Empty, 17 | payload_description 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_flash.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_data = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("sequence", U2), 11 | ("size", U2), 12 | ("data", KeyLoop("size", U1)) 13 | ) 14 | 15 | payload_description_stop = Fields( 16 | ("type", U1), 17 | ("version", U1) 18 | ) 19 | 20 | payload_description_ack = Fields( 21 | ("type", U1), 22 | ("version", U1), 23 | ("ack", U1), 24 | ("reserved1", U1), 25 | ("sequence", U2) 26 | ) 27 | 28 | description = MessageDescription( 29 | message_class=MGA, 30 | message_id=MessageId("FLASH", b"\x21"), 31 | payload_description=Options( 32 | payload_description_stop, 33 | payload_description_ack, 34 | payload_description_data 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_gal.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_eph = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("iodNav", U2), 13 | ("deltaN", I2), 14 | ("m0", I4), 15 | ("e", U4), 16 | ("sqrtA", U4), 17 | ("omega0", I4), 18 | ("i0", I4), 19 | ("omega", I4), 20 | ("omegaDot", I4), 21 | ("iDot", I2), 22 | ("cuc", I2), 23 | ("cus", I2), 24 | ("crc", I2), 25 | ("crs", I2), 26 | ("cic", I2), 27 | ("cis", I2), 28 | ("toe", U2), 29 | ("af0", I4), 30 | ("af1", I4), 31 | ("af2", I1), 32 | ("sisaIndexE1E5b", U1), 33 | ("toc", U2), 34 | ("bgdE1E5b", I2), 35 | ("reserved2", 2*U1), 36 | ("healthE1b", U1), 37 | ("dataValidityE1b", U1), 38 | ("healthE5b", U1), 39 | ("dataValidityE5b", U1), 40 | ("reserved3", 4*U1) 41 | ) 42 | 43 | payload_description_alm = Fields( 44 | ("type", U1), 45 | ("version", U1), 46 | ("svId", U1), 47 | ("reserved1", U1), 48 | ("ioda", U1), 49 | ("almWNa", U1), 50 | ("toa", U2), 51 | ("deltaSqrtA", I2), 52 | ("e", U2), 53 | ("deltaI", I2), 54 | ("omega0", I2), 55 | ("omegaDot", I2), 56 | ("omega", I2), 57 | ("m0", I2), 58 | ("af0", I2), 59 | ("af1", I2), 60 | ("healthE1B", U1), 61 | ("healthE5b", U1), 62 | ("reserved2", 4*U1) 63 | ) 64 | 65 | payload_description_timeoffset = Fields( 66 | ("type", U1), 67 | ("version", U1), 68 | ("reserved1", 2*U1), 69 | ("a0G", I2), 70 | ("a1G", I2), 71 | ("t0G", U1), 72 | ("wn0G", U1), 73 | ("reserved2", 2*U1) 74 | ) 75 | 76 | payload_description_utc = Fields( 77 | ("type", U1), 78 | ("version", U1), 79 | ("reserved1", 2*U1), 80 | ("a0", I4), 81 | ("a1", I4), 82 | ("dtLS", I1), 83 | ("tot", U1), 84 | ("wnt", U1), 85 | ("wnLSF", U1), 86 | ("dN", U1), 87 | ("dtLSF", I1), 88 | ("reserved2", 2*U1) 89 | ) 90 | 91 | description = MessageDescription( 92 | message_class=MGA, 93 | message_id=MessageId("GAL", b"\x02"), 94 | payload_description=Options( 95 | payload_description_eph, 96 | payload_description_alm, 97 | payload_description_timeoffset, 98 | payload_description_utc 99 | ) 100 | ) 101 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_glo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_eph = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("FT", U1), 13 | ("B", U1), 14 | ("M", U1), 15 | ("H", I1), 16 | ("x", I4), 17 | ("y", I4), 18 | ("z", I4), 19 | ("dx", I4), 20 | ("dy", I4), 21 | ("dz", I4), 22 | ("ddx", I1), 23 | ("ddy", I1), 24 | ("ddz", I1), 25 | ("tb", U1), 26 | ("gamma", I2), 27 | ("E", U1), 28 | ("deltaTau", I1), 29 | ("tau", I4), 30 | ("reserved2", 4*U1) 31 | ) 32 | 33 | payload_description_alm = Fields( 34 | ("type", U1), 35 | ("version", U1), 36 | ("svId", U1), 37 | ("reserved1", U1), 38 | ("N", U2), 39 | ("M", U1), 40 | ("C", U1), 41 | ("tau", I2), 42 | ("epsilon", U2), 43 | ("lambda", I4), 44 | ("deltaI", I4), 45 | ("tLambda", U4), 46 | ("deltaT", I4), 47 | ("deltaDT", I1), 48 | ("H", I1), 49 | ("omega", I2), 50 | ("reserved2", 4*U1) 51 | ) 52 | 53 | payload_description_timeoffset = Fields( 54 | ("type", U1), 55 | ("version", U1), 56 | ("N", U2), 57 | ("tauC", I4), 58 | ("tauGps", I4), 59 | ("B1", I2), 60 | ("B2", I2), 61 | ("reserved1", 4*U1) 62 | ) 63 | 64 | description = MessageDescription( 65 | message_class=MGA, 66 | message_id=MessageId("GLO", b"\x06"), 67 | payload_description=Options( 68 | payload_description_eph, 69 | payload_description_alm, 70 | payload_description_timeoffset 71 | ) 72 | ) 73 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_gps.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_eph = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("fitInterval", U1), 13 | ("uraIndex", U1), 14 | ("svHealth", U1), 15 | ("tgd", I1), 16 | ("iodc", U2), 17 | ("toc", U2), 18 | ("reserved2", U1), 19 | ("af2", I1), 20 | ("af1", I2), 21 | ("af0", I4), 22 | ("crs", I2), 23 | ("deltaN", I2), 24 | ("m0", I4), 25 | ("cuc", I2), 26 | ("cus", I2), 27 | ("e", U4), 28 | ("sqrtA", U4), 29 | ("toe", U2), 30 | ("cic", I2), 31 | ("omega0", I4), 32 | ("cis", I2), 33 | ("crc", I2), 34 | ("i0", I4), 35 | ("omega", I4), 36 | ("omegaDot", I4), 37 | ("idot", I2), 38 | ("reserved3", 2*U1) 39 | ) 40 | 41 | payload_description_alm = Fields( 42 | ("type", U1), 43 | ("version", U1), 44 | ("svId", U1), 45 | ("svHealth", U1), 46 | ("e", U2), 47 | ("almWNa", U1), 48 | ("toa", U1), 49 | ("deltaI", I2), 50 | ("omegaDot", I2), 51 | ("sqrtA", U4), 52 | ("omega0", I4), 53 | ("omega", I4), 54 | ("m0", I4), 55 | ("af0", I2), 56 | ("af1", I2), 57 | ("reserved1", 4*U1) 58 | ) 59 | 60 | payload_description_health = Fields( 61 | ("type", U1), 62 | ("version", U1), 63 | ("reserved1", 2*U1), 64 | ("healthCode", 32*U1), 65 | ("reserved2", 4*U1) 66 | ) 67 | 68 | payload_description_utc = Fields( 69 | ("type", U1), 70 | ("version", U1), 71 | ("reserved1", 2*U1), 72 | ("utcA0", I4), 73 | ("utcA1", I4), 74 | ("utcDtLS", I1), 75 | ("utcTot", U1), 76 | ("utcWNt", U1), 77 | ("utcWNlsf", U1), 78 | ("utcDn", U1), 79 | ("utcDtLSF", I1), 80 | ("reserved2", 2*U1) 81 | ) 82 | 83 | payload_description_iono = Fields( 84 | ("type", U1), 85 | ("version", U1), 86 | ("reserved1", 2*U1), 87 | ("ionoAlpha0", I1), 88 | ("ionoAlpha1", I1), 89 | ("ionoAlpha2", I1), 90 | ("ionoAlpha3", I1), 91 | ("ionoBeta0", I1), 92 | ("ionoBeta1", I1), 93 | ("ionoBeta2", I1), 94 | ("ionoBeta3", I1), 95 | ("reserved2", 4*U1) 96 | ) 97 | 98 | description = MessageDescription( 99 | message_class=MGA, 100 | message_id=MessageId("GPS", b"\x00"), 101 | payload_description=Options( 102 | payload_description_eph, 103 | payload_description_alm, 104 | payload_description_health, 105 | payload_description_utc, 106 | payload_description_iono 107 | ) 108 | ) 109 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_ini.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_pos_xyz = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("reserved1", 2*U1), 11 | ("ecefX", I4), 12 | ("ecefY", I4), 13 | ("ecefZ", I4), 14 | ("posAcc", U4) 15 | ) 16 | 17 | payload_description_pos_llh = Fields( 18 | ("type", U1), 19 | ("version", U1), 20 | ("reserved1", 2*U1), 21 | ("lat", I4), 22 | ("lon", I4), 23 | ("alt", I4), 24 | ("posAcc", U4) 25 | ) 26 | 27 | ref = Bitfield(1, entries=[ 28 | BitfieldEntry("source", slice(0, 4)), 29 | BitfieldEntry("fall", 4), 30 | BitfieldEntry("last", 5) 31 | ]) 32 | 33 | payload_description_time_utc = Fields( 34 | ("type", U1), 35 | ("version", U1), 36 | ("ref", ref), 37 | ("leapSecs", I1), 38 | ("year", U2), 39 | ("month", U1), 40 | ("day", U1), 41 | ("hour", U1), 42 | ("minute", U1), 43 | ("second", U1), 44 | ("reserved1", U1), 45 | ("ns", U4), 46 | ("tAccS", U2), 47 | ("reserved2", 2*U1), 48 | ("tAccNs", U4), 49 | ) 50 | 51 | payload_description_time_gps = Fields( 52 | ("type", U1), 53 | ("version", U1), 54 | ("ref", ref), 55 | ("gnssId", U1), 56 | ("reserved1", 2*U1), 57 | ("week", U2), 58 | ("tow", U4), 59 | ("ns", U4), 60 | ("tAccS", U2), 61 | ("reserved2", 2*U1), 62 | ("tAccNs", U4) 63 | ) 64 | 65 | payload_description_clkd = Fields( 66 | ("type", U1), 67 | ("version", U1), 68 | ("reserved1", 2*U1), 69 | ("clkD", I4), 70 | ("clkDAcc", U4) 71 | ) 72 | 73 | flags = Bitfield(1, entries=[ 74 | BitfieldEntry("source", slice(0, 4)), 75 | BitfieldEntry("fall", 4) 76 | ]) 77 | 78 | payload_description_freq = Fields( 79 | ("type", U1), 80 | ("version", U1), 81 | ("reserved1", 2*U1), 82 | ("flags", flags), 83 | ("freq", I4), 84 | ("freqAcc", U4) 85 | ) 86 | 87 | payload_description_eop = Fields( 88 | ("type", U1), 89 | ("version", U1), 90 | ("reserved1", 2*U1), 91 | ("d2kRef", U2), 92 | ("d2kMax", U2), 93 | ("xpP0", I4), 94 | ("xpP1", I4), 95 | ("ypP0", I4), 96 | ("ypP1", I4), 97 | ("dUT1", I4), 98 | ("ddUT1", I4), 99 | ("reserved2", 40*U1) 100 | ) 101 | 102 | description = MessageDescription( 103 | message_class=MGA, 104 | message_id=MessageId("INI", b"\x40"), 105 | payload_description=Options( 106 | payload_description_pos_xyz, 107 | payload_description_pos_llh, 108 | payload_description_time_utc, 109 | payload_description_time_gps, 110 | payload_description_clkd, 111 | payload_description_freq, 112 | payload_description_eop 113 | ) 114 | ) 115 | -------------------------------------------------------------------------------- /ubx/descriptions/mga_qzss.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description_eph = Fields( 8 | ("type", U1), 9 | ("version", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("fitInterval", U1), 13 | ("uraIndex", U1), 14 | ("svHealth", U1), 15 | ("tgd", I1), 16 | ("iodc", U2), 17 | ("toc", U2), 18 | ("reserved2", U1), 19 | ("af2", I1), 20 | ("af1", I2), 21 | ("af0", I4), 22 | ("crs", I2), 23 | ("deltaN", I2), 24 | ("m0", I4), 25 | ("cuc", I2), 26 | ("cus", I2), 27 | ("e", U4), 28 | ("sqrtA", U4), 29 | ("toe", U2), 30 | ("cic", I2), 31 | ("omega0", I4), 32 | ("cis", I2), 33 | ("crc", I2), 34 | ("i0", I4), 35 | ("omega", I4), 36 | ("omegaDot", I4), 37 | ("idot", I2), 38 | ("reserved3", 2*U1) 39 | ) 40 | 41 | payload_description_alm = Fields( 42 | ("type", U1), 43 | ("version", U1), 44 | ("svId", U1), 45 | ("svHealth", U1), 46 | ("e", U2), 47 | ("almWNa", U1), 48 | ("toa", U1), 49 | ("deltaI", I2), 50 | ("omegaDot", I2), 51 | ("sqrtA", U4), 52 | ("omega0", I4), 53 | ("omega", I4), 54 | ("m0", I4), 55 | ("af0", I2), 56 | ("af1", I2), 57 | ("reserved1", 4*U1) 58 | ) 59 | 60 | payload_description_health = Fields( 61 | ("type", U1), 62 | ("version", U1), 63 | ("reserved1", 2*U1), 64 | ("healthCode", 5*U1), 65 | ("reserved2", 3*U1) 66 | ) 67 | 68 | description = MessageDescription( 69 | message_class=MGA, 70 | message_id=MessageId("QZSS", b"\x05"), 71 | payload_description=Options( 72 | payload_description_eph, 73 | payload_description_alm, 74 | payload_description_health, 75 | ) 76 | ) 77 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_batch.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("fillLevel", U2), 11 | ("dropsAll", U2), 12 | ("dropsSinceMon", U2), 13 | ("nextMsgCnt", U2) 14 | ) 15 | 16 | description = MessageDescription( 17 | message_class=MON, 18 | message_id=MessageId("BATCH", b"\x32"), 19 | payload_description=Options( 20 | Empty, 21 | payload_description 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_gnss.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | supported = Bitfield(1, entries=[ 8 | BitfieldEntry("GPSSup", 0), 9 | BitfieldEntry("GlonassSup", 1), 10 | BitfieldEntry("BeidouSup", 2), 11 | BitfieldEntry("GalileoSup", 3) 12 | ]) 13 | 14 | defaultGnss = Bitfield(1, entries=[ 15 | BitfieldEntry("GPSDef", 0), 16 | BitfieldEntry("GlonassDef", 1), 17 | BitfieldEntry("BeidouDef", 2), 18 | BitfieldEntry("GalileoDef", 3) 19 | ]) 20 | 21 | enabled = Bitfield(1, entries=[ 22 | BitfieldEntry("GPSEna", 0), 23 | BitfieldEntry("GlonassEna", 1), 24 | BitfieldEntry("BeidouEna", 2), 25 | BitfieldEntry("GalileoEna", 3) 26 | ]) 27 | 28 | payload_description = Fields( 29 | ("version", U1), 30 | ("supported", supported), 31 | ("defaultGnss", defaultGnss), 32 | ("enabled", enabled), 33 | ("simultaneous", U1), 34 | ("reserved1", 3*U1), 35 | ) 36 | 37 | description = MessageDescription( 38 | message_class=MON, 39 | message_id=MessageId("GNSS", b"\x28"), 40 | payload_description=Options( 41 | Empty, 42 | payload_description 43 | ) 44 | ) 45 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_hw.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, ( 8 | BitfieldEntry("rtcCalib", 0), 9 | BitfieldEntry("safeBoot", 1), 10 | BitfieldEntry("jammingState", slice(2, 4)), 11 | BitfieldEntry("xtalAbsent", 4), 12 | ) 13 | ) 14 | 15 | payload_description = Fields( 16 | ("pinSel", X4), 17 | ("pinBank", X4), 18 | ("pinDir", X4), 19 | ("pinVal", X4), 20 | ("noisePerMS", U2), 21 | ("agcCnt", U2), 22 | ("aStatus", U1), 23 | ("aPower", U1), 24 | ("flags", flags), 25 | ("reserved1", U1), 26 | ("usedMask", X4), 27 | ("VP", 17*U1), 28 | ("jamInd", U1), 29 | ("reserved2", U2), 30 | ("pinIrq", X4), 31 | ("pullH", X4), 32 | ("pullL", X4) 33 | ) 34 | 35 | description = MessageDescription( 36 | message_class=MON, 37 | message_id=MessageId("HW", b"\x09"), 38 | payload_description=Options( 39 | Empty, 40 | payload_description 41 | ) 42 | ) 43 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_hw2.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("ofsI", I1), 9 | ("magI", U1), 10 | ("ofsQ", I1), 11 | ("magQ", U1), 12 | ("cfgSource", U1), 13 | ("reserved1", 3*U1), 14 | ("lowLevCfg", U4), 15 | ("reserved2", 8*U1), 16 | ("postStatus", U4), 17 | ("reserved3", 4*U1) 18 | ) 19 | 20 | description = MessageDescription( 21 | message_class=MON, 22 | message_id=MessageId("HW2", b"\x0b"), 23 | payload_description=Options( 24 | Empty, 25 | payload_description 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_io.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = MatchedLoop( 8 | Fields( 9 | ("rxBytes", U4), 10 | ("txBytes", U4), 11 | ("parityErrs", U2), 12 | ("framingErrs", U2), 13 | ("overrunErrs", U2), 14 | ("breakCond", U2), 15 | ("rxBusy", U1), 16 | ("txBusy", U1), 17 | ("reserved1", 2*U1) 18 | ) 19 | ) 20 | 21 | description = MessageDescription( 22 | message_class=MON, 23 | message_id=MessageId("IO", b"\x02"), 24 | payload_description=Options( 25 | Empty, 26 | payload_description 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_msgpp.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("msg1", 8*U2), 9 | ("msg2", 8*U2), 10 | ("msg3", 8*U2), 11 | ("msg4", 8*U2), 12 | ("msg5", 8*U2), 13 | ("msg6", 8*U2), 14 | ("skipped", 6*U4) 15 | 16 | ) 17 | 18 | description = MessageDescription( 19 | message_class=MON, 20 | message_id=MessageId("MSGPP", b"\x06"), 21 | payload_description=Options( 22 | Empty, 23 | payload_description 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_patch.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | patchInfo = Bitfield(4, entries=[ 8 | BitfieldEntry("activated", 0), 9 | BitfieldEntry("location", slice(1, 3)) 10 | ]) 11 | 12 | entry = Fields( 13 | ("patchInfo", patchInfo), 14 | ("comparatorNumber", U4), 15 | ("patchAddress", U4), 16 | ("patchData", U4) 17 | ) 18 | 19 | payload_description = Fields( 20 | ("version", U2), 21 | ("nEntries", U2), 22 | ("entries", KeyLoop("nEntries", entry)) 23 | ) 24 | 25 | description = MessageDescription( 26 | message_class=MON, 27 | message_id=MessageId("PATCH", b"\x27"), 28 | payload_description=Options( 29 | Empty, 30 | payload_description 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_rxbuf.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("pending", 6*U2), 9 | ("usage", 6*U1), 10 | ("peakUsage", 6*U1) 11 | ) 12 | 13 | description = MessageDescription( 14 | message_class=MON, 15 | message_id=MessageId("RXBUF", b"\x07"), 16 | payload_description=Options( 17 | Empty, 18 | payload_description 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_rxr.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("awake", 0) 9 | ]) 10 | 11 | payload_description = Fields( 12 | ("flags", flags), 13 | ) 14 | 15 | description = MessageDescription( 16 | message_class=MON, 17 | message_id=MessageId("RXR", b"\x21"), 18 | payload_description=Options( 19 | Empty, 20 | payload_description 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_smgr.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | intOsc = Bitfield(2, entries=[ 8 | BitfieldEntry("intOscState", slice(0, 4)), 9 | BitfieldEntry("intOscCalib", 4), 10 | BitfieldEntry("intOscDisc", 5) 11 | ]) 12 | 13 | extOsc = Bitfield(2, entries=[ 14 | BitfieldEntry("extOscState", slice(0, 4)), 15 | BitfieldEntry("extOscCalib", 4), 16 | BitfieldEntry("extOscDisc", 5) 17 | ]) 18 | 19 | gnss = Bitfield(1, entries=[ 20 | BitfieldEntry("gnssAvail", 0) 21 | ]) 22 | 23 | extInt0 = Bitfield(1, entries=[ 24 | BitfieldEntry("extInt0Avail", 0), 25 | BitfieldEntry("extInt0Type", 1), 26 | BitfieldEntry("extInt0FeedBack", 2) 27 | ]) 28 | 29 | extInt1 = Bitfield(1, entries=[ 30 | BitfieldEntry("extInt1Avail", 0), 31 | BitfieldEntry("extInt1Type", 1), 32 | BitfieldEntry("extInt1FeedBack", 2) 33 | ]) 34 | 35 | payload_description = Fields( 36 | ("version", U1), 37 | ("reserved1", 3*U1), 38 | ("iTOW", U4), 39 | ("intOsc", intOsc), 40 | ("extOsc", extOsc), 41 | ("discSrc", U1), 42 | ("gnss", gnss), 43 | ("extInt0", extInt0), 44 | ("extInt1", extInt1) 45 | ) 46 | 47 | description = MessageDescription( 48 | message_class=MON, 49 | message_id=MessageId("SMGR", b"\x2e"), 50 | payload_description=Options( 51 | Empty, 52 | payload_description 53 | ) 54 | ) 55 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_txbuf.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | errors = Bitfield(1, entries=[ 8 | BitfieldEntry("limit", slice(0, 6)), 9 | BitfieldEntry("mem", 6), 10 | BitfieldEntry("alloc", 7) 11 | ]) 12 | 13 | payload_description = Fields( 14 | ("pending", 6*U2), 15 | ("usage", 6*U1), 16 | ("peakUsage", 6*U1), 17 | ("tUsage", U1), 18 | ("tPeakusage", U1), 19 | ("errors", errors), 20 | ("reserved1", U1) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=MON, 25 | message_id=MessageId("TXBUF", b"\x08"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/mon_ver.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | errors = Bitfield(1, entries=[ 8 | BitfieldEntry("limit", slice(0, 6)), 9 | BitfieldEntry("mem", 6), 10 | BitfieldEntry("alloc", 7) 11 | ]) 12 | 13 | payload_description = Fields( 14 | ("swVersion", Chars(30)), 15 | ("hwVersion", Chars(10)), 16 | ("extension", MatchedLoop(Chars(30))) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=MON, 21 | message_id=MessageId("VER", b"\x04"), 22 | payload_description=Options( 23 | Empty, 24 | payload_description 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_aopstatus.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | aopCfg = Bitfield(1, entries=[ 8 | BitfieldEntry("useAOP", 0) 9 | ]) 10 | 11 | payload_description0 = Fields( 12 | ("iTOW", U4), 13 | ("aopCfg", aopCfg), 14 | ("status", U1), 15 | ("reserved1", 10*U1) 16 | ) 17 | 18 | description = MessageDescription( 19 | message_class=NAV, 20 | message_id=MessageId("AOPSTATUS", b"\x60"), 21 | payload_description=Options( 22 | Empty, 23 | payload_description0, 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_att.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("version", U1), 10 | ("reserved1", 3*U1), 11 | ("roll", I4), 12 | ("pitch", I4), 13 | ("heading", I4), 14 | ("accRoll", U4), 15 | ("accPitch", U4), 16 | ("accHeading", U4), 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=NAV, 21 | message_id=MessageId("ATT", b"\x05"), 22 | payload_description=Options( 23 | Empty, 24 | payload_description0, 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_clock.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("clkB", I4), 10 | ("clkD", I4), 11 | ("tAcc", U4), 12 | ("fAcc", U4) 13 | ) 14 | 15 | description = MessageDescription( 16 | message_class=NAV, 17 | message_id=MessageId("CLOCK", b"\x22"), 18 | payload_description=Options( 19 | Empty, 20 | payload_description0, 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_dgps.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("channel", slice(0, 4)), 9 | BitfieldEntry("dgpsUsed", 4) 10 | ]) 11 | 12 | ch = Fields( 13 | ("svid", U1), 14 | ("flags", flags), 15 | ("ageC", U2), 16 | ("prc", R4), 17 | ("prrc", R4) 18 | ) 19 | 20 | payload_description0 = Fields( 21 | ("iTOW", U4), 22 | ("age", I4), 23 | ("baseId", I2), 24 | ("baseHealth", I2), 25 | ("numCh", U1), 26 | ("status", U1), 27 | ("reserved1", 2*U1), 28 | ("chs", KeyLoop("numCh", ch)) 29 | ) 30 | 31 | description = MessageDescription( 32 | message_class=NAV, 33 | message_id=MessageId("DGPS", b"\x31"), 34 | payload_description=Options( 35 | Empty, 36 | payload_description0, 37 | ) 38 | ) 39 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_dop.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("gDOP", U2), 10 | ("pDOP", U2), 11 | ("tDOP", U2), 12 | ("vDOP", U2), 13 | ("hDOP", U2), 14 | ("nDOP", U2), 15 | ("eDOP", U2), 16 | ) 17 | 18 | description = MessageDescription( 19 | message_class=NAV, 20 | message_id=MessageId("DOP", b"\x04"), 21 | payload_description=Options( 22 | Empty, 23 | payload_description0, 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_eoe.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ) 10 | 11 | description = MessageDescription( 12 | message_class=NAV, 13 | message_id=MessageId("EOE", b"\x61"), 14 | payload_description=Options( 15 | Empty, 16 | payload_description0, 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_geofence.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | fence = Fields( 8 | ("state", U1), 9 | ("reserved1", U1) 10 | ) 11 | 12 | payload_description0 = Fields( 13 | ("iTOW", U4), 14 | ("version", U1), 15 | ("status", U1), 16 | ("numFences", U1), 17 | ("combState", U1), 18 | ("fences", KeyLoop("numFences", fence)) 19 | ) 20 | 21 | description = MessageDescription( 22 | message_class=NAV, 23 | message_id=MessageId("GEOFENCE", b"\x39"), 24 | payload_description=Options( 25 | Empty, 26 | payload_description0, 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_hpposecef.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("iTOW", U4), 11 | ("ecefX", I4), 12 | ("ecefY", I4), 13 | ("ecefZ", I4), 14 | ("ecefXHp", I1), 15 | ("ecefYHp", I1), 16 | ("ecefZHp", I1), 17 | ("reserved2", U1), 18 | ("pAcc", U4) 19 | ) 20 | 21 | description = MessageDescription( 22 | message_class=NAV, 23 | message_id=MessageId("HPPOSECEF", b"\x13"), 24 | payload_description=Options( 25 | Empty, 26 | payload_description0, 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_hpposllh.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("iTOW", U4), 11 | ("lon", I4), 12 | ("lat", I4), 13 | ("height", I4), 14 | ("hMSL", I4), 15 | ("lonHp", I1), 16 | ("latHp", I1), 17 | ("heightHp", I1), 18 | ("hMSLHp", I1), 19 | ("hAcc", U4), 20 | ("vAcc", U4) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=NAV, 25 | message_id=MessageId("HPPOSLLH", b"\x14"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description0, 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_odo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("iTOW", U4), 11 | ("distance", U4), 12 | ("totalDistance", U4), 13 | ("distanceStd", U4) 14 | ) 15 | 16 | description = MessageDescription( 17 | message_class=NAV, 18 | message_id=MessageId("ODO", b"\x09"), 19 | payload_description=Options( 20 | Empty, 21 | payload_description0, 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_orb.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | svFlag = Bitfield(1, entries=[ 8 | BitfieldEntry("health", slice(0, 2)), 9 | BitfieldEntry("visibility", slice(2, 4)) 10 | ]) 11 | 12 | eph = Bitfield(1, entries=[ 13 | BitfieldEntry("ephUsability", slice(0, 5)), 14 | BitfieldEntry("ephSource", slice(5, 8)) 15 | ]) 16 | 17 | alm = Bitfield(1, entries=[ 18 | BitfieldEntry("almUsability", slice(0, 5)), 19 | BitfieldEntry("almSource", slice(5, 8)) 20 | ]) 21 | 22 | otherOrb = Bitfield(1, entries=[ 23 | BitfieldEntry("anoAopUsability", slice(0, 5)), 24 | BitfieldEntry("type", slice(5, 8)) 25 | ]) 26 | 27 | sv = Fields( 28 | ("gnssId", U1), 29 | ("svId", U1), 30 | ("svFlag", svFlag), 31 | ("eph", eph), 32 | ("alm", alm), 33 | ("otherOrb", otherOrb) 34 | ) 35 | 36 | payload_description0 = Fields( 37 | ("iTOW", U4), 38 | ("version", U1), 39 | ("numSv", U1), 40 | ("reserved1", 2*U1), 41 | ("svs", KeyLoop("numSv", sv)) 42 | ) 43 | 44 | description = MessageDescription( 45 | message_class=NAV, 46 | message_id=MessageId("ORB", b"\x34"), 47 | payload_description=Options( 48 | Empty, 49 | payload_description0, 50 | ) 51 | ) 52 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_posecef.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("ecefX", I4), 10 | ("ecefY", I4), 11 | ("ecefZ", I4), 12 | ("pAcc", U4) 13 | ) 14 | 15 | description = MessageDescription( 16 | message_class=NAV, 17 | message_id=MessageId("POSECEF", b"\x01"), 18 | payload_description=Options( 19 | Empty, 20 | payload_description0, 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_posllh.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("lon", I4), 10 | ("lat", I4), 11 | ("height", I4), 12 | ("hMSL", I4), 13 | ("hAcc", U4), 14 | ("vAcc", U4) 15 | ) 16 | 17 | description = MessageDescription( 18 | message_class=NAV, 19 | message_id=MessageId("POSLLH", b"\x02"), 20 | payload_description=Options( 21 | Empty, 22 | payload_description0, 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_pvt.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("validDate", 0), 9 | BitfieldEntry("validTime", 1), 10 | BitfieldEntry("fullyResolved", 2), 11 | BitfieldEntry("validMag", 3), 12 | ]) 13 | 14 | flags = Bitfield(1, entries=[ 15 | BitfieldEntry("gnssFixOK", 0), 16 | BitfieldEntry("diffSoln", 1), 17 | BitfieldEntry("psmState", slice(2, 5)), 18 | BitfieldEntry("headVehValid", 5), 19 | BitfieldEntry("carrSoln", slice(6, 8)), 20 | ]) 21 | 22 | flags2 = Bitfield(1, entries=[ 23 | BitfieldEntry("confirmedAvai", 5), 24 | BitfieldEntry("confirmedDate", 6), 25 | BitfieldEntry("confirmedTime", 7), 26 | ]) 27 | 28 | payload_description0 = Fields( 29 | ("iTOW", U4), 30 | ("year", U2), 31 | ("month", U1), 32 | ("day", U1), 33 | ("hour", U1), 34 | ("min", U1), 35 | ("sec", U1), 36 | ("valid", valid), 37 | ("tAcc", U4), 38 | ("nano", I4), 39 | ("fixType", U1), 40 | ("flags", flags), 41 | ("flags2", flags2), 42 | ("numSV", U1), 43 | ("lon", I4), 44 | ("lat", I4), 45 | ("height", I4), 46 | ("hMSL", I4), 47 | ("hAcc", U4), 48 | ("vAcc", U4), 49 | ("velN", I4), 50 | ("velE", I4), 51 | ("velD", I4), 52 | ("gSpeed", I4), 53 | ("headMot", I4), 54 | ("sAcc", U4), 55 | ("headAcc", U4), 56 | ("pDOP", U2), 57 | ("reserved1", 6*U1), 58 | ("headVeh", I4), 59 | ("magDec", I2), 60 | ("magAcc", U2) 61 | ) 62 | 63 | description = MessageDescription( 64 | message_class=NAV, 65 | message_id=MessageId("PVT", b"\x07"), 66 | payload_description=Options( 67 | Empty, 68 | payload_description0, 69 | ) 70 | ) 71 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_relposned.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(4, entries=[ 8 | BitfieldEntry("gnssFixOK", 0), 9 | BitfieldEntry("diffSoln", 1), 10 | BitfieldEntry("relPosValid", 2), 11 | BitfieldEntry("carrSoln", slice(3, 5)), 12 | BitfieldEntry("isMoving", 5), 13 | BitfieldEntry("refPosMiss", 6), 14 | BitfieldEntry("refObsMiss", 7) 15 | ]) 16 | 17 | payload_description0 = Fields( 18 | ("version", U1), 19 | ("reserved1", U1), 20 | ("refStationId", U2), 21 | ("iTOW", U4), 22 | ("relPosN", I4), 23 | ("relPosE", I4), 24 | ("relPosD", I4), 25 | ("relPosHPN", I1), 26 | ("relPosHPE", I1), 27 | ("relPosHPD", I1), 28 | ("reserved2", U1), 29 | ("accN", U4), 30 | ("accE", U4), 31 | ("accD", U4), 32 | ("flags", flags) 33 | ) 34 | 35 | description = MessageDescription( 36 | message_class=NAV, 37 | message_id=MessageId("RELPOSNED", b"\x3c"), 38 | payload_description=Options( 39 | Empty, 40 | payload_description0, 41 | ) 42 | ) 43 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_resetodo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | description = MessageDescription( 8 | message_class=NAV, 9 | message_id=MessageId("RESETODO", b"\x10"), 10 | payload_description=Options( 11 | Empty 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_sat.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(4, ( 8 | BitfieldEntry("qualityInd", slice(0, 3)), 9 | BitfieldEntry("svUsed", 3), 10 | BitfieldEntry("health", slice(4, 6)), 11 | BitfieldEntry("diffCor", 6), 12 | BitfieldEntry("smoothed", 7), 13 | BitfieldEntry("orbitSource", slice(8, 11)), 14 | BitfieldEntry("ephAvail", 11), 15 | BitfieldEntry("almAvail", 12), 16 | BitfieldEntry("anoAvail", 13), 17 | BitfieldEntry("aopAvail", 14), 18 | BitfieldEntry("sbasCorrUsed", 16), 19 | BitfieldEntry("rtcmCorrUsed", 17), 20 | BitfieldEntry("prCorrUsed", 20), 21 | BitfieldEntry("crCorrUsed", 21), 22 | BitfieldEntry("doCorrUsed", 22), 23 | ) 24 | ) 25 | 26 | svs_fields = Fields( 27 | ("gnssId", U1), 28 | ("svId", U1), 29 | ("cno", U1), 30 | ("elev", I1), 31 | ("azim", I2), 32 | ("prRes", I2), 33 | ("flags", flags), 34 | ) 35 | 36 | payload_description = Fields( 37 | ("iTOW", U4), 38 | ("version", U1), 39 | ("numSvs", U1), 40 | ("reserved1", 2*U1), 41 | ("meas", KeyLoop("numSvs", svs_fields)) 42 | ) 43 | 44 | description = MessageDescription( 45 | message_class=NAV, 46 | message_id=MessageId("SAT", b"\x35"), 47 | payload_description=Options( 48 | Empty, 49 | payload_description 50 | ) 51 | ) 52 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_sbas.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | service = Bitfield(1, entries=[ 8 | BitfieldEntry("Ranging", 0), 9 | BitfieldEntry("Corrections", 1), 10 | BitfieldEntry("Integrity", 2), 11 | BitfieldEntry("Testmode", 3), 12 | ]) 13 | 14 | svs_fields = Fields( 15 | ("svid", U1), 16 | ("flags", U1), 17 | ("udre", U1), 18 | ("svSys", U1), 19 | ("svService", U1), 20 | ("reserved2", U1), 21 | ("prc", I2), 22 | ("reserved3", 2*U1), 23 | ("ic", I2), 24 | ) 25 | 26 | payload_description = Fields( 27 | ("iTOW", U4), 28 | ("geo", U1), 29 | ("mode", U1), 30 | ("sys", I1), 31 | ("service", service), 32 | ("cnt", U1), 33 | ("reserved1", 3*U1), 34 | ("svs", KeyLoop("cnt", svs_fields)) 35 | ) 36 | 37 | description = MessageDescription( 38 | message_class=NAV, 39 | message_id=MessageId("SBAS", b"\x32"), 40 | payload_description=Options( 41 | Empty, 42 | payload_description 43 | ) 44 | ) 45 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_sol.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("gnssFixOK", 0), 9 | BitfieldEntry("diffSoln", 1), 10 | BitfieldEntry("WKNSET", 2), 11 | BitfieldEntry("TOWSET", 3) 12 | ]) 13 | 14 | payload_description0 = Fields( 15 | ("iTOW", U4), 16 | ("fTOW", I4), 17 | ("week", I2), 18 | ("gpsFix", U1), 19 | ("flags", flags), 20 | ("ecefX", I4), 21 | ("ecefY", I4), 22 | ("ecefZ", I4), 23 | ("pAcc", U4), 24 | ("ecefVX", I4), 25 | ("ecefVY", I4), 26 | ("ecefVZ", I4), 27 | ("sAcc", U4), 28 | ("pDOP", U2), 29 | ("reserved1", U1), 30 | ("numSv", U1), 31 | ("reserved2", 4*U1) 32 | ) 33 | 34 | description = MessageDescription( 35 | message_class=NAV, 36 | message_id=MessageId("SOL", b"\x06"), 37 | payload_description=Options( 38 | Empty, 39 | payload_description0, 40 | ) 41 | ) 42 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_status.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, ( 8 | BitfieldEntry("gpsFixOk", 0), 9 | BitfieldEntry("diffSoln", 1), 10 | BitfieldEntry("wknSet", 2), 11 | BitfieldEntry("towSet", 3), 12 | BitfieldEntry("reserved", slice(4, 8)) 13 | ) 14 | ) 15 | 16 | fixStat = Bitfield(1, ( 17 | BitfieldEntry("diffCor", 0), 18 | BitfieldEntry("mapMatching", slice(6, 8)) 19 | ) 20 | ) 21 | 22 | flags2 = Bitfield(1, ( 23 | BitfieldEntry("psmState", slice(0, 2)), 24 | BitfieldEntry("spoofDetState", slice(3, 5)), 25 | ) 26 | ) 27 | 28 | payload_description0 = Fields( 29 | ("iTOW", U4), 30 | ("gpsFix", U1), 31 | ("flags", flags), 32 | ("fixStat", fixStat), 33 | ("flags2", flags2), 34 | ("ttff", U4), 35 | ("msss", U4), 36 | ) 37 | 38 | description = MessageDescription( 39 | message_class=NAV, 40 | message_id=MessageId("STATUS", b"\x03"), 41 | payload_description=Options( 42 | Empty, 43 | payload_description0, 44 | ) 45 | ) 46 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_svin.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("iTOW", U4), 11 | ("dur", U4), 12 | ("meanX", I4), 13 | ("meanY", I4), 14 | ("meanZ", I4), 15 | ("meanXHP", I1), 16 | ("meanYHP", I1), 17 | ("meanZHP", I1), 18 | ("reserved2", U1), 19 | ("meanAcc", U4), 20 | ("obs", U4), 21 | ("valid", U1), 22 | ("active", U1), 23 | ("reserved3", 2*U1) 24 | ) 25 | 26 | description = MessageDescription( 27 | message_class=NAV, 28 | message_id=MessageId("SVIN", b"\x3b"), 29 | payload_description=Options( 30 | Empty, 31 | payload_description0, 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_svinfo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | globalFlags = Bitfield(1, ( 8 | BitfieldEntry("chipGen", slice(0, 3)), 9 | ) 10 | ) 11 | 12 | flags = Bitfield(1, ( 13 | BitfieldEntry("svUsed", 0), 14 | BitfieldEntry("diffCorr", 1), 15 | BitfieldEntry("orbitAvail", 2), 16 | BitfieldEntry("orbitEph", 3), 17 | BitfieldEntry("unhealthy", 4), 18 | BitfieldEntry("orbitAlm", 5), 19 | BitfieldEntry("orbitAop", 6), 20 | BitfieldEntry("smoothed", 7), 21 | ) 22 | ) 23 | 24 | quality = Bitfield(1, ( 25 | BitfieldEntry("qualityInd", slice(0, 4)), 26 | ) 27 | ) 28 | 29 | chn_fields = Fields( 30 | ("chn", U1), 31 | ("svid", U1), 32 | ("flags", flags), 33 | ("quality", quality), 34 | ("cno", U1), 35 | ("elev", I1), 36 | ("azim", I2), 37 | ("prRes", I4) 38 | ) 39 | 40 | payload_description0 = Fields( 41 | ("iTOW", U4), 42 | ("numCh", U1), 43 | ("globalFlags", globalFlags), 44 | ("reserved1", 2*U1), 45 | ("ch", KeyLoop("numCh", chn_fields)), 46 | ) 47 | 48 | description = MessageDescription( 49 | message_class=NAV, 50 | message_id=MessageId("SVINFO", b"\x30"), 51 | payload_description=Options( 52 | Empty, 53 | payload_description0, 54 | ) 55 | ) 56 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timedbs.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("sowValid", 0), 9 | BitfieldEntry("weekValid", 1), 10 | BitfieldEntry("leapSValid", 2), 11 | ]) 12 | 13 | payload_description0 = Fields( 14 | ("iTOW", U4), 15 | ("SOW", U4), 16 | ("fSOW", I4), 17 | ("week", I2), 18 | ("leapS", I1), 19 | ("valid", valid), 20 | ("tAcc", U4) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=NAV, 25 | message_id=MessageId("TIMEDBS", b"\x24"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description0, 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timegal.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("galTowValid", 0), 9 | BitfieldEntry("galWnoValid", 1), 10 | BitfieldEntry("leapSValid", 2), 11 | ]) 12 | 13 | payload_description0 = Fields( 14 | ("iTOW", U4), 15 | ("galTow", U4), 16 | ("fGalTow", I4), 17 | ("galWno", I2), 18 | ("leapS", I1), 19 | ("valid", valid), 20 | ("tAcc", U4) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=NAV, 25 | message_id=MessageId("TIMEGAL", b"\x25"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description0, 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timeglo.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("todValid", 0), 9 | BitfieldEntry("dateValid", 1), 10 | ]) 11 | 12 | payload_description0 = Fields( 13 | ("iTOW", U4), 14 | ("TOD", U4), 15 | ("fTOD", I4), 16 | ("Nt", U2), 17 | ("N4", U1), 18 | ("valid", valid), 19 | ("tAcc", U4) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=NAV, 24 | message_id=MessageId("TIMEGLO", b"\x23"), 25 | payload_description=Options( 26 | Empty, 27 | payload_description0, 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timegps.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("towValid", 0), 9 | BitfieldEntry("weekValid", 1), 10 | BitfieldEntry("leapSValid", 2), 11 | ]) 12 | 13 | payload_description0 = Fields( 14 | ("iTOW", U4), 15 | ("fTOW", I4), 16 | ("week", I2), 17 | ("leapS", I1), 18 | ("valid", valid), 19 | ("tAcc", U4) 20 | ) 21 | 22 | description = MessageDescription( 23 | message_class=NAV, 24 | message_id=MessageId("TIMEGPS", b"\x20"), 25 | payload_description=Options( 26 | Empty, 27 | payload_description0, 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timels.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("validCurrLs", 0), 9 | BitfieldEntry("validTimeToLsEvent", 1), 10 | ]) 11 | 12 | payload_description0 = Fields( 13 | ("iTOW", U4), 14 | ("version", U1), 15 | ("reserved1", 3*U1), 16 | ("srcOfCurrLs", U1), 17 | ("currLs", I1), 18 | ("srcOfLsChange", U1), 19 | ("lsChange", I1), 20 | ("timeToLsEvent", I4), 21 | ("dateOfLsGpsWn", U2), 22 | ("dateOfLsGpsDn", U2), 23 | ("reserved2", 3*U1), 24 | ("valid", valid), 25 | ) 26 | 27 | description = MessageDescription( 28 | message_class=NAV, 29 | message_id=MessageId("TIMELS", b"\x26"), 30 | payload_description=Options( 31 | Empty, 32 | payload_description0, 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_timeutc.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | valid = Bitfield(1, entries=[ 8 | BitfieldEntry("validTOW", 0), 9 | BitfieldEntry("validWKN", 1), 10 | BitfieldEntry("validUTC", 1), 11 | BitfieldEntry("utcStandard", slice(4, 8)) 12 | ]) 13 | 14 | payload_description0 = Fields( 15 | ("iTOW", U4), 16 | ("tAcc", U4), 17 | ("nano", I4), 18 | ("year", U2), 19 | ("month", U1), 20 | ("day", U1), 21 | ("hour", U1), 22 | ("min", U1), 23 | ("sec", U1), 24 | ("valid", valid), 25 | ) 26 | 27 | description = MessageDescription( 28 | message_class=NAV, 29 | message_id=MessageId("TIMEUTC", b"\x21"), 30 | payload_description=Options( 31 | Empty, 32 | payload_description0, 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_velecef.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("ecefVX", I4), 10 | ("ecefVY", I4), 11 | ("ecefVZ", I4), 12 | ("sAcc", U4) 13 | ) 14 | 15 | description = MessageDescription( 16 | message_class=NAV, 17 | message_id=MessageId("VELECEF", b"\x11"), 18 | payload_description=Options( 19 | Empty, 20 | payload_description0, 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /ubx/descriptions/nav_velned.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("iTOW", U4), 9 | ("velN", I4), 10 | ("velE", I4), 11 | ("velD", I4), 12 | ("speed", U4), 13 | ("gSpeed", U4), 14 | ("heading", I4), 15 | ("sAcc", U4), 16 | ("cAcc", U4) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=NAV, 21 | message_id=MessageId("VELNED", b"\x12"), 22 | payload_description=Options( 23 | Empty, 24 | payload_description0, 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_imes.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | position1_1 = Bitfield(4, [ 8 | BitfieldEntry("pos1Floor", slice(0, 8)), 9 | BitfieldEntry("pos1Lat", slice(8, 31)) 10 | ]) 11 | 12 | position1_2 = Bitfield(4, [ 13 | BitfieldEntry("pos1Lon", slice(0, 24)), 14 | BitfieldEntry("pos1Valid", 24) 15 | ]) 16 | 17 | position2_1 = Bitfield(4, [ 18 | BitfieldEntry("pos2Floor", slice(0, 9)), 19 | BitfieldEntry("pos2Alt", slice(9, 21)), 20 | BitfieldEntry("pos2Acc", slice(21, 23)), 21 | BitfieldEntry("pos1Valid", 23) 22 | ]) 23 | 24 | shortIdFrame = Bitfield(4, [ 25 | BitfieldEntry("shortId", slice(0, 12)), 26 | BitfieldEntry("shortValid", 12), 27 | BitfieldEntry("shortBoundary", 13) 28 | ]) 29 | 30 | mediumId_2 = Bitfield(4, [ 31 | BitfieldEntry("mediumIdMSB", 0), 32 | BitfieldEntry("mediumValid", 1), 33 | BitfieldEntry("mediumboundary", 2) 34 | ]) 35 | 36 | tx = Fields( 37 | ("reserved2", U1), 38 | ("txId", U1), 39 | ("reserved3", 3*U1), 40 | ("cno", U1), 41 | ("reserved4", 2*U1), 42 | ("doppler", I4), 43 | ("position1_1", position1_1), 44 | ("position1_2", position1_2), 45 | ("position2_1", position2_1), 46 | ("lat", I4), 47 | ("lon", I4), 48 | ("shortIdFrame", shortIdFrame), 49 | ("mediumIdLSB", U4), 50 | ("mediumId_2", mediumId_2) 51 | ) 52 | 53 | payload_description0 = Fields( 54 | ("numTx", U1), 55 | ("version", U1), 56 | ("resreved1", 2*U1), 57 | ("txs", KeyLoop("numTx", tx)) 58 | ) 59 | 60 | description = MessageDescription( 61 | message_class=RXM, 62 | message_id=MessageId("IMES", b"\x61"), 63 | payload_description=Options( 64 | Empty, 65 | payload_description0, 66 | ) 67 | ) 68 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_measx.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, [ 8 | BitfieldEntry("towSet", slice(0, 2)) 9 | ]) 10 | 11 | sv = Fields( 12 | ("gnssId", U1), 13 | ("svId", U1), 14 | ("cNo", U1), 15 | ("mpathIndic", U1), 16 | ("dopplerMS", I4), 17 | ("dopplerHz", I4), 18 | ("wholeChips", U2), 19 | ("fracChips", U2), 20 | ("codePhase", U4), 21 | ("intCodePhase", U1), 22 | ("pseuRangeRMSErr", U1), 23 | ("reserved5", 2*U1) 24 | ) 25 | 26 | payload_description0 = Fields( 27 | ("version", U1), 28 | ("reserved1", 3*U1), 29 | ("gpsTOW", U4), 30 | ("gloTOW", U4), 31 | ("bdsTOW", U4), 32 | ("reserved2", 4*U1), 33 | ("qzssTOW", U4), 34 | ("gpsTOWacc", U2), 35 | ("gloTOWacc", U2), 36 | ("bdsTOWacc", U2), 37 | ("reserved3", 2*U1), 38 | ("qzssTOWacc", U2), 39 | ("numSV", U1), 40 | ("flags", flags), 41 | ("reserved4", 8*U1), 42 | ("svs", KeyLoop("numSV", sv)) 43 | ) 44 | 45 | description = MessageDescription( 46 | message_class=RXM, 47 | message_id=MessageId("MEASX", b"\x14"), 48 | payload_description=Options( 49 | Empty, 50 | payload_description0, 51 | ) 52 | ) 53 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_pmreq.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags_0 = Bitfield(4, [ 8 | BitfieldEntry("backup", 1) 9 | ]) 10 | 11 | payload_description0 = Fields( 12 | ("duration", U4), 13 | ("flags", flags_0), 14 | ) 15 | 16 | 17 | flags_1 = Bitfield(4, [ 18 | BitfieldEntry("backup", 1), 19 | BitfieldEntry("force", 2) 20 | ]) 21 | 22 | wakeupSources = Bitfield(4, [ 23 | BitfieldEntry("uartrx", 3), 24 | BitfieldEntry("extint0", 5), 25 | BitfieldEntry("extint1", 6), 26 | BitfieldEntry("spics", 7) 27 | ]) 28 | 29 | payload_description1 = Fields( 30 | ("version", U1), 31 | ("reserved1", 3*U1), 32 | ("duration", U4), 33 | ("flags", flags_1), 34 | ("wakeupSources", wakeupSources) 35 | ) 36 | 37 | description = MessageDescription( 38 | message_class=RXM, 39 | message_id=MessageId("PMREQ", b"\x41"), 40 | payload_description=Options( 41 | Empty, 42 | payload_description0, 43 | payload_description1 44 | ) 45 | ) 46 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_rawx.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | recStat = Bitfield(1, ( 8 | BitfieldEntry("leapSec", 0), 9 | BitfieldEntry("clkReset", 1), 10 | ) 11 | ) 12 | 13 | prStdev = Bitfield(1, ( 14 | BitfieldEntry("prStd", slice(0, 4)), 15 | ) 16 | ) 17 | 18 | cpStdev = Bitfield(1, ( 19 | BitfieldEntry("cpStd", slice(0, 4)), 20 | ) 21 | ) 22 | 23 | doStdev = Bitfield(1, ( 24 | BitfieldEntry("doStd", slice(0, 4)), 25 | ) 26 | ) 27 | 28 | trkStat = Bitfield(1, ( 29 | BitfieldEntry("prValid", 0), 30 | BitfieldEntry("cpValid", 1), 31 | BitfieldEntry("halfCyc", 2), 32 | BitfieldEntry("subHalfCyc", 3), 33 | ) 34 | ) 35 | 36 | meas_fields = Fields( 37 | ("prMes", R8), 38 | ("cpMes", R8), 39 | ("doMes", R4), 40 | ("gnssId", U1), 41 | ("svId", U1), 42 | ("reserved2", U1), 43 | ("freqId", U1), 44 | ("locktime", U2), 45 | ("cno", U1), 46 | ("prStdev", prStdev), 47 | ("cpStdev", cpStdev), 48 | ("doStdev", doStdev), 49 | ("trkStat", trkStat), 50 | ("reserved3", U1) 51 | ) 52 | 53 | payload_description = Fields( 54 | ("rcvTow", R8), 55 | ("week", U2), 56 | ("leapS", I1), 57 | ("numMeas", U1), 58 | ("recStat", recStat), 59 | ("version", U1), 60 | ("reserved1", 2*U1), 61 | ("meas", KeyLoop("numMeas", meas_fields)) 62 | ) 63 | 64 | description = MessageDescription( 65 | message_class=RXM, 66 | message_id=MessageId("RAWX", b"\x15"), 67 | payload_description=Options( 68 | Empty, 69 | payload_description, 70 | ) 71 | ) 72 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_rlm.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("version", U1), 9 | ("type", U1), 10 | ("svId", U1), 11 | ("reserved1", U1), 12 | ("beacon", 8*U1), 13 | ("message", U1), 14 | ("params", 2*U1), 15 | ("reserved2", U1) 16 | ) 17 | 18 | payload_description1 = Fields( 19 | ("version", U1), 20 | ("type", U1), 21 | ("svId", U1), 22 | ("reserved1", U1), 23 | ("beacon", 8*U1), 24 | ("message", U1), 25 | ("params", 12*U1), 26 | ("reserved2", 3*U1) 27 | ) 28 | 29 | description = MessageDescription( 30 | message_class=RXM, 31 | message_id=MessageId("RLM", b"\x59"), 32 | payload_description=Options( 33 | Empty, 34 | payload_description0, 35 | payload_description1 36 | ) 37 | ) 38 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_rtcm.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("crcFailed", 0) 9 | ]) 10 | 11 | payload_description0 = Fields( 12 | ("version", U1), 13 | ("flags", flags), 14 | ("reserved1", 2*U1), 15 | ("refStation", U2), 16 | ("msgType", U2) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=RXM, 21 | message_id=MessageId("RTCM", b"\x32"), 22 | payload_description=Options( 23 | payload_description0 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_sfrbx.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | words_fields = Fields( 8 | ("dwrd", U4) 9 | ) 10 | 11 | payload_description = Fields( 12 | ("gnssId", U1), 13 | ("svId", U1), 14 | ("reserved1", U1), 15 | ("freqId", U1), 16 | ("numWords", U1), 17 | ("chn", U1), 18 | ("version", U1), 19 | ("reserved2", U1), 20 | ("meas", KeyLoop("numWords", words_fields)) 21 | ) 22 | 23 | description = MessageDescription( 24 | message_class=RXM, 25 | message_id=MessageId("SFRBX", b"\x13"), 26 | payload_description=Options( 27 | Empty, 28 | payload_description 29 | ) 30 | ) 31 | -------------------------------------------------------------------------------- /ubx/descriptions/rxm_svsi.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | svFlag = Bitfield(1, entries=[ 8 | BitfieldEntry("ura", slice(0, 4)), 9 | BitfieldEntry("healthy", 4), 10 | BitfieldEntry("ephVal", 5), 11 | BitfieldEntry("almVal", 6), 12 | BitfieldEntry("notAvail", 7) 13 | ]) 14 | 15 | age = Bitfield(1, entries=[ 16 | BitfieldEntry("almAge", slice(0, 4)), 17 | BitfieldEntry("ephAge", slice(4, 8)), 18 | ]) 19 | 20 | sv = Fields( 21 | ("svid", U1), 22 | ("svFlag", svFlag), 23 | ("azim", I2), 24 | ("elev", I1), 25 | ("age", age) 26 | ) 27 | 28 | payload_description = Fields( 29 | ("iTOW", U4), 30 | ("week", I2), 31 | ("numVis", U1), 32 | ("numSV", U1), 33 | ("svs", KeyLoop("numSV", sv)) 34 | ) 35 | 36 | description = MessageDescription( 37 | message_class=RXM, 38 | message_id=MessageId("SVSI", b"\x20"), 39 | payload_description=Options( 40 | Empty, 41 | payload_description 42 | ) 43 | ) 44 | -------------------------------------------------------------------------------- /ubx/descriptions/sec_sign.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("classID", U1), 11 | ("messageID", U1), 12 | ("checksum", U2), 13 | ("hash", 32*U1) 14 | ) 15 | 16 | description = MessageDescription( 17 | message_class=SEC, 18 | message_id=MessageId("SIGN", b"\x01"), 19 | payload_description=Options( 20 | payload_description 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /ubx/descriptions/sec_uniqid.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("uniqueID", 5*U1), 11 | ) 12 | 13 | description = MessageDescription( 14 | message_class=SEC, 15 | message_id=MessageId("UNIQID", b"\x03"), 16 | payload_description=Options( 17 | payload_description 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_dosc.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("value", U4) 11 | ) 12 | 13 | description = MessageDescription( 14 | message_class=TIM, 15 | message_id=MessageId("DOSC", b"\x11"), 16 | payload_description=Options( 17 | payload_description 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_fchg.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("version", U1), 9 | ("reserved1", 3*U1), 10 | ("iTOW", U4), 11 | ("intDeltaFreq", I4), 12 | ("intDeltaFreqUnc", U4), 13 | ("intRaw", U4), 14 | ("extDeltaFreq", I4), 15 | ("extDeltaFreqUnc", U4), 16 | ("extRaw", U4) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=TIM, 21 | message_id=MessageId("FCHG", b"\x16"), 22 | payload_description=Options( 23 | Empty, 24 | payload_description 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_hoc.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("raw", 0), 9 | BitfieldEntry("difference", 1) 10 | ]) 11 | 12 | payload_description = Fields( 13 | ("version", U1), 14 | ("oscId", U1), 15 | ("flags", flags), 16 | ("reserved1", U1), 17 | ("value", I4) 18 | ) 19 | 20 | description = MessageDescription( 21 | message_class=TIM, 22 | message_id=MessageId("HOC", b"\x17"), 23 | payload_description=Options( 24 | payload_description 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_smeas.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("freqValid", 0), 9 | BitfieldEntry("phaseValid", 1), 10 | ]) 11 | 12 | meas = Fields( 13 | ("sourceId", U1), 14 | ("flags", flags), 15 | ("phaseOffsetFrac", I1), 16 | ("phaseUncFrac", U1), 17 | ("phaseOffset", I4), 18 | ("phaseUnc", U4), 19 | ("reserved3", 4*U1), 20 | ("freqOffset", I4), 21 | ("freqUnc", U4) 22 | ) 23 | 24 | payload_description = Fields( 25 | ("version", U1), 26 | ("numMeas", U1), 27 | ("reserved1", 2*U1), 28 | ("iTOW", U4), 29 | ("reserved2", 4*U1), 30 | ("meass", KeyLoop("numMeas", meas)) 31 | ) 32 | 33 | description = MessageDescription( 34 | message_class=TIM, 35 | message_id=MessageId("SMEAS", b"\x13"), 36 | payload_description=Options( 37 | Empty, 38 | payload_description 39 | ) 40 | ) 41 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_svin.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description = Fields( 8 | ("dur", U4), 9 | ("meanX", I4), 10 | ("meanY", I4), 11 | ("meanZ", I4), 12 | ("meanV", I4), 13 | ("obs", U4), 14 | ("valid", U1), 15 | ("active", U1), 16 | ("reserved1", 2*U1) 17 | ) 18 | 19 | description = MessageDescription( 20 | message_class=TIM, 21 | message_id=MessageId("SVIN", b"\x04"), 22 | payload_description=Options( 23 | Empty, 24 | payload_description 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_tm2.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("mode", 0), 9 | BitfieldEntry("run", 1), 10 | BitfieldEntry("newFallingEdge", 2), 11 | BitfieldEntry("timeBase", slice(3, 5)), 12 | BitfieldEntry("utc", 5), 13 | BitfieldEntry("time", 6), 14 | BitfieldEntry("newRisingEdge", 7) 15 | ]) 16 | 17 | payload_description = Fields( 18 | ("ch", U1), 19 | ("flags", flags), 20 | ("count", U2), 21 | ("wnR", U2), 22 | ("wnF", U2), 23 | ("towMsR", U4), 24 | ("towSubMsR", U4), 25 | ("towMsF", U4), 26 | ("towSubMsF", U4), 27 | ("accEst", U4) 28 | ) 29 | 30 | description = MessageDescription( 31 | message_class=TIM, 32 | message_id=MessageId("TM2", b"\x03"), 33 | payload_description=Options( 34 | Empty, 35 | payload_description 36 | ) 37 | ) 38 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_tos.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(4, entries=[ 8 | BitfieldEntry("leapNow", 0), 9 | BitfieldEntry("leapSoon", 1), 10 | BitfieldEntry("leapPositive", 2), 11 | BitfieldEntry("timeInLimit", 3), 12 | BitfieldEntry("intOscInLimit", 4), 13 | BitfieldEntry("extOscInLimit", 5), 14 | BitfieldEntry("gnssTimeValid", 6), 15 | BitfieldEntry("UTCTimeValid", 7), 16 | BitfieldEntry("DiscSrc", slice(8, 11)), 17 | BitfieldEntry("raim", 11), 18 | BitfieldEntry("cohPulse", 12), 19 | BitfieldEntry("lockedPulse", 13), 20 | ]) 21 | 22 | payload_description = Fields( 23 | ("version", U1), 24 | ("gnssId", U1), 25 | ("reserved1", 2*U1), 26 | ("flags", flags), 27 | ("year", U2), 28 | ("month", U1), 29 | ("day", U1), 30 | ("hour", U1), 31 | ("minute", U1), 32 | ("second", U1), 33 | ("utcStandard", U1), 34 | ("utcOffset", I4), 35 | ("utcUncertainty", U4), 36 | ("week", U4), 37 | ("TOW", U4), 38 | ("gnssOffset", I4), 39 | ("gnssUncertainty", U4), 40 | ("intOscOffset", I4), 41 | ("intOscUncertainty", U4), 42 | ("extOscOffset", I4), 43 | ("extOscUncertainty", U4) 44 | ) 45 | 46 | description = MessageDescription( 47 | message_class=TIM, 48 | message_id=MessageId("TOS", b"\x12"), 49 | payload_description=Options( 50 | Empty, 51 | payload_description 52 | ) 53 | ) 54 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_tp.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, ( 8 | BitfieldEntry("timeBase", 0), 9 | BitfieldEntry("utc", 1), 10 | BitfieldEntry("raim", slice(2, 4)), 11 | ) 12 | ) 13 | 14 | refInfo = Bitfield(1, ( 15 | BitfieldEntry("timeRefGnss", slice(0, 4)), 16 | BitfieldEntry("utcStandard", slice(4, 8)), 17 | ) 18 | ) 19 | 20 | payload_description = Fields( 21 | ("towMS", U4), 22 | ("towSubMS", U4), 23 | ("qErr", I4), 24 | ("week", U2), 25 | ("flags", flags), 26 | ("refInfo", refInfo) 27 | ) 28 | 29 | description = MessageDescription( 30 | message_class=TIM, 31 | message_id=MessageId("TP", b"\x01"), 32 | payload_description=Options( 33 | Empty, 34 | payload_description 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_vcocal.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | payload_description0 = Fields( 8 | ("type", U1) 9 | ) 10 | 11 | payload_description1 = Fields( 12 | ("type", U1), 13 | ("version", U1), 14 | ("oscId", U1), 15 | ("srcId", U1), 16 | ("reserved1", 2*U1), 17 | ("raw0", U2), 18 | ("raw1", U2), 19 | ("maxStepSize", U2) 20 | ) 21 | 22 | payload_description2 = Fields( 23 | ("type", U1), 24 | ("version", U1), 25 | ("oscId", U1), 26 | ("reserved1", 3*U1), 27 | ("gainUncertainty", U2), 28 | ("gainVco", I4) 29 | ) 30 | 31 | description = MessageDescription( 32 | message_class=TIM, 33 | message_id=MessageId("VCOCAL", b"\x15"), 34 | payload_description=Options( 35 | Empty, 36 | payload_description0, 37 | payload_description1, 38 | payload_description2 39 | ) 40 | ) 41 | -------------------------------------------------------------------------------- /ubx/descriptions/tim_vrfy.py: -------------------------------------------------------------------------------- 1 | from ..message_class import * 2 | from ..message_id import * 3 | from ..payload import * 4 | from ..message import * 5 | 6 | 7 | flags = Bitfield(1, entries=[ 8 | BitfieldEntry("src", slice(0, 3)), 9 | ]) 10 | 11 | payload_description = Fields( 12 | ("itow", I4), 13 | ("frac", I4), 14 | ("deltaMs", I4), 15 | ("deltaNs", I4), 16 | ("wno", U2), 17 | ("flags", flags), 18 | ("reserved1", U1) 19 | ) 20 | 21 | description = MessageDescription( 22 | message_class=TIM, 23 | message_id=MessageId("VRFY", b"\x06"), 24 | payload_description=Options( 25 | Empty, 26 | payload_description 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /ubx/message.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | from . import utils 4 | from . import rawmessage 5 | from .message_class import MessageClass 6 | from .message_id import MessageId 7 | 8 | 9 | class MessageDescription: 10 | def __init__(self, message_class, message_id, payload_description): 11 | assert isinstance(message_class, MessageClass) 12 | assert isinstance(message_id, MessageId) 13 | assert hasattr(payload_description, "parse") 14 | assert hasattr(payload_description, "serialize") 15 | self.message_class = message_class 16 | self.message_id = message_id 17 | self.payload_description = payload_description 18 | 19 | @property 20 | def name(self): 21 | return self.message_class.name + "-" + self.message_id.name 22 | 23 | @property 24 | def key(self): 25 | return self.message_class.byte + self.message_id.byte 26 | 27 | def __str__(self): 28 | template = "MessageDescription:\n"\ 29 | " name = {name}\n"\ 30 | " class = 0x{class}\n"\ 31 | " id = 0x{id}\n"\ 32 | " payload = {payload}" 33 | return template.format(**{ 34 | "name": self.name, 35 | "class": utils.byte2hexstring(self.message_class.byte), 36 | "id": utils.byte2hexstring(self.message_id.byte), 37 | "payload": str(self.payload_description).replace("\n", "\n"+" "*8) 38 | }) 39 | 40 | def parse(self, buffer): 41 | return Message(self, self.payload_description.parse(buffer)) 42 | 43 | def rawmessage(self, content): 44 | return rawmessage.RawMessage(self.message_class.byte, self.message_id.byte, 45 | self.payload_description.serialize(content)) 46 | 47 | def serialize(self, content): 48 | return self.rawmessage(content).serialize() 49 | 50 | 51 | class Message: 52 | def __init__(self, description, content): 53 | self.description = description 54 | self.content = content 55 | 56 | def serialize(self): 57 | return self.description.serialize(self.content) 58 | 59 | @property 60 | def name(self): 61 | return self.description.name 62 | 63 | @property 64 | def message_class(self): 65 | return self.description.message_class 66 | 67 | @property 68 | def message_id(self): 69 | return self.description.message_id 70 | 71 | @property 72 | def key(self): 73 | return self.message_class.byte + self.message_id.byte 74 | 75 | def __str__(self): 76 | template = "Message(name=\"{}\")" 77 | return template.format(self.name) 78 | -------------------------------------------------------------------------------- /ubx/message_class.py: -------------------------------------------------------------------------------- 1 | """UBX message classes.""" 2 | 3 | from . import utils 4 | 5 | 6 | class MessageClass: 7 | """ 8 | Simple class storing the name and byte of a UBX message class. 9 | """ 10 | def __init__(self, name, byte): 11 | if not isinstance(byte, bytes): 12 | raise TypeError("byte argument has to be of type \"byte\" but is: {}".format( 13 | type(byte))) 14 | self.name = name 15 | self.byte = byte 16 | 17 | def __eq__(self, other): 18 | if isinstance(other, MessageClass): 19 | return self.name==other.name and self.byte==other.byte 20 | else: 21 | return NotImplemented 22 | 23 | def __ne__(self, other): 24 | return not self==other 25 | 26 | def __str__(self): 27 | bytestring = utils.byte2hexstring(self.byte) 28 | return "MessageClass(name={}, byte=0x{})".format(self.name, bytestring) 29 | 30 | 31 | classes = [ 32 | MessageClass("NAV", b"\x01"), 33 | MessageClass("RXM", b"\x02"), 34 | MessageClass("INF", b"\x04"), 35 | MessageClass("ACK", b"\x05"), 36 | MessageClass("CFG", b"\x06"), 37 | MessageClass("UPD", b"\x09"), 38 | MessageClass("MON", b"\x0a"), 39 | MessageClass("AID", b"\x0b"), 40 | MessageClass("TIM", b"\x0d"), 41 | MessageClass("ESF", b"\x10"), 42 | MessageClass("MGA", b"\x13"), 43 | MessageClass("LOG", b"\x21"), 44 | MessageClass("SEC", b"\x27"), 45 | MessageClass("HNR", b"\x28"), 46 | ] 47 | """UBX message classes.""" 48 | 49 | 50 | # Insert message classes into module namespace 51 | for message_class in classes: 52 | globals()[message_class.name] = message_class 53 | 54 | 55 | def get_by_name(name): 56 | """Obtain the message class with the given name. 57 | 58 | Raises a ValueError if no message class matches the given name. 59 | """ 60 | for message_class in classes: 61 | if message_class.name==name: 62 | return message_class 63 | raise ValueError("Unknown MessageClass of name \"{}\".".format(name)) 64 | 65 | 66 | def get_by_byte(byte): 67 | """Obtain the message class with the given byte. 68 | 69 | Raises a ValueError if no message class matches the given byte. 70 | """ 71 | if not isinstance(byte, bytes): 72 | raise TypeError("Expected byte argument to be of type \"bytes\" but it is \"{}\".".format(type(byte))) 73 | for message_class in classes: 74 | if message_class.byte==byte: 75 | return message_class 76 | raise ValueError("Unknown MessageClass with byte \"0x{}\".".format(utils.byte2hexstring(byte))) 77 | -------------------------------------------------------------------------------- /ubx/message_id.py: -------------------------------------------------------------------------------- 1 | """UBX message ids""" 2 | 3 | from . import utils 4 | 5 | 6 | class MessageId: 7 | """ 8 | Simple class storing the name and byte of a UBX message id. 9 | """ 10 | def __init__(self, name, byte, subname=None): 11 | if not isinstance(byte, bytes): 12 | raise TypeError("byte argument has to be of type \"byte\" but is: {}".format( 13 | type(byte))) 14 | self.name = name 15 | self.subname = subname 16 | self.byte = byte 17 | 18 | def __eq__(self, other): 19 | if isinstance(other, MessageId): 20 | return self.name==other.name\ 21 | and self.subname==other.subname\ 22 | and self.byte==other.byte 23 | else: 24 | return NotImplemented 25 | 26 | def __ne__(self, other): 27 | return not self==other 28 | 29 | def __str__(self): 30 | bytestring = utils.byte2hexstring(self.byte) 31 | if self.subname is None: 32 | return "MessageId(name={}, byte=0x{})".format(self.name, bytestring) 33 | else: 34 | return "MessageId(name={}, subname={}, byte=0x{})".format( 35 | self.name, self.subname, bytestring) 36 | -------------------------------------------------------------------------------- /ubx/parser.py: -------------------------------------------------------------------------------- 1 | from . import payload 2 | 3 | 4 | class Parser: 5 | def __init__(self, *descriptions): 6 | self.descriptions = {} 7 | for d in descriptions: 8 | self.add_description(d) 9 | 10 | def add_description(self, description): 11 | self.descriptions[description.key] = description 12 | 13 | def parse(self, rawmsg): 14 | key = rawmsg.key 15 | if key not in self.descriptions: 16 | raise KeyError("No description for " + str(rawmsg)) 17 | else: 18 | buffer = payload.Buffer(rawmsg.payload, index=0) 19 | msg = self.descriptions[key].parse(buffer) 20 | if buffer.remaining_bytesize != 0: 21 | raise payload.PayloadError("Not all bytes used.", buffer, None) 22 | return msg 23 | -------------------------------------------------------------------------------- /ubx/payload.py: -------------------------------------------------------------------------------- 1 | import struct 2 | import codecs 3 | from collections import OrderedDict 4 | 5 | import bitarray 6 | 7 | 8 | class PayloadError(Exception): 9 | def __init__(self, msg, buffer, context, suberror=None): 10 | if isinstance(suberror, Exception): 11 | submessage = "\n- " + str(suberror) 12 | elif isinstance(suberror, (tuple, list)): 13 | submessage = "\n- " + "\n- ".join(map(str, suberror)) 14 | else: 15 | submessage = "" 16 | msg = msg + submessage.replace("\n", "\n ") 17 | 18 | Exception.__init__(self, msg) 19 | self.msg = msg 20 | self.buffer = buffer 21 | self.context = context 22 | self.suberror = suberror 23 | 24 | 25 | class Context: 26 | def __init__(self, data=None, parent=None): 27 | self.data = data 28 | self.parent = parent 29 | 30 | @staticmethod 31 | def child(context, data): 32 | return Context(data=data, parent=context) 33 | 34 | 35 | class Buffer: 36 | def __init__(self, data, index): 37 | self.data = data 38 | self.index = index 39 | 40 | @property 41 | def remaining_bytesize(self): 42 | return len(self.data) - self.index 43 | 44 | def reset(self): 45 | self.index = 0 46 | 47 | def read(self, n): 48 | selection = self.data[self.index:self.index+n] 49 | self.index += n 50 | return selection 51 | 52 | def check_bytesize(self, bytesize, name, context): 53 | if bytesize is not None and self.remaining_bytesize < bytesize: 54 | raise PayloadError("Not enough remaining bytes ({}) to parse {} of size {}".format( 55 | self.remaining_bytesize, name, bytesize), 56 | self, context) 57 | 58 | class EmptyVariable: 59 | bytesize = 0 60 | 61 | def parse(self, buffer, context=None): 62 | return None 63 | 64 | def serialize(self, content, context=None): 65 | if content is not None: 66 | raise PayloadError("Content to be serialized by EmptyVariable is not None.", content, context) 67 | return b"" 68 | 69 | def __str__(self): 70 | return "Empty" 71 | 72 | 73 | Empty = EmptyVariable() 74 | 75 | 76 | class AtomicVariable: 77 | def __init__(self, name, bytesize, struct_format): 78 | self.name = name 79 | self.bytesize = bytesize 80 | self.struct_format = struct_format 81 | self.struct = struct.Struct("<" + self.struct_format) 82 | 83 | def parse(self, buffer, context=None): 84 | buffer.check_bytesize(self.bytesize, self.name, context) 85 | bytestring = buffer.read(self.bytesize) 86 | return self.struct.unpack(bytestring)[0] 87 | 88 | def serialize(self, content, context=None): 89 | return self.struct.pack(content) 90 | 91 | def __str__(self): 92 | return self.name 93 | 94 | def __mul__(self, n): 95 | if not isinstance(n, int): 96 | return NotImplemented 97 | return List(n*[self]) 98 | 99 | def __rmul__(self, n): 100 | return self.__mul__(n) 101 | 102 | 103 | class BitfieldEntry: 104 | def __init__(self, name, bits): 105 | self.name = name 106 | self.bits = bits 107 | 108 | def parse(self, bitarray): 109 | return bitarray[self.bits] 110 | 111 | def serialize(self, content, bitarray, context=None): 112 | bitarray[self.bits] = content[self.name] 113 | 114 | def __str__(self): 115 | return "BitfieldEntry(name=\"{}\"; bits={})".format(self.name, self.bits) 116 | 117 | 118 | class Bitfield: 119 | def __init__(self, bytesize, entries=None): 120 | self.bytesize = bytesize 121 | self.entries = entries 122 | 123 | def parse(self, buffer, context=None): 124 | buffer.check_bytesize(self.bytesize, "Bitfield", context) 125 | bytestring = buffer.read(self.bytesize) 126 | bits = bitarray.bitarray(endian="little") 127 | bits.frombytes(bytestring) 128 | if self.entries is None: 129 | return bits 130 | d = OrderedDict() 131 | for entry in self.entries: 132 | d[entry.name] = entry.parse(bits) 133 | return d 134 | 135 | def serialize(self, content, context=None): 136 | if isinstance(content, bitarray.bitarray): 137 | return content.tobytes() 138 | if not isinstance(content, (dict, OrderedDict)): 139 | raise PayloadError("Serialization error in Bitfield: content must be dict or OrderedDict but is {}.".format( 140 | type(content)), content, context) 141 | if self.entries is None: 142 | raise PayloadError("Serialization error in Bitfield: Description is None but content is {}.".format( 143 | type(content)), content, context) 144 | subcontext = Context.child(context, content) 145 | bits = bitarray.bitarray(8*self.bytesize, endian="little") 146 | bits.setall(False) 147 | for entry in self.entries: 148 | entry.serialize(content, bits, subcontext) 149 | return bits.tobytes() 150 | 151 | def __str__(self): 152 | header = "Bitfield({})".format(self.bytesize) 153 | if self.entries is None: 154 | return header 155 | return header + ":\n" + "\n".join([" * "+str(entry) for entry in self.entries]) 156 | 157 | def __mul__(self, n): 158 | if not isinstance(n, int): 159 | return NotImplemented 160 | return List(n*[self]) 161 | 162 | def __rmul__(self, n): 163 | return self.__mul__(n) 164 | 165 | 166 | U1 = AtomicVariable("U1", 1, "B") 167 | U2 = AtomicVariable("U2", 2, "H") 168 | U4 = AtomicVariable("U4", 4, "L") 169 | U8 = AtomicVariable("U8", 8, "Q") 170 | 171 | I1 = AtomicVariable("I1", 1, "b") 172 | I2 = AtomicVariable("I2", 2, "h") 173 | I4 = AtomicVariable("I4", 4, "l") 174 | I8 = AtomicVariable("I8", 8, "q") 175 | 176 | R4 = AtomicVariable("R4", 4, "f") 177 | R8 = AtomicVariable("R8", 8, "d") 178 | 179 | X1 = Bitfield(1) 180 | X2 = Bitfield(2) 181 | X4 = Bitfield(4) 182 | X8 = Bitfield(8) 183 | 184 | 185 | class Chars: 186 | def __init__(self, bytesize, encoding="iso-8859-1"): 187 | self.bytesize = bytesize 188 | self.encoding = codecs.lookup(encoding) 189 | 190 | def parse(self, buffer, context=None): 191 | buffer.check_bytesize(self.bytesize, "Chars", context) 192 | if self.bytesize is None: 193 | bytestring = buffer.read(buffer.remaining_bytesize) 194 | else: 195 | bytestring = buffer.read(self.bytesize) 196 | return bytestring.decode(self.encoding) 197 | 198 | def serialize(self, content, context=None): 199 | return content.encode(self.encoding) 200 | 201 | def __str__(self): 202 | return "Chars({})".format(self.bytesize) 203 | 204 | 205 | class Fields(OrderedDict): 206 | def __init__(self, *fields): 207 | OrderedDict.__init__(self, fields) 208 | bytesize = 0 209 | for _, description in fields: 210 | if not hasattr(description, "bytesize") or description.bytesize is None: 211 | bytesize = None 212 | break 213 | else: 214 | bytesize += description.bytesize 215 | self.bytesize = bytesize 216 | 217 | def parse(self, buffer, context=None): 218 | buffer.check_bytesize(self.bytesize, "Fields", context) 219 | data = OrderedDict() 220 | subcontext = Context.child(context, data) 221 | for name, description in self.items(): 222 | try: 223 | data[name] = description.parse(buffer, subcontext) 224 | except PayloadError as e: 225 | raise PayloadError("Fields: PayloadError while parsing the field {}.".format(name), 226 | buffer, context, e) 227 | return data 228 | 229 | def serialize(self, content, context=None): 230 | if not isinstance(content, (dict, OrderedDict)): 231 | raise PayloadError("Serialization error in Fields: content must be dict or OrderedDict but is {}.".format( 232 | type(content)), content, context) 233 | if len(content) != len(self): 234 | raise PayloadError("Serialization error in Fields: length of content is {} instead of {}.".format( 235 | len(content), len(self)), content, context) 236 | subcontext = Context.child(context, content) 237 | data = [] 238 | for name, description in self.items(): 239 | if name not in content: 240 | raise PayloadError("Serialization error in Fields: content has no field with name {}.".format(name), 241 | content, context) 242 | try: 243 | data.append(description.serialize(content[name], subcontext)) 244 | except PayloadError as e: 245 | raise PayloadError("Serialization error in field {}.".format(name), 246 | content, context, e) 247 | return b"".join(data) 248 | 249 | def __str__(self): 250 | description_strings = [] 251 | for name, description in self.items(): 252 | description_string = str(description) 253 | if "\n" in description_string: 254 | description_string = description_string.replace("\n", "\n ") 255 | description_strings.append("{}:\n {}".format(name, description_string)) 256 | else: 257 | description_strings.append("{}: {}".format(name, description_string)) 258 | if self.bytesize is None: 259 | sizestring = "?" 260 | else: 261 | sizestring = str(self.bytesize) 262 | return "Fields(length=" + sizestring + ") {\n " + ",\n ".join(description_strings) + "\n}" 263 | 264 | 265 | class List: 266 | def __init__(self, descriptions): 267 | self.descriptions = descriptions 268 | bytesize = 0 269 | for description in descriptions: 270 | if not hasattr(description, "bytesize") or description.bytesize is None: 271 | bytesize = None 272 | break 273 | else: 274 | bytesize += description.bytesize 275 | self.bytesize = bytesize 276 | 277 | def parse(self, buffer, context=None): 278 | buffer.check_bytesize(self.bytesize, "List", context) 279 | data = [] 280 | subcontext = Context.child(context, data) 281 | for i, description in enumerate(self.descriptions): 282 | try: 283 | data.append(description.parse(buffer, subcontext)) 284 | except PayloadError as e: 285 | raise PayloadError("List description: PayloadError while parsing entry number {}.".format(i), 286 | buffer, context, e) 287 | return data 288 | 289 | def serialize(self, content, context=None): 290 | if not isinstance(content, (list, tuple)): 291 | raise PayloadError("Serialization error in list: content must be list or tuple but is {}.".format( 292 | type(content)), content, context) 293 | if len(content) != len(self.descriptions): 294 | raise PayloadError("Serialization error in list: length of content is {} instead of {}.".format( 295 | len(content), len(self.descriptions)), content, context) 296 | subcontext = Context.child(context, content) 297 | data = [] 298 | for i, description in enumerate(self.descriptions): 299 | try: 300 | data.append(description.serialize(content[i], subcontext)) 301 | except PayloadError as e: 302 | raise PayloadError("Serialization error in list entry number {}".format(i), 303 | content, context, e) 304 | return b"".join(data) 305 | 306 | def __str__(self): 307 | return "[\n " +\ 308 | ",\n ".join([str(d).replace("\n", "\n ") 309 | for d in self.descriptions]) +\ 310 | "\n]" 311 | 312 | 313 | class Loop: 314 | def __init__(self, description): 315 | self.description = description 316 | self.bytesize = None 317 | 318 | def iterations(self, buffer, context): 319 | raise NotImplementedError() 320 | 321 | def parse(self, buffer, context): 322 | n = self.iterations(buffer, context) 323 | data = [] 324 | subcontext = Context.child(context, data) 325 | for i in range(n): 326 | try: 327 | data.append(self.description.parse(buffer, subcontext)) 328 | except PayloadError as e: 329 | raise PayloadError("Loop description: Payload error in iteration {}/{}.".format(i+1, n), 330 | buffer, context, e) 331 | return data 332 | 333 | def serialize(self, content, context=None): 334 | subcontext = Context.child(context, content) 335 | data = [] 336 | if not isinstance(content, (list, tuple)): 337 | raise PayloadError("Serialization error in loop: content must be list or tuple but is {}.".format( 338 | type(content)), content, context) 339 | try: 340 | for i, entry in enumerate(content): 341 | data.append(self.description.serialize(entry, subcontext)) 342 | except PayloadError as e: 343 | raise PayloadError("Serialization error in loop iteration {}".format(i), 344 | content, context, e) 345 | 346 | return b"".join(data) 347 | 348 | 349 | class MatchedLoop(Loop): 350 | def __init__(self, description): 351 | if description.bytesize is None: 352 | raise ValueError("Description of matched loop has to have a fixed byte size.") 353 | Loop.__init__(self, description) 354 | 355 | def iterations(self, buffer, context): 356 | n, m = divmod(buffer.remaining_bytesize, self.description.bytesize) 357 | if m!=0: 358 | raise PayloadError("Matched loop of content length {} doesn't match input of length{}".format( 359 | self.description.bytesize, buffer.remaining_bytesize), buffer, context) 360 | return n 361 | 362 | def __str__(self): 363 | return "MatchedLoop:\n| " +\ 364 | str(self.description).replace("\n", "\n| ") 365 | 366 | 367 | class KeyLoop(Loop): 368 | def __init__(self, key, description): 369 | Loop.__init__(self, description) 370 | self.key = key 371 | 372 | def iterations(self, buffer, context): 373 | return context.data[self.key] 374 | 375 | def __str__(self): 376 | return "Loop(key=\"{}\"):\n| ".format(self.key) +\ 377 | str(self.description).replace("\n", "\n| ") 378 | 379 | 380 | class Options: 381 | def __init__(self, *descriptions): 382 | self.descriptions = descriptions 383 | 384 | def parse(self, buffer, context=None): 385 | payload_errors = [] 386 | for description in self.descriptions: 387 | if description.bytesize is not None and buffer.remaining_bytesize != description.bytesize: 388 | payload_errors.append(PayloadError( 389 | "Description bytesize ({}) doesn't match remaining bytesize ({})".format( 390 | description.bytesize, buffer.remaining_bytesize), 391 | buffer, context)) 392 | continue 393 | try: 394 | return description.parse(buffer, context) 395 | except PayloadError as e: 396 | payload_errors.append(e) 397 | buffer.reset() 398 | continue 399 | raise PayloadError("All available description options failed.", 400 | buffer, context, payload_errors) 401 | 402 | def serialize(self, content, context=None): 403 | payload_errors = [] 404 | subcontext = Context.child(context, content) 405 | for description in self.descriptions: 406 | try: 407 | return description.serialize(content, subcontext) 408 | except PayloadError as e: 409 | payload_errors.append(e) 410 | raise PayloadError("All available description options failed.", 411 | content, context, payload_errors) 412 | 413 | def __str__(self): 414 | options = [] 415 | for i, d in enumerate(self.descriptions): 416 | options.append(" [{}]: ".format(i) + str(d).replace("\n", "\n ")) 417 | return "Options:\n" + "\n".join(options) 418 | -------------------------------------------------------------------------------- /ubx/printing/__init__.py: -------------------------------------------------------------------------------- 1 | from .rst import RST 2 | -------------------------------------------------------------------------------- /ubx/printing/base.py: -------------------------------------------------------------------------------- 1 | from .. import payload 2 | from .. import message 3 | 4 | 5 | class DescriptionPrinter: 6 | def print_dispatch(self, obj): 7 | if isinstance(obj, message.MessageDescription): 8 | return self.print_MessageDescription(obj) 9 | if isinstance(obj, payload.EmptyVariable): 10 | return self.print_EmptyVariable(obj) 11 | if isinstance(obj, payload.BitfieldEntry): 12 | return self.print_BitfieldEntry(obj) 13 | if isinstance(obj, payload.Bitfield): 14 | return self.print_Bitfield(obj) 15 | if isinstance(obj, payload.AtomicVariable): 16 | return self.print_AtomicVariable(obj) 17 | if isinstance(obj, payload.Chars): 18 | return self.print_Chars(obj) 19 | if isinstance(obj, payload.Fields): 20 | return self.print_Fields(obj) 21 | if isinstance(obj, payload.List): 22 | return self.print_List(obj) 23 | if isinstance(obj, payload.MatchedLoop): 24 | return self.print_MatchedLoop(obj) 25 | if isinstance(obj, payload.KeyLoop): 26 | return self.print_KeyLoop(obj) 27 | if isinstance(obj, payload.Options): 28 | return self.print_Options(obj) 29 | raise NotImplementedError() 30 | 31 | def print_MessageDescription(self, obj): 32 | raise NotImplementedError() 33 | 34 | def print_EmptyVariable(self, obj): 35 | raise NotImplementedError() 36 | 37 | def print_BitfieldEntry(self, obj): 38 | raise NotImplementedError() 39 | 40 | def print_Bitfield(self, obj): 41 | raise NotImplementedError() 42 | 43 | def print_AtomicVariable(self, obj): 44 | raise NotImplementedError() 45 | 46 | def print_Chars(self, obj): 47 | raise NotImplementedError() 48 | 49 | def print_Fields(self, obj): 50 | raise NotImplementedError() 51 | 52 | def print_List(self, obj): 53 | raise NotImplementedError() 54 | 55 | def print_MatchedLoop(self, obj): 56 | raise NotImplementedError() 57 | 58 | def print_KeyLoop(self, obj): 59 | raise NotImplementedError() 60 | 61 | def print_Options(self, obj): 62 | raise NotImplementedError() 63 | -------------------------------------------------------------------------------- /ubx/printing/rst.py: -------------------------------------------------------------------------------- 1 | from .base import DescriptionPrinter 2 | 3 | from .. import utils 4 | from .. import payload 5 | from .. import message 6 | 7 | 8 | class RST(DescriptionPrinter): 9 | def print_MessageDescription(self, obj): 10 | template = ":name: {name}\n\n"\ 11 | ":class: 0x{class}\n\n"\ 12 | ":id: 0x{id}\n\n"\ 13 | ":payload:\n\n {payload}" 14 | return template.format(**{ 15 | "name": obj.name, 16 | "class": utils.byte2hexstring(obj.message_class.byte), 17 | "id": utils.byte2hexstring(obj.message_id.byte), 18 | "payload": self.print_dispatch(obj.payload_description).replace("\n", "\n ") 19 | }) 20 | 21 | 22 | def print_EmptyVariable(self, obj): 23 | return "`Empty`" 24 | 25 | def print_BitfieldEntry(self, obj): 26 | if isinstance(obj.bits, int): 27 | bits = str(obj.bits) 28 | elif isinstance(obj.bits, slice): 29 | bits = "{}:{}".format(obj.bits.start, obj.bits.stop) 30 | else: 31 | bits = str(obj.bits) 32 | return "{bits}: *{name}*".format(name=obj.name, bits=bits) 33 | 34 | def print_Bitfield(self, obj): 35 | header = "Bitfield({})".format(obj.bytesize) 36 | if obj.entries is None: 37 | return header 38 | return header + "\n\n" + "\n\n".join(" " + self.print_BitfieldEntry(entry) for entry in obj.entries) 39 | 40 | def print_AtomicVariable(self, obj): 41 | return obj.name 42 | 43 | def print_Chars(self, obj): 44 | return "Chars({})".format(obj.bytesize) 45 | 46 | def print_Fields(self, obj): 47 | description_string = lambda name, description: " :{}:\n {}".format(name, self.print_dispatch(description).replace("\n", "\n ")) 48 | description_strings = [description_string(name, description) for name, description in obj.items()] 49 | if obj.bytesize is None: 50 | sizestring = "?" 51 | else: 52 | sizestring = str(obj.bytesize) 53 | return "Fields(length=" + sizestring + ")\n\n" + "\n\n".join(description_strings) 54 | 55 | def print_List(self, obj): 56 | return "List\n\n - " +\ 57 | "\n\n - ".join([self.print_dispatch(d).replace("\n", "\n ") 58 | for d in obj.descriptions]) 59 | 60 | def print_MatchedLoop(self, obj): 61 | return "MatchedLoop\n\n " + self.print_dispatch(obj.description).replace("\n", "\n ") 62 | 63 | def print_KeyLoop(self, obj): 64 | return "KeyLoop(key=\"{}\"):\n\n ".format(obj.key) +\ 65 | self.print_dispatch(obj.description).replace("\n", "\n ") 66 | 67 | def print_Options(self, obj): 68 | return "#. " + "\n\n#. ".join(self.print_dispatch(d).replace("\n", "\n ") for d in obj.descriptions) 69 | -------------------------------------------------------------------------------- /ubx/rawmessage.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | from . import syncchars 4 | from . import message_class 5 | from . import utils 6 | from . import checksum 7 | 8 | 9 | class RawMessage: 10 | length_struct = struct.Struct("