Ben Olmstead | c0d7784 | 2019-07-31 17:34:05 -0700 | [diff] [blame] | 1 | # Emboss |
| 2 | |
| 3 | Emboss is a tool for generating code that reads and writes binary data |
| 4 | structures. It is designed to help write code that communicates with hardware |
| 5 | devices such as GPS receivers, LIDAR scanners, or actuators. |
| 6 | |
| 7 | ## What does Emboss *do*? |
| 8 | |
| 9 | Emboss takes specifications of binary data structures, and produces code that |
| 10 | will efficiently and safely read and write those structures. |
| 11 | |
| 12 | Currently, Emboss only generates C++ code, but the compiler is structured so |
| 13 | that writing new back ends is relatively easy -- contact emboss-dev@google.com |
| 14 | if you think Emboss would be useful, but your project uses a different language. |
| 15 | |
| 16 | |
| 17 | ## When should I use Emboss? |
| 18 | |
| 19 | If you're sitting down with a manual that looks something like |
Ben Olmstead | d21c393 | 2022-03-10 17:59:12 -0800 | [diff] [blame] | 20 | [this](https://hexagondownloads.blob.core.windows.net/public/Novatel/assets/Documents/Manuals/om-20000094/om-20000094.pdf) or |
| 21 | [this](https://www.u-blox.com/sites/default/files/products/documents/u-blox6_ReceiverDescrProtSpec_%28GPS.G6-SW-10018%29_Public.pdf), |
Ben Olmstead | c0d7784 | 2019-07-31 17:34:05 -0700 | [diff] [blame] | 22 | Emboss is meant for you. |
| 23 | |
| 24 | |
| 25 | ## When should I not use Emboss? |
| 26 | |
| 27 | Emboss is not designed to handle text-based protocols; if you can use minicom or |
| 28 | telnet to connect to your device, and manually enter commands and see responses, |
| 29 | Emboss probably won't help you. |
| 30 | |
| 31 | Emboss is intended for cases where you do not control the data format. If you |
| 32 | are defining your own format, you may be better off using [Protocol |
| 33 | Buffers](https://developers.google.com/protocol-buffers/) or [Cap'n |
| 34 | Proto](https://capnproto.org/) or [BSON](http://bsonspec.org/) or some similar |
| 35 | system. |
| 36 | |
| 37 | |
| 38 | ## Why not just use packed structs? |
| 39 | |
| 40 | In C++, packed structs are most common method of dealing with these kinds of |
| 41 | structures; however, they have a number of drawbacks compared to Emboss views: |
| 42 | |
| 43 | 1. Access to packed structs is not checked. Emboss (by default) ensures that |
| 44 | you do not read or write out of bounds. |
| 45 | 2. It is easy to accidentally trigger C++ undefined behavior using packed |
| 46 | structs, for example by not respecting the struct's alignment restrictions |
| 47 | or by running afoul of strict aliasing rules. Emboss is designed to work |
| 48 | with misaligned data, and is careful to use strict-aliasing-safe constructs. |
| 49 | 3. Packed structs do not handle variable-size arrays, nor arrays of |
| 50 | sub-byte-size fields, such as boolean flags. |
| 51 | 4. Packed structs do not handle endianness; your code must be very careful to |
| 52 | correctly convert stored endianness to native. |
| 53 | 5. Packed structs do not handle variable-sized fields, such as embedded |
| 54 | substructs with variable length. |
| 55 | 6. Although unions can sometimes help, packed structs do not handle overlapping |
| 56 | fields well. |
| 57 | 7. Although unions can sometimes help, packed structs do not handle optional |
| 58 | fields well. |
| 59 | 8. Certain aspects of bitfields in C++, such as their exact placement within |
| 60 | the larger containing block, are implementation-defined. Emboss always |
| 61 | reads and writes bitfields in a portable way. |
| 62 | 9. Packed structs do not have support for conversion to human-readable text |
| 63 | format. |
| 64 | 10. It is difficult to read the definition of a packed struct in order to |
| 65 | generate documentation, alternate representations, or support in languages |
| 66 | other than C and C++. |
| 67 | |
| 68 | |
| 69 | ## What does Emboss *not* do? |
| 70 | |
| 71 | Emboss does not help you transmit data over a wire -- you must use something |
| 72 | else to actually transmit bytes back and forth. This is partly because there |
| 73 | are too many possible ways of communicating with devices, but also because it |
| 74 | allows you to manipulate structures independently of where they came from or |
| 75 | where they are going. |
| 76 | |
| 77 | Emboss does not help you interpret your data, or implement any kind of |
| 78 | higher-level logic. It is strictly meant to help you turn bit patterns into |
| 79 | something suitable for your programming language to handle. |
| 80 | |
| 81 | |
| 82 | ## What state is Emboss in? |
| 83 | |
| 84 | Emboss is currently under development. While it should be entirely ready for |
| 85 | many data formats, it may still be missing features. If you find something that |
| 86 | Emboss can't handle, please contact `emboss-dev@google.com` to see if and when |
| 87 | support can be added. |
| 88 | |
| 89 | Emboss is not an officially supported Google product: while the Emboss authors |
| 90 | will try to answer feature requests, bug reports, and questions, there is no SLA |
| 91 | (service level agreement). |
| 92 | |
| 93 | |
| 94 | ## Getting Started |
| 95 | |
Nick | 8732131 | 2020-04-15 21:52:39 -0400 | [diff] [blame] | 96 | Head over to the [User Guide](doc/guide.md) to get started. |