NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Functions
Conversion Functions

Functions

char * ndiErrorString (int errnum)
 
unsigned long ndiHexToUnsignedLong (const char *cp, int n)
 
long ndiSignedToLong (const char *cp, int n)
 
char * ndiHexEncode (char *cp, const void *data, int n)
 
voidndiHexDecode (void *data, const char *cp, int n)
 
static char * plErrorString (int errnum)
 
static unsigned long plHexToUnsignedLong (const char *cp, int n)
 
static long plSignedToLong (const char *cp, int n)
 
static char * plHexEncode (char *cp, const void *data, int n)
 
static voidplHexDecode (void *data, const char *cp, int n)
 

Detailed Description

These are a set of helper functions for doing miscellaneous conversions to and from ascii.

Function Documentation

char* ndiErrorString ( int  errnum)

Convert an error code returned by ndiGetError() into a string that describes the error. The error codes are listed in Error Codes.

An unrecognized error code will return "Unrecognized error code".

void* ndiHexDecode ( void data,
const char *  cp,
int  n 
)

This function converts a hex-encoded string into binary data. This can be used to decode the SROM data sent from the device. The length of the input string must be twice the expected number of bytes in the output data, since each binary byte is ecoded by two hexidecimal digits.

As a convenience, the return value is a pointer to the decoded data.

char* ndiHexEncode ( char *  cp,
const void data,
int  n 
)

This function is used to convert raw binary data into a stream of hexidecimal digits that can be sent to the device. The length of the output string will be twice the number of bytes in the input data, since each byte will be represented by two hexidecimal digits.

As a convenience, the return value is a pointer to the hexidecimal string. If the string must be terminated, then set cp[2*n] to '\0' before calling this function, otherwise the string will be left unterminated.

unsigned long ndiHexToUnsignedLong ( const char *  cp,
int  n 
)

Convert n characters of a hexidecimal string into an unsigned long. The conversion halts if a non-hexidecimal digit is found.

The primary use of this function is decoding replies from the device.

long ndiSignedToLong ( const char *  cp,
int  n 
)

Convert n characters of a signed decimal string to a long. The first character in the string must be '+' or '-', otherwise the result will be zero.

The primary use of this function is decoding replies from the device.

static char* plErrorString ( int  errnum)
static

Convert an error code returned by plGetError() into a string that describes the error. The error codes are listed in Error Codes.

An unrecognized error code will return "Unrecognized error code".

static void* plHexDecode ( void data,
const char *  cp,
int  n 
)
static

This function converts a hex-encoded string into binary data. This can be used to decode the SROM data sent from the POLARIS. The length of the input string must be twice the expected number of bytes in the output data, since each binary byte is ecoded by two hexidecimal digits.

As a convenience, the return value is a pointer to the decoded data.

static char* plHexEncode ( char *  cp,
const void data,
int  n 
)
static

This function is used to convert raw binary data into a stream of hexidecimal digits that can be sent to the POLARIS. The length of the output string will be twice the number of bytes in the input data, since each byte will be represented by two hexidecimal digits.

As a convenience, the return value is a pointer to the hexidecimal string. If the string must be terminated, then set cp[2*n] to '\0' before calling this function, otherwise the string will be left unterminated.

static unsigned long plHexToUnsignedLong ( const char *  cp,
int  n 
)
static

Convert n characters of a hexidecimal string into an unsigned long. The conversion halts if a non-hexidecimal digit is found.

The primary use of this function is decoding replies from the POLARIS.

static long plSignedToLong ( const char *  cp,
int  n 
)
static

Convert n characters of a signed decimal string to a long. The first character in the string must be '+' or '-', otherwise the result will be zero.

The primary use of this function is decoding replies from the POLARIS.