Example for updating the MTi-1's firmware. Uses a platform independent, retargetable pure C implementation of the firmware updater protocol.
xbusparser.h
00001 /*! 00002 * \file 00003 * \copyright Copyright (C) Xsens Technologies B.V., 2015. 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 00006 * use this file except in compliance with the License. You may obtain a copy 00007 * of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 00014 * License for the specific language governing permissions and limitations 00015 * under the License. 00016 */ 00017 #ifndef XBUSPARSER_H 00018 #define XBUSPARSER_H 00019 00020 #include "xbusmessage.h " 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 struct XbusParser; 00027 00028 /*! 00029 * \brief Callback function structure for use with the XbusParser. 00030 */ 00031 struct XbusParserCallback 00032 { 00033 /*! 00034 * \brief Allocate a buffer for message reception. 00035 * \param bufSize The size of the buffer to allocate. 00036 * \returns Pointer to buffer to use for message reception, or NULL if 00037 * a buffer cannot be allocated. 00038 * 00039 * \note It is the resposibility of the user to deallocate the message 00040 * data buffers pointed to by XbusMessage structures passed to the 00041 * handleMessage() callback function. 00042 */ 00043 void* (*allocateBuffer)(size_t bufSize); 00044 00045 /*! 00046 * \brief Deallocate a buffer that was previously allocated by a call to 00047 * allocateBuffer. 00048 */ 00049 void (*deallocateBuffer)(void const* buffer); 00050 00051 /*! 00052 * \brief Handle a received message. 00053 * 00054 * \note If the passed XbusMessage structure has a non-null data pointer 00055 * then it is the responsibility of the user to free this once handling 00056 * of the message is complete. 00057 */ 00058 void (*handleMessage)(struct XbusMessage const* message); 00059 }; 00060 00061 00062 00063 typedef struct XbusParserCallback XbusParserCallback; 00064 00065 size_t XbusParser_mem(void); 00066 00067 struct XbusParser* XbusParser_create(struct XbusParserCallback const* callback); 00068 00069 void XbusParser_destroy(struct XbusParser* parser); 00070 00071 struct XbusParser* XbusParser_init(void* parserMem, struct XbusParserCallback const* callback); 00072 00073 void XbusParser_parseBuffer(struct XbusParser* parser, uint8_t const* buf, size_t bufSize); 00074 00075 00076 #ifdef __cplusplus 00077 } 00078 #endif // extern "C" 00079 00080 #endif // XBUSPARSER_H
Generated on Wed Jul 13 2022 07:56:15 by 1.7.2