Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: modem_ref_helper_for_v5_3_217
kal_codec.h File Reference
========================================================================={{{ Copyright (c) 20XX / All rights reserved / / IMPORTANT: This Software may not be modified, copied or distributed unless / embedded on a WizziLab product. More...
Go to the source code of this file.
Data Structures | |
union | kal_ctf_t |
D7A compressed time format. More... | |
Functions | |
void | hex2ascii (char *in, char *out, u16 length) |
Convert hexadecimal number to ascii. | |
char * | itoa (int value, char *result, int base) |
Converts an integer value to a null-terminated string using the specified base and stores the result in the array given by result parameter. | |
int | atoitok (u8 **p) |
Extracts from a ASCII string a value (decimal or hex) and convert it to an integer value. | |
s32 | kal_atoi (u8 *s) |
Extracts from a ASCII string a decimal value and convert it to an integer value. | |
s32 | kal_atoi_float (u8 *s, u8 d) |
Extracts from a ASCII string a float value and convert it to an integer value * 10^number_of_decimals. | |
u32 | kal_atoi_hex (u8 *s) |
Extracts from a ASCII string a hex value and convert it to an integer value. | |
u16 | kal_base64_strlen (const char *in) |
Real length (excluding padding) of Base64-encoded string Note : the input string always has 4x chars, if not return 0. | |
void | kal_base64_encode (char *out, u8 *in, u16 len) |
Encode Base64-encoded buffer. | |
void | kal_base64_decode (u8 *out, const char *in, u16 len) |
Decode Base64-encoded buffer. | |
void | kal_tolower (u8 *s) |
Changes inplace to lower character a non-constant string. | |
void | kal_toupper (u8 *s) |
Changes inplace to upper character a non-constant string. | |
u8 | kal_crc8 (u8 *in, u32 len) |
Generate crc8. | |
kal_ctf_t | kal_ctf_encode (u32 val, u8 ceil) |
Compress u32 to D7A Compressed Time format (CTF). | |
u32 | kal_ctf_decode (kal_ctf_t ctf) |
Decompress from Compressed Time Format to u32. |
Detailed Description
========================================================================={{{ Copyright (c) 20XX / All rights reserved / / IMPORTANT: This Software may not be modified, copied or distributed unless / embedded on a WizziLab product.
Other than for the foregoing purpose, this / Software and/or its documentation may not be used, reproduced, copied, / prepared derivative works of, modified, performed, distributed, displayed / or sold for any purpose. For the sole purpose of embedding this Software / on a WizziLab product, copy, modification and distribution of this / Software is granted provided that the following conditions are respected: / / Redistributions of source code must retain the above copyright notice, / this list of conditions and the following disclaimer / / Redistributions in binary form must reproduce the above copyright / notice, this list of conditions and the following disclaimer in the / documentation and/or other materials provided with the distribution. / / The name of WizziLab can not be used to endorse or promote products / derived from this software without specific prior written permission. / / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS / "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED / TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR / PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR / CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, / EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, / PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, / OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY / OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING / NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS / SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. / WIZZILAB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, / ENHANCEMENTS OR MODIFICATIONS. / / Should you have any questions regarding your right to use this Software, / contact WizziLab at www.wizzilab.com. / / =========================================================================}}} KAL utilities s
Definition in file kal_codec.h.
Function Documentation
int atoitok | ( | u8 ** | p ) |
Extracts from a ASCII string a value (decimal or hex) and convert it to an integer value.
- Blank characters are skipped
- hexa values must begin with '0x' or '0X'
- '-' sign is handled
- returns after one value has been parsed or null character or CR character has been found.
- Parameters:
-
p pointer to pointer to the string to be parsed. The pointer to string is modified: at the end of the call it points to the character following the last parsed one.
Definition at line 134 of file kal_codec.cpp.
void hex2ascii | ( | char * | in, |
char * | out, | ||
u16 | length | ||
) |
Convert hexadecimal number to ascii.
- Parameters:
-
char* in input buffer (hex) char* out output buffer (ascii) u16 len length of inoput buffer in bytes
Definition at line 74 of file kal_codec.cpp.
char* itoa | ( | int | value, |
char * | result, | ||
int | base | ||
) |
Converts an integer value to a null-terminated string using the specified base and stores the result in the array given by result parameter.
- Parameters:
-
int value integer to convert char* result converted string int base base used for conversion 2, 8, 10, 16
- Returns:
- A pointer to the resulting null-terminated string, same as parameter result
Definition at line 94 of file kal_codec.cpp.
s32 kal_atoi | ( | u8 * | s ) |
Extracts from a ASCII string a decimal value and convert it to an integer value.
'-' sign is handled
- Parameters:
-
s char* string to convert
- Return values:
-
s32 integer value
'-' and '+' signs are handled
- Parameters:
-
s char* string to convert
- Return values:
-
s32 integer value
Definition at line 179 of file kal_codec.cpp.
s32 kal_atoi_float | ( | u8 * | s, |
u8 | d | ||
) |
Extracts from a ASCII string a float value and convert it to an integer value * 10^number_of_decimals.
'-' and '+' signs are handled
- Parameters:
-
s char* string to convert d u8 Number of decimals
- Return values:
-
s32 integer value
Definition at line 213 of file kal_codec.cpp.
u32 kal_atoi_hex | ( | u8 * | s ) |
Extracts from a ASCII string a hex value and convert it to an integer value.
- Parameters:
-
s char* string to convert
- Return values:
-
u32 integer value
Definition at line 276 of file kal_codec.cpp.
void kal_base64_decode | ( | u8 * | out, |
const char * | in, | ||
u16 | len | ||
) |
Decode Base64-encoded buffer.
The output buffer is supposed to have enough space
- Parameters:
-
out u8* binary buffer result in char* string to decode len u16 string length, excluding padding
- Return values:
-
void
Definition at line 406 of file kal_codec.cpp.
void kal_base64_encode | ( | char * | out, |
u8 * | in, | ||
u16 | len | ||
) |
Encode Base64-encoded buffer.
The output buffer is supposed to have enough space Beware, the stream encoding is Big Endian.
- Parameters:
-
out char* string result in u8* binary buffer to encode len u16 length of the binary buffer in bytes
- Return values:
-
void
Definition at line 354 of file kal_codec.cpp.
u16 kal_base64_strlen | ( | const char * | in ) |
Real length (excluding padding) of Base64-encoded string Note : the input string always has 4x chars, if not return 0.
- Parameters:
-
in char* string to decode
- Return values:
-
u16 string length
Definition at line 304 of file kal_codec.cpp.
u8 kal_crc8 | ( | u8 * | in, |
u32 | len | ||
) |
Generate crc8.
- Parameters:
-
in u8* input buffer len u32 input buffer length in bytes
- Return values:
-
void
Generate crc8.
A table-based algorithm would be faster, but for only a few bytes it isn't worth the code size.
- Parameters:
-
in u8* input buffer len u32 input buffer length in bytes
- Return values:
-
void
Definition at line 489 of file kal_codec.cpp.
u32 kal_ctf_decode | ( | kal_ctf_t | ctf ) |
Decompress from Compressed Time Format to u32.
- Parameters:
-
ctf kal_ctf_t compressed value in CTF
- Return values:
-
u32 decode result
Definition at line 577 of file kal_codec.cpp.
kal_ctf_t kal_ctf_encode | ( | u32 | val, |
u8 | ceil | ||
) |
Compress u32 to D7A Compressed Time format (CTF).
The ceil flag is used to define rounding, so that kal_ctf_decode(kal_ctf_encode(val, FALSE) <= val (floor) kal_ctf_decode(kal_ctf_encode(val, TRUE) >= val (ceiling)
- Parameters:
-
val u32 value to encode ceil u8 ceil value when TRUE
- Return values:
-
kal_ctf_t compressed value
Definition at line 522 of file kal_codec.cpp.
void kal_tolower | ( | u8 * | s ) |
Changes inplace to lower character a non-constant string.
- Parameters:
-
s u8* String to transform
- Return values:
-
void
Definition at line 444 of file kal_codec.cpp.
void kal_toupper | ( | u8 * | s ) |
Changes inplace to upper character a non-constant string.
- Parameters:
-
s u8* String to transform
- Return values:
-
void
Definition at line 464 of file kal_codec.cpp.
Generated on Wed Jul 20 2022 12:33:07 by
