Loading...
Searching...
No Matches
o2_msg_data Struct Reference
Basics

data part of an O2 message More...

`#include <o2.h>`

## Data Fields

o2_time | timestamp
| the message delivery time (0 for immediate)
char | address [4]
| the message address string

## Detailed Description

data part of an O2 message

This data type is used to pass o2 message data to message handlers. It appears many other times in the code. You should NEVER allocate or free an o2_msg_data struct. Instead, create a message using o2_send_start(), o2_add_*(), and o2_message_finish() to get an o2_message_ptr. Within the o2_message, the data field is an o2_msg_data structure. We would use o2_message everywhere instead of o2_msg_data, but bundles can contain multiple o2_msg_data structures without the extra baggage contained in an o2_message.

Note: it is assumed that an o2_msg_data struct is always preceded by a 32-bit length. Ideally, length should therefore be in this struct, but then the compiler might add padding to put the timestamp on an 8-byte alignment. This could be solved with a pack pragma, but that is not standard C. To be safe and portable, I decided to just leave length out of the struct. The macro MSG_DATA_LENGTH can be used to access the length field.

## Field Documentation

## address

char address[4]

the message address string

Although this field is declared as 4 bytes, actual messages have variable length, and the address is followed by a string of type codes and the actual parameters. The length of the entire message including the timestamp is given by the `length` field.

The documentation for this struct was generated from the following file:

- src/o2.h