COM Helper Functions
[Communications Interface]


Functions

void buf_insert16 (uint8_t *p, uint16_t pos, uint16_t word)
 Insert a uint16_t into an array of bytes in little endian byte order.
void buf_insert32 (uint8_t *p, uint16_t pos, uint32_t dword)
 Insert a uint32_t into an array of bytes in little endian byte order.
uint16_t buf_extract16 (uint8_t *p, uint16_t pos)
 Extracts a little endian uint16_t from an array of bytes.
uint32_t buf_extract32 (uint8_t *p, uint16_t pos)
 Extracts a little endian uint32_t from an array of bytes.

Detailed Description

These functions do not directly relate to the COM Layer, but are useful when dealing with comBufs on specific platforms.

Specifically, the buf_insert and buf_extract functions can be used instead of casting a byte pointer to a uint16_t* or uint32_t*. On some platforms such as the TELOSb, undefined behavior occurs if you read or write a 16-bit or 32-bit value to a location in memory that is not word aligned. These functions do not have such an issue.


Function Documentation

uint16_t buf_extract16 uint8_t *  p,
uint16_t  pos
 

Parameters:
p A pointer to a byte array
pos The index from which to extract the uint16_t.
Returns:
the extracted 16-bit value.

uint32_t buf_extract32 uint8_t *  p,
uint16_t  pos
 

Parameters:
p A pointer to a byte array
pos The index from which to extract the uint32_t.
Returns:
the extracted 32-bit value.

void buf_insert16 uint8_t *  p,
uint16_t  pos,
uint16_t  word
 

Parameters:
p A pointer to an array of uint8_ts..
pos The index at which to insert the uint16_t.
word The 16-bit number to insert.

void buf_insert32 uint8_t *  p,
uint16_t  pos,
uint32_t  dword
 

Parameters:
p A pointer to an array of uint8_ts.
pos The index at which to insert the uint32_t.
dword The 32-bit number to insert.


Generated on Mon Nov 23 06:26:00 2009 for MANTIS by  doxygen 1.4.6