|
Packer DocumentationMaintained by: David Austin |
| 1.0 Introduction |
The Packer is imperfect but it serves the purpose. I wanted to avoid any two-stage compilation process which commonly occurs with other packages. I may have to reconsider this decision and introduce some better (more complete) format for describing (and particularly documenting) the messages. This format can then be processed to generate the DROSMessages header file.
| 2.0 Packer Tutorials |
|
This example shows how to pack a simple message with just an integer
in the body. ACK_FMT_STR is defined as "%i".
2.2 Unpacking a Simple Message
|
This example shows how to unpack a simple message with just an integer
in the body. ACK_FMT_STR is defined as "%i".
2.3 Packing a Variable-Length Message
|
This example shows the use of the offset parameter to the pack_msg_data function. The variable offset maintains the current packing position. It must be initialised to zero and is then updated by pack_msg_data as packing occurs. Note: for fixed length messages, it is not necessary to maintain the offset so NULL can be passed in place of a pointer to a variable to update.
2.4 Unpacking a Variable-Length Message
|
This example shows the use of the offset parameter to the extract_msg_data function. The variable offset maintains the current unpacking position. It must be initialised to zero and is then updated by extract_msg_data as unpacking occurs. Note: for fixed length messages, it is not necessary to maintain the offset so NULL can be passed in place of a pointer to a variable to update.
| 3.0 Packer Format Flags |
Characters in the format string which do not form part of a specifier are copied to the message buffer. Specifiers start with a '%' character, have a number of options or flags and end with a single character which describes the format.
Major differences from printf(3) are:
| Copyright 2001,2002 David Austin |