Functions | Variables
hex_bytes.c File Reference

Routines for converting between byte arrays and hex strings. More...

#include <stdlib.h>
#include "tm_reader.h"
#include "serial_reader_imp.h"
Include dependency graph for hex_bytes.c:

Go to the source code of this file.

Functions

void TMR_bytesToHex (const uint8_t *bytes, uint32_t size, char *hex)
void TMR_hexDottedQuad (const uint8_t bytes[4], char buf[12])
TMR_Status TMR_hexDottedQuadToUint32 (const char bytes[12], uint32_t *result)
TMR_Status TMR_hexToBytes (const char *hex, uint8_t *bytes, uint32_t size, uint32_t *convertLen)

Variables

static char hexchars [] = "0123456789ABCDEF"

Detailed Description

Routines for converting between byte arrays and hex strings.

Author:
Nathan Williams
Date:
10/23/2009

Definition in file hex_bytes.c.


Function Documentation

void TMR_bytesToHex ( const uint8_t *  bytes,
uint32_t  size,
char *  hex 
)

Convert an array of bytes, such as a tag EPC, into a hexadecimal string.

Parameters:
bytesThe byte array to convert.
sizeThe length of the byte array to convert.
[out]hexThe converted hexadecimal string, null-terminated.
Test:
If size is 0, *hex should point to an empty string.

Definition at line 83 of file hex_bytes.c.

void TMR_hexDottedQuad ( const uint8_t  bytes[4],
char  buf[12] 
)

Convert a four-byte array into a null-terminated string with the format %02X.%02X.%02X.%02X (AA.BB.CC.DD).

Parameters:
bytesThe array of four bytes to convert
bufThe string to write to. Must be at least 12 bytes.

Definition at line 103 of file hex_bytes.c.

TMR_Status TMR_hexDottedQuadToUint32 ( const char  bytes[12],
uint32_t *  result 
)

Convert a 12-byte null-terminated string hexDottedQuad into a uint32_t

Parameters:
bytesThe array of twelve bytes to convert
resultThe resulting uint32_t
Returns:
uint32_t represented but the 12 bytes

Definition at line 125 of file hex_bytes.c.

TMR_Status TMR_hexToBytes ( const char *  hex,
uint8_t *  bytes,
uint32_t  size,
uint32_t *  convertLen 
)

Convert a hexadecimal string into an array of bytes. The string may optionally include a "0x" prefix, which will be ignored.

Parameters:
hexThe hexadecimal string to convert.
[out]bytesThe array to store the converted bytes.
sizeThe length of the byte array to store into.
[out]convertLenThe number of bytes written to the array, or NULL.
Test:

If hex string is empty, *bytes should not be altered.

*convertLen is set to the correct value.

Function works when convertLen is NULL.

Specific values: "00", "0000", "ffff", "0xffff", "00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabb".

Definition at line 40 of file hex_bytes.c.


Variable Documentation

char hexchars[] = "0123456789ABCDEF" [static]

Definition at line 36 of file hex_bytes.c.



thingmagic_rfid
Author(s): Brian Bingham
autogenerated on Thu May 16 2019 03:01:24