Firmware enhancements for HSP_RPC_GUI 3.0.1

Dependencies:   USBDevice

Fork of HSP_RPC_GUI by Maxim Integrated

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers StringHelper.h Source File

StringHelper.h

00001 /*******************************************************************************
00002  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *******************************************************************************
00032  */
00033 #ifndef _STRINGHELPER_H_
00034 #define _STRINGHELPER_H_
00035 
00036 #include "mbed.h"
00037 
00038 /**
00039 * @brief Process an array of hex alpha numeric strings representing arguments of
00040 * type uint8
00041 * @param args Array of strings to process
00042 * @param argsUintPtr Pointer of uint8 to save converted arguments
00043 * @param numberOf Number of strings to convert
00044 */
00045 void ProcessArgs(char args[32][32], uint8_t *argsUintPtr, int numberOf);
00046 /**
00047 * @brief Format a binary 8-bit array into a string
00048 * @param uint8Ptr byte buffer to process
00049 * @param numberOf number of bytes in the buffer
00050 * @param reply an array of strings to place the converted array values into
00051 */
00052 void FormatReply(uint8_t *uint8Ptr, int numberOf, char reply[32][32]);
00053 /**
00054 * @brief Process an array of hex alpha numeric strings representing arguments of
00055 * type uint32
00056 * @param args Array of strings to process
00057 * @param argsUintPtr Pointer of uint32 to save converted arguments
00058 * @param numberOf Number of strings to convert
00059 */
00060 void ProcessArgs32(char args[32][32], uint32_t *argsUintPtr, int numberOf);
00061 /**
00062 * @brief Process an array of decimal numeric strings representing arguments of
00063 * type uint32
00064 * @param args Array of strings to process
00065 * @param argsUintPtr Pointer of uint32 to save converted arguments
00066 * @param numberOf Number of strings to convert
00067 */
00068 void ProcessArgs32Dec(char args[32][32], uint32_t *argsUintPtr, int numberOf);
00069 /**
00070 * @brief Format a binary 32-bit array into a string
00071 * @param uint32Ptr 32-bit value buffer to process
00072 * @param numberOf number of values in the buffer
00073 * @param reply an array of strings to place the converted array values into
00074 */
00075 void FormatReply32(uint32_t *uint32Ptr, int numberOf, char reply[32][32]);
00076 /**
00077 * @brief Parse an incoming string hex value into an 8-bit value
00078 * @param str string to process
00079 * @returns 8-bit byte that is parsed from the string
00080 */
00081 uint8_t StringToByte(char str[32]);
00082 /**
00083 * @brief Parse an incoming string hex value into 32-bit value
00084 * @param str string to process
00085 * @returns 32-bit value that is parsed from the string
00086 */
00087 uint32_t StringToInt(char str[32]);
00088 /**
00089 * @brief Parse a single string in decimal format to a uint32 number
00090 * @param str String to process
00091 * @returns Returns the converted number of type uint32
00092 */
00093 uint32_t ParseAsciiDecU32(char *str);
00094 /**
00095 * @brief Parse a single string in hex format to a uint32 number
00096 * @param str String to process
00097 * @returns Returns the converted number of type uint32
00098 */
00099 uint32_t ParseAsciiHexU32(char *str);
00100 /**
00101 * @brief Format a binary 8-bit array into a string
00102 * @param data 8-bit value buffer to process
00103 * @param length number of values in the buffer
00104 * @param str output string buffer
00105 * @return output string
00106 */
00107 char *BytesToHexStr(uint8_t *data, uint32_t length, char *str);
00108 /**
00109 * @brief Parse an incoming string until a CRLF is encountered, dst will contain
00110 * the parsed string
00111 * @param src source string to process
00112 * @param dst destination string to contain the parsed incoming string
00113 * @param length length of incoming src string
00114 * @returns updated pointer in src string
00115 */
00116 char *ParseUntilCRLF(char *src, char *dst, int length);
00117 
00118 #endif // _STRINGHELPER_H_