Simple python script to generate IEEE style frame figures in svg.
Depends on svgwrite.
python framedraw.py <input.yaml>
There's practically no error handling in the script, so some knowledge of python is required to decrypt errors.
154frame.yml genearates the following figure, which is an approximation of the IEEE 802.15.4 frame format:
Drawing bitfields is also possible. E.g. the IEEE 802.15.4 SUN OFDM PHR documentation looks like this:
The yaml file is fairly easy to understand, at least the parts that you might need. The next part is just a reference of all keywords, but in general, it's probably simpler to grab the example and modify it.
All the keywords in the yaml are lowercase. Each yml should start with a global
formatting field followed by the frame description under frame
name: the filename to generateunitsize: The width of each unit in pixel (i.e., how many pixels is drawn for a byte). Recommended: 25height: The height of the frame drawing rectangles. Recommended: 30fontsize: Font size for all fonts. Recommended: 10fontfamily: Font family for all fonts. Recommended: 10topspace: Space from the top of the canvas. Recommended: 7bottomspace: Space under the frame rectangle. Recommended: 7leftspace: Space left/right from the frame rectnagle. Recommended: 5withsize: Set it toTrueto write the size under the frame (otherwise size is only represented with drawing width)withbits: If enabled, the frame will be drawn as a dual rectangle, with the upper rectangle documenting bitfields, e.g. 6-10. Usable for creating documentation on bitfields. Note that whenwithbitsis true, allsizemust be integersizeunit: Unit to print after the size, with leading spaces. E.g.," B"subfrmaespacing: disatnace between subframes, including main frame and first subframe. Recommended: 80scale: Optional parameter to scale up/down the final drawing. When ommitted, scale 1 is assumed.
Frame is an array of frame elements, drawn in order from left to right, each must have at least:
name: The name of the frame element, drawn in the middle of its rectanglesize: Unlessdrawsizeis specified, defines the width of the rectangle (size * unitsize), and ifwithsizeisTrue, printed under the rectangle. Must be numerical unless `drawsize`` is specified.
sizeunit: If specified, replaces thesizeunitinglobaldrawsize: If specified, replaces size to define the width of the rectangle. Must be numerical.cut: Cuts the frame with "arrows" around the defined location. E.g., ifsize/drawsizeis 10, acutat 7 will cut the element around 70% of it width
Under a frame element, a subframe can be defined. This will be connected to
the frame element with dotted lines. For a subframe, the following is required:
subframerow: The row to draw the given subframe. Row 0 is the main frame, so the first subframe(s) should be in row 1.subframe: Works exactly the same asframe, so a list of frame elements should be defined under it
The system is written recursively, so subframes of subframes is possible.
There are none. I just needed a quick and dirty tool to draw frames for documentation and I was fed up doing it with rectangles and textboxes. But this is good enough for me. If you want something better, fork the code.