ioLibrary for Cortex M series
Modules | Functions
Common_util
Collaboration diagram for Common_util:

Modules

 Alarm
 
 Base64
 
 Macro Util
 

Functions

int8_t digit_length (int32_t dgt, int8_t base)
 
int32_t str_check (int(*method)(int), int8_t *str)
 
void print_dump (void *buf, uint16_t len)
 
uint16_t checksum (uint8_t *src, uint32_t len)
 

Detailed Description

Function Documentation

int8_t digit_length ( int32_t  dgt,
int8_t  base 
)

Count digit's letter Ex) digit_length(12345, 10) : This will return 5.

Parameters
dgtThe digit value to count
baseDigit base like 2, 8, 10, 16
Returns
>0: Counted digit letter
RET_NOK: Error

Definition at line 199 of file util.c.

References RET_NOK.

int32_t str_check ( int(*)(int)  method,
int8_t *  str 
)

Check string with standard library method. Below is the method you can use.

  • isalpha, isupper, islower
  • isdigit, isxdigit, isalnum
  • isspace, ispunct, isprint
  • isgraph, iscntrl, isascii

Ex) str_check(isdigit, "12345") : This will return RET_OK.
Ex) str_check(islower, "AbcDe") : This will return RET_NOK.

Parameters
methodThe method to use for check
strThe string to check
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 232 of file util.c.

References RET_NOK, and RET_OK.

Referenced by ip_check(), and mac_check().

void print_dump ( void *  buf,
uint16_t  len 
)

Separate string into small peace by delimiter like strtok. But if the input string contains more than one character from delimiter
in a row, strsep returns an empty string for each pair of characters from delimiter.

Ex) strsep("a,b,c,,,f,gh", ",") : When meet ,,, strtok returns 'f' but this returns NULL.

Parameters
stringpString to separate
delimDelimiter
Returns
Next pointer separated by delimiter Print Binary Dump Data.
Parameters
bufThe data to print
lenThe data length

Definition at line 288 of file util.c.

References LOG, LOGA, LOGFA, and NL1.

uint16_t checksum ( uint8_t *  src,
uint32_t  len 
)

Calculate checksum of a stream.

Parameters
srcThe string to calculate checksum.
lenThe string length.
Returns
Checksum

Definition at line 320 of file util.c.