Alex exoskeleton
ALEX SoftwareDocumentation
Classes | Enumerations | Functions | Variables
CO_comm_helpers.h File Reference
#include <CO_driver.h>
#include "CO_SDO.h"
Include dependency graph for CO_comm_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dataType_t
 Data types structure - Defined in CANOpen Code. More...
 

Enumerations

enum  respErrorCode_t {
  respErrorNone = 0, respErrorReqNotSupported = 100, respErrorSyntax = 101, respErrorInternalState = 102,
  respErrorNoDefaultNodeSet = 105, respErrorUnsupportedNet = 106, respErrorUnsupportedNode = 107
}
 

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_tgetDataType (char *token, int *err)
 

Variables

const char spaceDelim []
 

Detailed Description

Command interface for CANopenSocket - ASCII helper functions.

Author
Janez Paternoster

This file is part of CANopenSocket, a Linux implementation of CANopen stack with master functionality. Project home page is https://github.com/CANopenNode/CANopenSocket. CANopenSocket is based on CANopenNode: https://github.com/CANopenNode/CANopenNode.

CANopenSocket is free and open source software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file CO_comm_helpers.h.

Enumeration Type Documentation

Response errors as specified by CiA 309-3.

Enumerator
respErrorNone 
respErrorReqNotSupported 
respErrorSyntax 
respErrorInternalState 
respErrorNoDefaultNodeSet 
respErrorUnsupportedNet 
respErrorUnsupportedNode 

Definition at line 38 of file CO_comm_helpers.h.

Function Documentation

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.

Parameters
stroutOutput string.
bufSdoInput binary data.
bufLenSize of input binary data.
Returns
Number of bytes written to strout.

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.

Parameters
bufSdoOutput binary data.
strinInput string.
Returns
Number of bytes written to bufSdo, 0 on failure.

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[].

Parameters
tokenInput string.
errInput and returning parameter sets to true in case of error. If err is already true, function returns 0 immediately.
Returns
Number.

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.

Parameters
initStrSame as first argument to strtok_r.
delimSame as second argument to strtok_r.
errInput and returning parameter sets to true in case of error. If err is already true, function returns NULL immediately.
Returns
Next token or NULL.

Definition at line 241 of file CO_comm_helpers.c.

uint32_t getU32 ( char *  token,
uint32_t  min,
uint32_t  max,
int *  err 
)

Get number from token.

Token must contain no other characters and number must be inside limits.

Parameters
tokenInput string.
minMinimum value for the output number.
maxMaximum value for the output number.
errInput and returning parameter sets to true in case of error. If err is already true, function returns 0 immediately.
Returns
Number.

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.)

Parameters
initStrSame as in getTok.
delimSame as in getTok.
errSame as in getTok.

Definition at line 257 of file CO_comm_helpers.c.

Variable Documentation

const char spaceDelim[]

Definition at line 36 of file CO_comm_helpers.c.