Functions | |
unsigned | fwHw_convertHexToDec (string pHex) |
string | fwHw_convertDecToHex (unsigned pDec) |
dyn_char | fwHw_convertHexToByte (string pHex) |
string | fwHw_convertByteToHex (dyn_char pByte) |
unsigned | fwHw_convertBinToDec (string pBin) |
string | fwHw_convertDecToBin (unsigned pDec) |
dyn_char | fwHw_convertWordsToBytes (dyn_uint pInt, int width) |
dyn_uint | fwHw_convertBytesToWords (dyn_char pChar, int width) |
float | fwHw_convertHexToFloat (string pHex) |
string | fwHw_convertFloatToHex (float pDec) |
bool | fwHw_isHex (string pHex) |
bool | fwHw_isBin (string pBin) |
dyn_char | fwHw_convertStringToByte (string pStr) |
unsigned fwHw_convertBinToDec | ( | string | pBin | ) |
This function converts a binary number (represented as a string) to the corresponding decimal number (unsigned integer).
[in] | pBin | binary number to be converted. |
(...) unsigned result; result = fwHw_convertBinToDec("101110101011"); // convert binary number '101110101011' to the corresponding decimal number DebugTN("Decimal: " + (string) result); // output the result of the conversion (...)
dyn_uint fwHw_convertBytesToWords | ( | dyn_char | pChar, | |
int | width | |||
) |
This function converts an array of Bytes to an array of Words (Integers). The actual buswidth (wordsize) can be specified.
[in] | pChar | array of bytes to be converted. |
[in] | width | specifies the number of bytes to build up a word (buswidth). |
(...) dyn_uint data; dyn_char myData; fwCcpc_LBUSRead("pclbcecs03",0x1000020,FWCCPC_LBUS_BITS_32,3,myData) // reads bytestream into myData data = fwHw_convertBytesToWords(myData,4); // convert bytes array to an array of integers (...)
string fwHw_convertByteToHex | ( | dyn_char | pByte | ) |
This function converts byte(s) (as received from the hardware) to the corresponding hexadecimal number (e.g. textfield on a panel). The first byte becomes the most significant in the hex string.
[in] | pByte | byte(s) to be converted. |
(...) string result; result = fwHw_convertByteToHex(makeDynChar(255, 15, 0)); // convert bytes '255', '15' & '0', // to the corresponding hexadecimal number which reads 'FF0F00'. DebugTN("Hexadecimal: " + result); // output the result of the conversion represented as a string (...)
string fwHw_convertDecToBin | ( | unsigned | pDec | ) |
This function converts an unsigned integer to the corresponding binary representation (string).
[in] | pDec | decimal number to be converted. |
(...) string result; result = fwHw_convertDecToBin(1127); // convert decimal number '1127' to the corresponding binary number DebugTN("Binary: " + result); // output the result of the conversion (...)
string fwHw_convertDecToHex | ( | unsigned | pDec | ) |
This function converts an unsigned integer to the corresponding hexadecimal representation as a string.
[in] | pDec | decimal number to be converted. |
(...) string result; unsigned number = 1127; result = fwHw_convertDecToHex(number); // convert decimal number '1127' to the corresponding hexadecimal string representation DebugTN("Hexadecimal: " + result); // output the result of the conversion (...)
string fwHw_convertFloatToHex | ( | float | pDec | ) |
This function converts a real number to the corresponding hexadecimal number. These functions are aimed to get a simple way to do arithmetic operations from large registers (48 bit counters). (C) provided and used by Herve Chanal, LPC Clermont Ferrand.
[in] | pDec | real number to be converted. |
(...) string result; result = fwHw_convertFloatToHex(1127); // convert decimal number '1127' to the corresponding hexadecimal number DebugTN("Hexadecimal: " + result); // output the result of the conversion (...)
dyn_char fwHw_convertHexToByte | ( | string | pHex | ) |
This function converts an hexadecimal number (represented as a string) to the corresponding array of 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.
[in] | pHex | hexadecimal string to be converted. |
(...) dyn_char result; result = fwHw_convertHexToByte("ff00"); // convert hexadecimal string representation ('ff00') // to the corresponding byte(s): '255' & '0' DebugTN("Byte(s): " + result); // output the result of the conversion (...)
unsigned fwHw_convertHexToDec | ( | string | pHex | ) |
This function converts a string representing a hexadecimal number (e.g. text on panel) into the corresponding decimal number (unsigned integer).
[in] | pHex | hexadecimal number to be converted. |
(...) unsigned result; result = fwHw_convertHexToDec("24e7d"); // convert hexadecimal string representation ('24e7d') to the corresponding decimal number DebugTN("Decimal: " + (string) result); // output the result of the conversion (...)
float fwHw_convertHexToFloat | ( | string | pHex | ) |
This function converts an hexadecimal number to the corresponding real number. It is based on the fwHw_convertHexToDec(string pHex) function. These functions are aimed to get a simple way to do arithmetic operations from large registers (48 bit counters). (C) provided and used by Herve Chanal, LPC Clermont Ferrand
[in] | pHex | hexadecimal number to be converted. Note: if the hexadecimal number is invalid then the returned value will be zero (0). |
(...) float result; result = fwHw_convertHexToFloat("24e7d"); // convert hexadecimal number '24e7d' to the corresponding float number DebugTN("Float: " + (string) result); // output the result of the conversion (...)
dyn_char fwHw_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.
[in] | pStr | string to be converted. |
(...) 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 (...)
dyn_char fwHw_convertWordsToBytes | ( | dyn_uint | pInt, | |
int | width | |||
) |
This function converts an array of Words (Integers) to an array of Bytes. The actual buswidth (wordsize) can be specified.
[in] | pInt | integer array to be converted. |
[in] | width | number of bytes (out of 4) to be used in conversion. |
(...) dyn_char data; string result; data = fwHw_convertWordsToBytes(makeDynInt(0xfeedbabeu,0x12345678u),4); // convert integer array to an array of bytes //fwSpecs_write(makeDynString("myBoard1.myReg01"), makeDynChar(data), ...) result = fwHw_convertByteToHex(data); // gives 'FEEDBABE12345678' (...)
bool fwHw_isBin | ( | string | pBin | ) |
This function checks if the specified binary number is valid or not.
[in] | pBin | binary number. |
false the number is not a valid binary number.
(...) if (fwHw_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 fwHw_isHex | ( | string | pHex | ) |
This function checks if the specified hexadecimal number is valid or not.
[in] | pHex | hexadecimal number. |
false the number is not a valid hexadecimal number.
(...) if (fwHw_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"); (...)