1- ## Specification and Bindings for Swift Binary Protocol
1+ # Specification and Bindings for Swift Binary Protocol
22
33<!-- toc -->
44
5- - [ Installing sbp2json, json2sbp, json2json and related tools] ( #installing-sbp2json-json2sbp-json2json-and-related-tools )
6- - [ Building / installing] ( #building--installing )
7- * [ Using Docker] ( #using-docker )
8- + [ Fetching the prebuilt image from DockerHub] ( #fetching-the-prebuilt-image-from-dockerhub )
9- + [ Creating your own image] ( #creating-your-own-image )
10- + [ Using the docker image] ( #using-the-docker-image )
11- * [ Installing from package managers] ( #installing-from-package-managers )
12- * [ Installing development Python versions] ( #installing-development-python-versions )
13- * [ Adding development version as a pip dependency] ( #adding-development-version-as-a-pip-dependency )
14- * [ Installing from source] ( #installing-from-source )
15- - [ SBP Development Procedures] ( #sbp-development-procedures )
16- - [ SBP Protocol Specification] ( #sbp-protocol-specification )
17- - [ JSON Schema Definitions] ( #json-schema-definitions )
18- - [ Kaitai Struct Format Descriptions] ( #kaitai-struct-format-descriptions )
19- - [ LICENSE] ( #license )
5+ - [ Specification and Bindings for Swift Binary Protocol] ( #specification-and-bindings-for-swift-binary-protocol )
6+ - [ Installing sbp2json, json2sbp, json2json and related tools] ( #installing-sbp2json-json2sbp-json2json-and-related-tools )
7+ - [ Building / installing] ( #building--installing )
8+ - [ Using Docker] ( #using-docker )
9+ - [ Fetching the prebuilt image from DockerHub] ( #fetching-the-prebuilt-image-from-dockerhub )
10+ - [ Creating your own image] ( #creating-your-own-image )
11+ - [ Using the docker image] ( #using-the-docker-image )
12+ - [ Installing from package managers] ( #installing-from-package-managers )
13+ - [ Installing development Python versions] ( #installing-development-python-versions )
14+ - [ Adding development version as a pip dependency] ( #adding-development-version-as-a-pip-dependency )
15+ - [ Installing from source] ( #installing-from-source )
16+ - [ SBP Development Procedures] ( #sbp-development-procedures )
17+ - [ SBP Protocol Specification] ( #sbp-protocol-specification )
18+ - [ JSON Schema Definitions] ( #json-schema-definitions )
19+ - [ Kaitai Struct Format Descriptions] ( #kaitai-struct-format-descriptions )
20+ - [ Notes on python bindings] ( #notes-on-python-bindings )
21+ - [ LICENSE] ( #license )
2022
2123<!-- tocstop -->
2224
@@ -32,19 +34,19 @@ messages used with SBP, a compiler for generating message bindings, and client
3234libraries in a variety of languages. This repository is organized into the
3335following directory structure:
3436
35- * [ ` docs ` ] ( ./docs ) : Protocol documentation and message definitions.
36- * [ ` spec ` ] ( ./spec ) : Machine readable protocol specification in
37+ - [ ` docs ` ] ( ./docs ) : Protocol documentation and message definitions.
38+ - [ ` spec ` ] ( ./spec ) : Machine readable protocol specification in
3739 [ YAML] ( http://en.wikipedia.org/wiki/YAML ) .
38- * [ ` generator ` ] ( ./generator ) : Simple, template-based generator for
40+ - [ ` generator ` ] ( ./generator ) : Simple, template-based generator for
3941 different languages.
40- * [ ` python ` ] ( ./python ) : Python client and examples.
41- * [ ` c ` ] ( ./c ) : C client library and examples.
42- * [ ` haskell ` ] ( ./haskell ) : Haskell client and examples.
43- * [ ` java ` ] ( ./java ) : Java client library and examples.
44- * [ ` javascript ` ] ( ./javascript ) : JavaScript client library and examples.
45- * [ ` rust ` ] ( ./rust ) : Rust client library and examples.
46- * [ ` sbpjson ` ] ( ./sbpjson ) : Tools for parsing SBP-JSON.
47- * [ ` kaitai ` ] ( ./kaitai ) : Kaitai Struct Format Description and generated code.
42+ - [ ` python ` ] ( ./python ) : Python client and examples.
43+ - [ ` c ` ] ( ./c ) : C client library and examples.
44+ - [ ` haskell ` ] ( ./haskell ) : Haskell client and examples.
45+ - [ ` java ` ] ( ./java ) : Java client library and examples.
46+ - [ ` javascript ` ] ( ./javascript ) : JavaScript client library and examples.
47+ - [ ` rust ` ] ( ./rust ) : Rust client library and examples.
48+ - [ ` sbpjson ` ] ( ./sbpjson ) : Tools for parsing SBP-JSON.
49+ - [ ` kaitai ` ] ( ./kaitai ) : Kaitai Struct Format Description and generated code.
4850
4951Except for the ` generator ` , all of the above are generated and should not be modified directly.
5052
@@ -72,7 +74,7 @@ your platform.
7274To install from source, you can use Rust's cargo tool (first [ install
7375Rust] ( https://www.rust-lang.org/tools/install ) ), then run:
7476
75- ```
77+ ``` sh
7678cargo install --git https://github.com/swift-nav/libsbp.git --bins
7779```
7880
@@ -87,13 +89,13 @@ tool as well as a `sbp2prettyjson` tool.
8789Finally, a Python version of the ` sbp2json ` tool exists, which is installable
8890on any platform that supports Python via pip, e.g.:
8991
90- ```
92+ ``` sh
9193pip3 install sbp
9294```
9395
9496The tool can then be invoked as follows:
9597
96- ```
98+ ``` sh
9799python3 -m sbp2json < sbp.bin
98100```
99101
@@ -103,9 +105,11 @@ but works on all platforms that Python itself supports.
103105## Building / installing
104106
105107Before you start, run
106- ```
108+
109+ ``` sh
107110git pull --tags
108111```
112+
109113in you local libsbp repository to pull the tags. This will ensure the correct
110114version number is generated.
111115
@@ -119,14 +123,18 @@ Start [Docker desktop](https://docs.docker.com/docker-for-mac/).
119123The quickest method to get going is to just pull a prebuilt copy from DockerHub
120124(no guarantees on freshness) by running the following on your command line:
121125
122- docker run --rm -v $PWD:/mnt/workspace -i -t swiftnav/libsbp-build:2025-02-10 /bin/bash
126+ ``` sh
127+ docker run --rm -v $PWD :/mnt/workspace -i -t swiftnav/libsbp-build:2025-02-10 /bin/bash
128+ ```
123129
124130This will mount your local copy of the libsbp repository onto the image.
125131
126- Check this [ link ] ( https://hub.docker.com/r/swiftnav/libsbp-build/tags ) for newer tags.
132+ Check libsbp-build [ dockerhub page ] ( https://hub.docker.com/r/swiftnav/libsbp-build/tags ) for newer tags.
127133Alternatively, you could run
128134
129- docker run --rm -v $PWD:/mnt/workspace -i -t swiftnav/libsbp-build:latest-master /bin/bash
135+ ``` sh
136+ docker run --rm -v $PWD :/mnt/workspace -i -t swiftnav/libsbp-build:latest-master /bin/bash
137+ ```
130138
131139if you are facing issues with compilation and the tags are out of date as well.
132140
@@ -136,18 +144,24 @@ Otherwise, the `Dockerfile` will create a docker image that contains all the
136144necessary dependencies to build libsbp. You can make a local image fresh from
137145this file by running ` docker build ` as such:
138146
139- docker build -t libsbp-build - <Dockerfile
147+ ``` sh
148+ docker build -t libsbp-build - < Dockerfile
149+ ```
140150
141151Reading the Dockerfile from STDIN prevents docker from pulling in the whole
142152repostory into the build context (which is then immediately discarded anyway).
143153You can customize the UID of the user that's created with the docker image
144154by passing the desired ` UID ` value to the build:
145155
156+ ``` sh
146157 docker build -t libsbp-build --build-arg UID=1234 - < Dockerfile
158+ ```
147159
148160You can then make this image operate on your local workspace like this:
149161
150- docker run --rm -v $PWD:/mnt/workspace -i -t libsbp-build:latest /bin/bash
162+ ``` sh
163+ docker run --rm -v $PWD :/mnt/workspace -i -t libsbp-build:latest /bin/bash
164+ ```
151165
152166#### Using the docker image
153167
@@ -158,12 +172,16 @@ This could take several hours to run. Alternately, the docker image will run
158172the ` make all ` command by default, so you can kick off the ` make all ` process
159173by simply running the following command:
160174
161- docker run --rm -v $PWD:/mnt/workspace -i -t libsbp-build:2025-02-10
175+ ``` sh
176+ docker run --rm -v $PWD :/mnt/workspace -i -t libsbp-build:2025-02-10
177+ ```
162178
163179To speed up this process you can attempt to run Python environment tests in
164180paralell with:
165181
166- docker run --rm -v $PWD:/mnt/workspace -i -t -e SBP_TOX_PARALLEL=auto libsbp-build:2025-02-10
182+ ``` sh
183+ docker run --rm -v $PWD :/mnt/workspace -i -t -e SBP_TOX_PARALLEL=auto libsbp-build:2025-02-10
184+ ```
167185
168186When you are finished, quit Docker so that it would not unnecessarily use up
169187resources on your machine.
@@ -177,9 +195,9 @@ issues from an old build.
177195
178196Some bindings are available on package managers:
179197
180- * [ ` python ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/python ) : available on pip
181- * [ ` haskell ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/haskell ) : available on Hackage
182- * [ ` javascript ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/javascript ) : available on NPM
198+ - [ ` python ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/python ) : available on pip
199+ - [ ` haskell ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/haskell ) : available on Hackage
200+ - [ ` javascript ` ] ( https://github.com/swift-nav/libsbp/tree/HEAD/javascript ) : available on NPM
183201
184202### Installing development Python versions
185203
@@ -190,6 +208,7 @@ pip install 'file:///path/to/libsbp#subdirectory=python'
190208```
191209
192210Or via setuptools directly:
211+
193212``` sh
194213cd /path/to/libsbp
195214cd python
@@ -199,31 +218,35 @@ python setup.py
199218### Adding development version as a pip dependency
200219
201220Run the following command:
221+
202222``` sh
203223pip install " git+https://github.com/swift-nav/libsbp@<GIT_REVISION>#egg=sbp&subdirectory=python"
204224```
205225
206226Or add this to ` requirements.txt ` :
207- ```
227+
228+ ``` sh
208229git+https://github.com/swift-nav/libsbp@< GIT_REVISION> # egg=sbp&subdirectory=python
209230```
210231
211232### Installing from source
233+
212234You can build one binding at a time or update all at once:
213235
214- ```
236+ ``` sh
215237make python
216238```
217239
218240or
219241
220- ```
242+ ``` sh
221243make all
222244```
223245
224246are both valid. To see a list of all valid targets, run ` make help ` .
225247
226248** Python version notes:**
249+
2272501 . By default the Python targets ` make python ` and ` make test-python ` (as well
228251 as ` make all ` ) run tests on all Python versions officially supported by * the
229252 libsbp Python bindings* , currently ** 3.6-3.9** , skipping any versions not
@@ -256,7 +279,7 @@ detection.
256279
257280Please see [ the docs] ( docs/sbp.pdf ) for a full description of the packet
258281structure and the message types. Developer documentation for the
259- language-specific sbp libraries is [ here ] ( http://swift-nav.github.io/libsbp/ ) .
282+ language-specific sbp libraries is available at [ http://swift-nav.github.io/libsbp/ ] ( http://swift-nav.github.io/libsbp/ ) .
260283Please refer to [ the changelog] ( CHANGELOG.md ) for more information about the
261284evolution of the library and its messages.
262285
@@ -281,19 +304,19 @@ respectively.
281304The Kaitai Struct format description files can also potentially be used to
282305generate bindings for the following targets:
283306
284- * graphviz
285- * csharp
286- * rust
287- * java
288- * go
289- * cpp_stl
290- * php
291- * lua
292- * nim
293- * html
294- * ruby
295- * construct
296- * javascript
307+ - graphviz
308+ - csharp
309+ - rust
310+ - java
311+ - go
312+ - cpp_stl
313+ - php
314+ - lua
315+ - nim
316+ - html
317+ - ruby
318+ - construct
319+ - javascript
297320
298321### Notes on python bindings
299322
0 commit comments