/**
* \file DebugPrint.c
* \brief Print raw data formatted in hex.
* \author Roman Pasechnik (r.pasechnik@samsung.com)
* \version 0.1
* \date Created Apr 14, 2014
* \par In Samsung Ukraine R&D Center (SURC) under a contract between
* \par LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and
* \par "Samsung Elecrtronics Co", Ltd (Seoul, Republic of Korea)
* \par Copyright: (c) Samsung Electronics Co, Ltd 2012. All rights reserved.
**/

#include "DebugPrint.h"
#include "log.h"

void debugPrintRawData(const uint8_t *data, int len)
{
	char buf[64];
	int bufLen = 0;
	int pos = 0;
	char table[] = {'0', '1', '2', '3', '4', '5', '6', '7',
			'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
	while(1)
	{
		if (pos >= len) {
			break;
		}
		buf[bufLen++] = table[data[pos] >> 4];
		buf[bufLen++] = table[data[pos] & 0xF];
		buf[bufLen++] = ' ';
		pos++;
		if (bufLen >= 24) {
			buf[bufLen++] = 0;
			LOGD("%s", buf);
			bufLen = 0;
		}
	}
	if (bufLen > 0) {
		buf[bufLen++] = 0;
		LOGD("%s", buf);
	}
}
