Conversion Functions


Functions

unsigned fwSpecs_convertHexToDec (string pHex)
string fwSpecs_convertDecToHex (unsigned pDec)
dyn_char fwSpecs_convertHexToByte (string pHex)
string fwSpecs_convertByteToHex (dyn_char pByte)
unsigned fwSpecs_convertBinToDec (string pBin)
string fwSpecs_convertDecToBin (unsigned pDec)
bool fwSpecs_isHex (string pHex)
bool fwSpecs_isBin (string pBin)
dyn_char fwSpecs_convertStringToByte (string pStr)

Detailed Description

List of conversion functions available to the user.

Function Documentation

unsigned fwSpecs_convertBinToDec ( string  pBin  ) 

This function converts an binary number to the corresponding decimal number.

Parameters:
[in] pBin binary number to be converted.
Returns:
unsigned decimal number.
Example:

  (...)
  unsigned result;

  result = fwSpecs_convertBinToDec("101110101011");   // convert binary number '101110101011' to the corresponding decimal number
  DebugTN("Decimal: " + (string) result);   // output the result of the conversion
  (...)



string fwSpecs_convertByteToHex ( dyn_char  pByte  ) 

This function converts byte(s) to the corresponding hexadecimal number.

Parameters:
[in] pByte byte(s) to be converted.
Returns:
string hexadecimal number.
Example:

  (...)
  string result;

  result = fwSpecs_convertByteToHex(makeDynChar(41, 42, 43));   // convert bytes '41', '42' & '43', to the corresponding hexadecimal number
  DebugTN("Hexadecimal: " + result);   // output the result of the conversion
  (...)



string fwSpecs_convertDecToBin ( unsigned  pDec  ) 

This function converts an decimal number to the corresponding binary number.

Parameters:
[in] pDec decimal number to be converted.
Returns:
string binary number.
Example:

  (...)
  string result;

  result = fwSpecs_convertDecToBin(1127);   // convert decimal number '1127' to the corresponding binary number
  DebugTN("Binary: " + result);   // output the result of the conversion
  (...)



string fwSpecs_convertDecToHex ( unsigned  pDec  ) 

This function converts an decimal number to the corresponding hexadecimal number.

Parameters:
[in] pDec decimal number to be converted.
Returns:
string hexadecimal number.
Example:

  (...)
  string result;

  result = fwSpecs_convertDecToHex(1127);   // convert decimal number '1127' to the corresponding hexadecimal number
  DebugTN("Hexadecimal: " + result);   // output the result of the conversion
  (...)



dyn_char fwSpecs_convertHexToByte ( string  pHex  ) 

This function converts an hexadecimal number to the corresponding byte(s).

Parameters:
[in] pHex hexadecimal number to be converted.
Returns:
dyn_char byte(s).
Example:

  (...)
  dyn_char result;

  result = fwSpecs_convertHexToByte("24e7d");   // convert hexadecimal number '24e7d' to the corresponding byte(s)
  DebugTN("Byte(s): " + result);   // output the result of the conversion
  (...)



unsigned fwSpecs_convertHexToDec ( string  pHex  ) 

This function converts an hexadecimal number to the corresponding decimal number.

Parameters:
[in] pHex hexadecimal number to be converted.
Returns:
unsigned decimal number.
Example:

  (...)
  unsigned result;

  result = fwSpecs_convertHexToDec("24e7d");   // convert hexadecimal number '24e7d' to the corresponding decimal number
  DebugTN("Decimal: " + (string) result);   // output the result of the conversion
  (...)



dyn_char fwSpecs_convertStringToByte ( string  pStr  ) 

This function converts a string to the corresponding array of ASCII byte(s). Each byte is represented as a char. A byte stream is regularly used as input or output of the fwCcpc framework. (e.g. writing or reading memory blocks) When debugging in the PVSS PARA module you are prompted the ASCII representation of the byte value. The array starts with the most significant byte.

Parameters:
[in] pStr string to be converted.
Returns:
dyn_char byte(s).
Example:

  (...)
  dyn_char result;

  result = fwHw_convertStringToByte("this is a test");   // convert to ascii string representation 
                                         
  DebugTN("Byte(s): " + result);   // output the result of the conversion
  (...)



bool fwSpecs_isBin ( string  pBin  ) 

This function checks if the specified binary number is valid or not.

Parameters:
[in] pBin binary number.
Returns:
true the number is a valid binary number.

false the number is not a valid binary number.

Example:

  (...)
  if (fwSpecs_isBin("1101011101"))   // check if the binary number '1101011101' is valid
     DebugTN("The number is a valid binary number");
  else
     DebugTN("The number is not a valid binary number");
  (...)



bool fwSpecs_isHex ( string  pHex  ) 

This function checks if the specified hexadecimal number is valid or not.

Parameters:
[in] pHex hexadecimal number.
Returns:
true the number is a valid hexadecimal number.

false the number is not a valid hexadecimal number.

Example:

  (...)
  if (fwSpecs_isHex("24e7d"))   // check if the hexadecimal number '24e7d' is valid
     DebugTN("The number is a valid hexadecimal number");
  else
     DebugTN("The number is not a valid hexadecimal number");
  (...)




Generated on Fri Mar 28 13:36:50 2008 for FwSpecs by  doxygen 1.4.7