fnBufferHex()

CHAR *fnBufferHex(unsigned long ulValue, unsigned char ucStyle, CHAR *ptrBuf);

ulValue is an unsigned long value to be converted to an ASCII HEX string in the output buffer pointed to by ptrBuf.
The conversion style is defined by ucStyle, which can be a mixture of following flags:
The length of the hexadecimal input is also included in the ucStyle parameter, with valid values of 1, 2 or 4 (the number of bytes in the value).

The function returns a pointer to the last character in the buffer (generally the NULL-terminator). This pointer allows simple concatenation since following string fragments can be added using this pointer.

Examples

Example of converting a MAC address into a formatted hex string output

// Convert a MAC address to a string
//
extern CHAR *fnMACStr(unsigned char *ptrMAC, CHAR *cStr)
{
    int i = MAC_LENGTH;

    while (--i) {
        cStr = fnBufferHex(*ptrMAC++, (unsigned char)(1 | NO_LEADIN | NO_TERMINATOR), cStr);
        *cStr++ = MAC_DELIMITER;
    }
    return (fnBufferHex(*ptrMAC++, (unsigned char)(1 | NO_LEADIN | WITH_TERMINATOR), cStr));
}

Related functions

fnBufferDec();
fnDebugHex();
fnHexStrHex();
fnDecStrHex();




Please use the µTasker forum to ask specific questions.