AM263Px MCU+ SDK: ub_strutils.h Source File

| AM263Px MCU+ SDK 26.00.00 |

ub_strutils.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2023 Texas Instruments Incorporated
3 * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4 *
5 * All rights reserved not granted herein.
6 * Limited License.
7 *
8 * Texas Instruments Incorporated grants a world-wide, royalty-free,
9 * non-exclusive license under copyrights and patents it now or hereafter
10 * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11 * this software subject to the terms herein. With respect to the foregoing patent
12 * license, such license is granted solely to the extent that any such patent is necessary
13 * to Utilize the software alone. The patent license shall not apply to any combinations which
14 * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15 * No hardware patent is licensed hereunder.
16 *
17 * Redistributions must preserve existing copyright notices and reproduce this license (including the
18 * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19 * in the documentation and/or other materials provided with the distribution
20 *
21 * Redistribution and use in binary form, without modification, are permitted provided that the following
22 * conditions are met:
23 *
24 * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25 * software provided in binary form.
26 * * any redistribution and use are licensed by TI for use only with TI Devices.
27 * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28 *
29 * If software source code is provided to you, modification and redistribution of the source code are permitted
30 * provided that the following conditions are met:
31 *
32 * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33 * TI for use only with TI Devices.
34 * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35 * works, are licensed by TI for use only with TI Devices.
36 *
37 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38 * promote products derived from this software without specific prior written permission.
39 *
40 * DISCLAIMER.
41 *
42 * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48 * POSSIBILITY OF SUCH DAMAGE.
49 */
60 #ifndef UB_STRUTILS_H_
61 #define UB_STRUTILS_H_
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66
67 typedef uint8_t ub_bytearray8_t[8];
68 typedef ub_bytearray8_t ub_streamid_t;
69
70 typedef uint8_t ub_bytearray6_t[6];
71 typedef ub_bytearray6_t ub_macaddr_t;
72
73
82 void ub_hexdump(bool console, bool debug, unsigned char *buf, int size, int addr);
83
89 void ub_byte2hexstr(uint8_t a, char *astr);
90
99 int ub_hexstr2barray(const char *bstr, uint8_t *bytes, const char delim, int len);
100
109 char *ub_bmac2smac(ub_macaddr_t bmac, char *smac);
110
118 uint8_t *ub_smac2bmac(const char *smac, ub_macaddr_t bmac);
119
128 char *ub_bsid2ssid(ub_streamid_t bsid, char *ssid);
129
137 uint8_t *ub_ssid2bsid(const char *ssid, ub_streamid_t bsid);
138
150 int ub_str2bytearray(uint8_t* dest, const char* input, uint8_t base);
151
162 char* ub_bytearray2str(char * dest, const unsigned char* bytes, int len);
163
171 int ub_find_nospace(const char *astr, int maxn);
172
181 int ub_find_space(const char *astr, int maxn);
182
190 int ub_command_line_parser(char *line, char *argv[], int maxargc);
191
199 int ub_strncpy(char *dest, const char *src, int maxlen);
200
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif
205
ub_bytearray6_t
uint8_t ub_bytearray6_t[6]
6-byte binary array
Definition: ub_strutils.h:70
ub_streamid_t
ub_bytearray8_t ub_streamid_t
8-byte binary array is used for Stream ID
Definition: ub_strutils.h:68
ub_ssid2bsid
uint8_t * ub_ssid2bsid(const char *ssid, ub_streamid_t bsid)
convert a string type stream id('XX:XX:XX:XX:XX:XX:XX:XX' format) to a binary type stream id
ub_bmac2smac
char * ub_bmac2smac(ub_macaddr_t bmac, char *smac)
convert a binary type mac address to a string type mac address('XX:XX:XX:XX:XX:XX' format)
ub_hexdump
void ub_hexdump(bool console, bool debug, unsigned char *buf, int size, int addr)
dump out data in hex format to the console
ub_hexstr2barray
int ub_hexstr2barray(const char *bstr, uint8_t *bytes, const char delim, int len)
convert array of 2-digit hex string
ub_find_space
int ub_find_space(const char *astr, int maxn)
look for space charcter and return the number of passed characters
ub_strncpy
int ub_strncpy(char *dest, const char *src, int maxlen)
copy a string
ub_command_line_parser
int ub_command_line_parser(char *line, char *argv[], int maxargc)
parse a command line string and make argc,argv[] for main function,
ub_macaddr_t
ub_bytearray6_t ub_macaddr_t
6-byte binary array is used for MAC Address
Definition: ub_strutils.h:71
ub_smac2bmac
uint8_t * ub_smac2bmac(const char *smac, ub_macaddr_t bmac)
convert a string type mac address('XX:XX:XX:XX:XX:XX' format) to a binary type mac address.
ub_str2bytearray
int ub_str2bytearray(uint8_t *dest, const char *input, uint8_t base)
convert a string type byte array('01,00,1e,00,00,03,....02,00,01') to a byte array
ub_bytearray8_t
uint8_t ub_bytearray8_t[8]
8-byte binary array
Definition: ub_strutils.h:67
ub_bytearray2str
char * ub_bytearray2str(char *dest, const unsigned char *bytes, int len)
convert a byte array to a string type byte array('01,00,1e,00,00,03,....02,00,01')
ub_find_nospace
int ub_find_nospace(const char *astr, int maxn)
look for non space charcter and return the number of passed characters
ub_bsid2ssid
char * ub_bsid2ssid(ub_streamid_t bsid, char *ssid)
convert a binary type stream id to a string type stream id ('XX:XX:XX:XX:XX:XX:XX:XX' format)
ub_byte2hexstr
void ub_byte2hexstr(uint8_t a, char *astr)
convert a byte to 2-digit hex string