Example for updating the MTi-1's firmware. Uses a platform independent, retargetable pure C implementation of the firmware updater protocol.

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

xbusparser.c File Reference

xbusparser.c File Reference

Go to the source code of this file.

Enumerations

enum  XbusParserState {
  XBPS_Preamble, XBPS_BusId, XBPS_MessageId, XBPS_Length,
  XBPS_ExtendedLengthMsb, XBPS_ExtendedLengthLsb, XBPS_Payload, XBPS_Checksum
}
 

XbusParser states.

More...

Functions

size_t XbusParser_mem (void)
 Get the amount of memory needed for the XbusParser structure.
struct XbusParser * XbusParser_create (struct XbusParserCallback const *callback)
 Create a new XbusParser object.
void XbusParser_destroy (struct XbusParser *parser)
 Frees an XbusParser structure allocated by XbusParser_create().
struct XbusParser * XbusParser_init (void *parserMem, struct XbusParserCallback const *callback)
 Initializes an XbusParser in the passed memory location.
void prepareForPayload (struct XbusParser *parser)
 Prepare for receiving a message payload.
void XbusParser_parseByte (struct XbusParser *parser, const uint8_t byte)
 Parse a byte of data from a motion tracker.
void XbusParser_parseBuffer (struct XbusParser *parser, uint8_t const *buf, size_t bufSize)
 Parse a buffer of data received from a motion tracker.

Detailed Description

Copyright (C) Xsens Technologies B.V., 2015.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file xbusparser.c.


Enumeration Type Documentation

XbusParser states.

Enumerator:
XBPS_Preamble 

Looking for preamble.

XBPS_BusId 

Waiting for bus ID.

XBPS_MessageId 

Waiting for message ID.

XBPS_Length 

Waiting for length.

XBPS_ExtendedLengthMsb 

Waiting for extended length MSB.

XBPS_ExtendedLengthLsb 

Waiting for extended length LSB.

XBPS_Payload 

Reading payload.

XBPS_Checksum 

Waiting for checksum.

Definition at line 23 of file xbusparser.c.


Function Documentation

void prepareForPayload ( struct XbusParser *  parser )

Prepare for receiving a message payload.

Requests a memory area to store the received data to using the registered callbacks.

Definition at line 116 of file xbusparser.c.

struct XbusParser* XbusParser_create ( struct XbusParserCallback const *  callback ) [read]

Create a new XbusParser object.

Parameters:
callbackPointer to callback structure containing callback functions for memory management and handling received messages.
Returns:
Pointer the new XbusParser structure.

Uses malloc to allocate the memory required for the parser.

Definition at line 71 of file xbusparser.c.

void XbusParser_destroy ( struct XbusParser *  parser )

Frees an XbusParser structure allocated by XbusParser_create().

Definition at line 85 of file xbusparser.c.

struct XbusParser* XbusParser_init ( void *  parserMem,
struct XbusParserCallback const *  callback 
) [read]

Initializes an XbusParser in the passed memory location.

Parameters:
parserMemPointer to memory to use for storing parser state. Should be at least as big as the value returned by XbusParser_mem().
callbackPointer to callback structure containing callback functions for memory management and handling received messages.
Returns:
Initialized XbusParser structure.

Definition at line 99 of file xbusparser.c.

size_t XbusParser_mem ( void   )

Get the amount of memory needed for the XbusParser structure.

Definition at line 57 of file xbusparser.c.

void XbusParser_parseBuffer ( struct XbusParser *  parser,
uint8_t const *  buf,
size_t  bufSize 
)

Parse a buffer of data received from a motion tracker.

Definition at line 218 of file xbusparser.c.

void XbusParser_parseByte ( struct XbusParser *  parser,
const uint8_t  byte 
)

Parse a byte of data from a motion tracker.

When a complete message is received the user will be notified by a call to the handleMessage() callback function.

Definition at line 129 of file xbusparser.c.