Alex exoskeleton
ALEX SoftwareDocumentation
|
#include "CO_comm_helpers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
Go to the source code of this file.
Functions | |
int | dtpHex (char *strout, int stroutSize, char *bufSdo, int bufLen) |
int | dtsHex (char *bufSdo, int bufSdoSize, char *strin) |
char * | getTok (char *initStr, const char *delim, int *err) |
void | lastTok (char *initStr, const char *delim, int *err) |
uint32_t | getU32 (char *token, uint32_t min, uint32_t max, int *err) |
int32_t | getI32 (char *token, int32_t min, int32_t max, int *err) |
uint64_t | getU64 (char *token, uint64_t min, uint64_t max, int *err) |
int64_t | getI64 (char *token, int64_t min, int64_t max, int *err) |
float32_t | getR32 (char *token, int *err) |
float64_t | getR64 (char *token, int *err) |
const dataType_t * | getDataType (char *token, int *err) |
Variables | |
const char | spaceDelim [] = " \t\n\r\f\v" |
int dtpHex | ( | char * | strout, |
int | stroutSize, | ||
char * | bufSdo, | ||
int | bufLen | ||
) |
Data type print function.
Functions writes binary data from bufSdo to strout (with sprintf). dtpHex outputs in hex format (two hex digits, space separated). There are other dtp functions inside dataTypes[] array.
strout | Output string. |
bufSdo | Input binary data. |
bufLen | Size of input binary data. |
Definition at line 44 of file CO_comm_helpers.c.
int dtsHex | ( | char * | bufSdo, |
int | bufSdoSize, | ||
char * | strin | ||
) |
Data type scan function.
Functions scans input string string and writes binary data to bufSdo. dtsHex scans from hex format (two hex digits, space separated). There are other dts functions inside dataTypes[] array.
bufSdo | Output binary data. |
strin | Input string. |
Definition at line 110 of file CO_comm_helpers.c.
const dataType_t* getDataType | ( | char * | token, |
int * | err | ||
) |
Get data type from token.
Token must exactly match one of the 'syntax' from dataTypes[].
token | Input string. |
err | Input and returning parameter sets to true in case of error. If err is already true, function returns 0 immediately. |
Definition at line 385 of file CO_comm_helpers.c.
int32_t getI32 | ( | char * | token, |
int32_t | min, | ||
int32_t | max, | ||
int * | err | ||
) |
Definition at line 290 of file CO_comm_helpers.c.
int64_t getI64 | ( | char * | token, |
int64_t | min, | ||
int64_t | max, | ||
int * | err | ||
) |
Definition at line 328 of file CO_comm_helpers.c.
float32_t getR32 | ( | char * | token, |
int * | err | ||
) |
Definition at line 347 of file CO_comm_helpers.c.
float64_t getR64 | ( | char * | token, |
int * | err | ||
) |
Definition at line 366 of file CO_comm_helpers.c.
char* getTok | ( | char * | initStr, |
const char * | delim, | ||
int * | err | ||
) |
Get token from currently parsing string.
Function calls thread safe strtok_r function and returns token. getTok itself may be used from one thread only.
initStr | Same as first argument to strtok_r. |
delim | Same as second argument to strtok_r. |
err | Input and returning parameter sets to true in case of error. If err is already true, function returns NULL immediately. |
Definition at line 241 of file CO_comm_helpers.c.
Get number from token.
Token must contain no other characters and number must be inside limits.
token | Input string. |
min | Minimum value for the output number. |
max | Maximum value for the output number. |
err | Input and returning parameter sets to true in case of error. If err is already true, function returns 0 immediately. |
Definition at line 271 of file CO_comm_helpers.c.
uint64_t getU64 | ( | char * | token, |
uint64_t | min, | ||
uint64_t | max, | ||
int * | err | ||
) |
Definition at line 309 of file CO_comm_helpers.c.
void lastTok | ( | char * | initStr, |
const char * | delim, | ||
int * | err | ||
) |
Verify, if there are no more tokens.
Function calls getTok and if there is another token and that token doesn't start with '#', it sets err to 1. (Comments are ignored.)
initStr | Same as in getTok. |
delim | Same as in getTok. |
err | Same as in getTok. |
Definition at line 257 of file CO_comm_helpers.c.
const char spaceDelim[] = " \t\n\r\f\v" |
Definition at line 36 of file CO_comm_helpers.c.