this is using the mbed os version 5-13-1

Dependencies:   mbed-http

Committer:
ocomeni
Date:
Thu May 02 21:50:17 2019 +0000
Revision:
103:7b566b522427
Child:
104:11e9605093c9
reached cloud hello message in box comms sequence

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ocomeni 103:7b566b522427 1 /**
ocomeni 103:7b566b522427 2 ******************************************************************************
ocomeni 103:7b566b522427 3 * @file debug.c
ocomeni 103:7b566b522427 4 * @brief Source file containing logic responsible for:
ocomeni 103:7b566b522427 5 * @details
ocomeni 103:7b566b522427 6 *
ocomeni 103:7b566b522427 7 ******************************************************************************
ocomeni 103:7b566b522427 8 * @author TTP
ocomeni 103:7b566b522427 9 * @copyright (c) 2017 TTP (The Technology Partnership) plc
ocomeni 103:7b566b522427 10 *
ocomeni 103:7b566b522427 11 ******************************************************************************
ocomeni 103:7b566b522427 12 */
ocomeni 103:7b566b522427 13
ocomeni 103:7b566b522427 14 //-------- Includes ----------------------------------------------------------//
ocomeni 103:7b566b522427 15
ocomeni 103:7b566b522427 16 #include "debug.h"
ocomeni 103:7b566b522427 17 #include <mbed.h>
ocomeni 103:7b566b522427 18 //#include "clocks.h"
ocomeni 103:7b566b522427 19
ocomeni 103:7b566b522427 20 //-------- Defines -----------------------------------------------------------//
ocomeni 103:7b566b522427 21
ocomeni 103:7b566b522427 22 #define FILE_CODE "dbgm"
ocomeni 103:7b566b522427 23 #define ERROR "err"
ocomeni 103:7b566b522427 24
ocomeni 103:7b566b522427 25 #define DBG_RX_BUFFER_SIZE_BYTES (1024)
ocomeni 103:7b566b522427 26 #define DBG_RX_BUFFER_MASK (DBG_RX_BUFFER_SIZE_BYTES - 1)
ocomeni 103:7b566b522427 27
ocomeni 103:7b566b522427 28 #define DBG_TX_BUFFER_SIZE_BYTES (1024)
ocomeni 103:7b566b522427 29
ocomeni 103:7b566b522427 30 #if (DBG_RX_BUFFER_SIZE_BYTES & DBG_RX_BUFFER_MASK)
ocomeni 103:7b566b522427 31 #error Rx buffer size is not power of 2
ocomeni 103:7b566b522427 32 #endif
ocomeni 103:7b566b522427 33
ocomeni 103:7b566b522427 34 //-------- Constants & enums -------------------------------------------------//
ocomeni 103:7b566b522427 35
ocomeni 103:7b566b522427 36
ocomeni 103:7b566b522427 37 //-------- Structs & typedefs ------------------------------------------------//
ocomeni 103:7b566b522427 38
ocomeni 103:7b566b522427 39 //-------- Global Variables --------------------------------------------------//
ocomeni 103:7b566b522427 40
ocomeni 103:7b566b522427 41 /**
ocomeni 103:7b566b522427 42 *@brief Global array of length ::DBG_TX_BUFFER_SIZE_BYTES to store
ocomeni 103:7b566b522427 43 * the current debug print statement of the firmware.
ocomeni 103:7b566b522427 44 */
ocomeni 103:7b566b522427 45 static char g_dbg_buffer[DBG_TX_BUFFER_SIZE_BYTES];
ocomeni 103:7b566b522427 46
ocomeni 103:7b566b522427 47 //-------- Static Variables --------------------------------------------------//
ocomeni 103:7b566b522427 48
ocomeni 103:7b566b522427 49 static const char dbg_tx_terminate_string[] = {'\n', '\r'}; ///<Array of characters representing the terminate sequence of a debug transmit string
ocomeni 103:7b566b522427 50
ocomeni 103:7b566b522427 51 static uint8_t current_debug_level; ///<Variable keeping track of the current debug level
ocomeni 103:7b566b522427 52
ocomeni 103:7b566b522427 53 static char fw_ver_string[REL_FW_VER_STRING_LEN_BYTES + SVN_FW_VER_STRING_LEN_BYTES];
ocomeni 103:7b566b522427 54 static uint8_t fw_ver_bytes[5];
ocomeni 103:7b566b522427 55
ocomeni 103:7b566b522427 56 static data_mode_e dbg_data_mode;
ocomeni 103:7b566b522427 57
ocomeni 103:7b566b522427 58 //Rx buffer to be used for both ASCII and binary mode
ocomeni 103:7b566b522427 59 static uint8_t dbg_rx_buffer[DBG_RX_BUFFER_SIZE_BYTES];
ocomeni 103:7b566b522427 60 static volatile uint16_t dbg_rx_pos;
ocomeni 103:7b566b522427 61 static volatile uint32_t dbg_rx_count;
ocomeni 103:7b566b522427 62 static volatile uint16_t dbg_rx_cmd_count;
ocomeni 103:7b566b522427 63
ocomeni 103:7b566b522427 64 //static char g_dbg_buffer[DBG_TX_BUFFER_SIZE_BYTES];
ocomeni 103:7b566b522427 65
ocomeni 103:7b566b522427 66 //-------- Static function prototypes ----------------------------------------//
ocomeni 103:7b566b522427 67
ocomeni 103:7b566b522427 68 static void set_fw_ver_string(void);
ocomeni 103:7b566b522427 69 static void set_fw_ver_bytes(void);
ocomeni 103:7b566b522427 70 static char get_rx_byte_from_buffer(void);
ocomeni 103:7b566b522427 71 static const char* debug_level_to_string(uint8_t debug_level);
ocomeni 103:7b566b522427 72
ocomeni 103:7b566b522427 73 //-------- Function implementations ------------------------------------------//
ocomeni 103:7b566b522427 74 #ifdef BOX_MICRO_CODE
ocomeni 103:7b566b522427 75 static inline void disable_dbg_rx_intrup(void)
ocomeni 103:7b566b522427 76 {
ocomeni 103:7b566b522427 77 __HAL_PCD_DISABLE(&hpcd_USB_OTG_FS);
ocomeni 103:7b566b522427 78 }
ocomeni 103:7b566b522427 79
ocomeni 103:7b566b522427 80 static inline void enable_dbg_rx_intrup(void)
ocomeni 103:7b566b522427 81 {
ocomeni 103:7b566b522427 82 __HAL_PCD_ENABLE(&hpcd_USB_OTG_FS);
ocomeni 103:7b566b522427 83 }
ocomeni 103:7b566b522427 84 #endif
ocomeni 103:7b566b522427 85 /**
ocomeni 103:7b566b522427 86 * @brief Starting function to supervise the
ocomeni 103:7b566b522427 87 * - Initialisation of UART2 responsible for acting as the debug port for the firmware
ocomeni 103:7b566b522427 88 * - Initialisation of the UART2 transmit and receive buffers
ocomeni 103:7b566b522427 89 * - Initial read from UART2
ocomeni 103:7b566b522427 90 *
ocomeni 103:7b566b522427 91 * @param None
ocomeni 103:7b566b522427 92 * @retval None
ocomeni 103:7b566b522427 93 */
ocomeni 103:7b566b522427 94 void initialise_debug(void)
ocomeni 103:7b566b522427 95 {
ocomeni 103:7b566b522427 96 memset(g_dbg_buffer, 0, sizeof(g_dbg_buffer));
ocomeni 103:7b566b522427 97
ocomeni 103:7b566b522427 98 //. Set the version strings
ocomeni 103:7b566b522427 99 set_fw_ver_string();
ocomeni 103:7b566b522427 100 set_fw_ver_bytes();
ocomeni 103:7b566b522427 101
ocomeni 103:7b566b522427 102 current_debug_level = NONE; //(LOG | ERR | TXT | DBG); //
ocomeni 103:7b566b522427 103 dbg_data_mode = DATA_ASCII;
ocomeni 103:7b566b522427 104 dbg_rx_pos = 0;
ocomeni 103:7b566b522427 105 dbg_rx_count = 0;
ocomeni 103:7b566b522427 106 dbg_rx_cmd_count = 0;
ocomeni 103:7b566b522427 107 }
ocomeni 103:7b566b522427 108
ocomeni 103:7b566b522427 109 /**
ocomeni 103:7b566b522427 110 * @brief
ocomeni 103:7b566b522427 111 * @param
ocomeni 103:7b566b522427 112 * @param
ocomeni 103:7b566b522427 113 * @retval
ocomeni 103:7b566b522427 114 */
ocomeni 103:7b566b522427 115 const char* get_dbg_tx_terminate_string(void)
ocomeni 103:7b566b522427 116 {
ocomeni 103:7b566b522427 117 if (dbg_data_mode == DATA_ASCII)
ocomeni 103:7b566b522427 118 {
ocomeni 103:7b566b522427 119 return dbg_tx_terminate_string;
ocomeni 103:7b566b522427 120 }
ocomeni 103:7b566b522427 121 else
ocomeni 103:7b566b522427 122 {
ocomeni 103:7b566b522427 123 return NULL;
ocomeni 103:7b566b522427 124 }
ocomeni 103:7b566b522427 125 }
ocomeni 103:7b566b522427 126
ocomeni 103:7b566b522427 127 /**
ocomeni 103:7b566b522427 128 * @brief
ocomeni 103:7b566b522427 129 * @param
ocomeni 103:7b566b522427 130 * @param
ocomeni 103:7b566b522427 131 * @retval
ocomeni 103:7b566b522427 132 */
ocomeni 103:7b566b522427 133 uint8_t get_dbg_tx_terminate_string_len(void)
ocomeni 103:7b566b522427 134 {
ocomeni 103:7b566b522427 135 if (dbg_data_mode == DATA_ASCII)
ocomeni 103:7b566b522427 136 {
ocomeni 103:7b566b522427 137 return sizeof(dbg_tx_terminate_string);
ocomeni 103:7b566b522427 138 }
ocomeni 103:7b566b522427 139 else
ocomeni 103:7b566b522427 140 {
ocomeni 103:7b566b522427 141 return 0;
ocomeni 103:7b566b522427 142 }
ocomeni 103:7b566b522427 143 }
ocomeni 103:7b566b522427 144
ocomeni 103:7b566b522427 145 static const char* debug_level_to_string(uint8_t debug_level)
ocomeni 103:7b566b522427 146 {
ocomeni 103:7b566b522427 147 switch(debug_level)
ocomeni 103:7b566b522427 148 {
ocomeni 103:7b566b522427 149 case LOG:
ocomeni 103:7b566b522427 150 return "LOG";
ocomeni 103:7b566b522427 151
ocomeni 103:7b566b522427 152 case ERR:
ocomeni 103:7b566b522427 153 return "ERR";
ocomeni 103:7b566b522427 154
ocomeni 103:7b566b522427 155 case DBG:
ocomeni 103:7b566b522427 156 return "DBG";
ocomeni 103:7b566b522427 157
ocomeni 103:7b566b522427 158 case TXT:
ocomeni 103:7b566b522427 159 return "TXT";
ocomeni 103:7b566b522427 160
ocomeni 103:7b566b522427 161 default:
ocomeni 103:7b566b522427 162 return "INV"; //Invalid
ocomeni 103:7b566b522427 163 }
ocomeni 103:7b566b522427 164 }
ocomeni 103:7b566b522427 165
ocomeni 103:7b566b522427 166
ocomeni 103:7b566b522427 167 //void dbg_printf(uint8_t debug_level, ...)
ocomeni 103:7b566b522427 168 //{
ocomeni 103:7b566b522427 169 // dbg_print(FILE_CODE, __LINE__, debug_level, ...);
ocomeni 103:7b566b522427 170 //}
ocomeni 103:7b566b522427 171 void dbg_printf(uint8_t debug_level, const char *text, ...)
ocomeni 103:7b566b522427 172 {
ocomeni 103:7b566b522427 173 //const char *file_code, uint16_t line_number,
ocomeni 103:7b566b522427 174
ocomeni 103:7b566b522427 175 if (current_debug_level & debug_level)
ocomeni 103:7b566b522427 176 {
ocomeni 103:7b566b522427 177 //Re-init the gloabl debug buffer
ocomeni 103:7b566b522427 178 memset(g_dbg_buffer, 0, sizeof(g_dbg_buffer));
ocomeni 103:7b566b522427 179 uint16_t len_bytes = 0;
ocomeni 103:7b566b522427 180
ocomeni 103:7b566b522427 181 if (debug_level != TXT)
ocomeni 103:7b566b522427 182 {
ocomeni 103:7b566b522427 183 sprintf(g_dbg_buffer, "|%s|%10u|", debug_level_to_string(debug_level), Kernel::get_ms_count());
ocomeni 103:7b566b522427 184 len_bytes = strlen(g_dbg_buffer);
ocomeni 103:7b566b522427 185 }
ocomeni 103:7b566b522427 186
ocomeni 103:7b566b522427 187 va_list args;
ocomeni 103:7b566b522427 188 va_start(args, text);
ocomeni 103:7b566b522427 189 vsnprintf(&g_dbg_buffer[len_bytes], (sizeof(g_dbg_buffer) - len_bytes - 2), text, args);
ocomeni 103:7b566b522427 190 printf("%s", g_dbg_buffer);
ocomeni 103:7b566b522427 191 va_end(args);
ocomeni 103:7b566b522427 192
ocomeni 103:7b566b522427 193 len_bytes = strlen(g_dbg_buffer);
ocomeni 103:7b566b522427 194 g_dbg_buffer[len_bytes++] = '\r';
ocomeni 103:7b566b522427 195 g_dbg_buffer[len_bytes++] = '\n';
ocomeni 103:7b566b522427 196 #ifdef WRITE_TO_FILE_ENABLED
ocomeni 103:7b566b522427 197 if (debug_level == LOG || debug_level == ERROR)
ocomeni 103:7b566b522427 198 {
ocomeni 103:7b566b522427 199 write_to_file(SYS_LOG, (const uint8_t *)g_dbg_buffer, len_bytes);
ocomeni 103:7b566b522427 200 }
ocomeni 103:7b566b522427 201
ocomeni 103:7b566b522427 202 if (dbg_data_mode == DATA_ASCII)
ocomeni 103:7b566b522427 203 {
ocomeni 103:7b566b522427 204 transmit_bytes_over_usb((uint8_t *)g_dbg_buffer, len_bytes);
ocomeni 103:7b566b522427 205 }
ocomeni 103:7b566b522427 206 #endif
ocomeni 103:7b566b522427 207 }
ocomeni 103:7b566b522427 208 }
ocomeni 103:7b566b522427 209
ocomeni 103:7b566b522427 210 /**
ocomeni 103:7b566b522427 211 Function used to send data during firmware update (in binary mode)
ocomeni 103:7b566b522427 212 */
ocomeni 103:7b566b522427 213 #ifdef WRITE_TO_FILE_ENABLED
ocomeni 103:7b566b522427 214 void debug_send_data(uint8_t *pData, uint16_t length)
ocomeni 103:7b566b522427 215 {
ocomeni 103:7b566b522427 216 transmit_bytes_over_usb(pData, length);
ocomeni 103:7b566b522427 217 }
ocomeni 103:7b566b522427 218 #endif
ocomeni 103:7b566b522427 219
ocomeni 103:7b566b522427 220 /**
ocomeni 103:7b566b522427 221 * @brief Function to set the debug level. Currently only 2 debug levels
ocomeni 103:7b566b522427 222 * are provided as mentioned in ::debug_log_level_e.
ocomeni 103:7b566b522427 223 * LOG is constantly enabled
ocomeni 103:7b566b522427 224 *
ocomeni 103:7b566b522427 225 * @param (uint8_t) debug_level
ocomeni 103:7b566b522427 226 * @retval None
ocomeni 103:7b566b522427 227 */
ocomeni 103:7b566b522427 228 void set_debug_level(uint8_t debug_level)
ocomeni 103:7b566b522427 229 {
ocomeni 103:7b566b522427 230 current_debug_level = (LOG | ERR | TXT | debug_level);
ocomeni 103:7b566b522427 231 dbg_printf(LOG, "Current debug level set to %02x", current_debug_level);
ocomeni 103:7b566b522427 232 }
ocomeni 103:7b566b522427 233
ocomeni 103:7b566b522427 234 /**
ocomeni 103:7b566b522427 235 * @brief Function to get the current debug level set.
ocomeni 103:7b566b522427 236 *
ocomeni 103:7b566b522427 237 * @param None
ocomeni 103:7b566b522427 238 * @retval (uint8_t) current_debug_level
ocomeni 103:7b566b522427 239 */
ocomeni 103:7b566b522427 240 uint8_t get_debug_level(void)
ocomeni 103:7b566b522427 241 {
ocomeni 103:7b566b522427 242 return current_debug_level;
ocomeni 103:7b566b522427 243 }
ocomeni 103:7b566b522427 244
ocomeni 103:7b566b522427 245 /**
ocomeni 103:7b566b522427 246 * @brief Function to set the micro firmware version
ocomeni 103:7b566b522427 247 * Firmware version follows the following format:
ocomeni 103:7b566b522427 248 * major.minor.patch.svn_revision
ocomeni 103:7b566b522427 249 *
ocomeni 103:7b566b522427 250 * If 'svnversion' is not installed on the machine, the svn
ocomeni 103:7b566b522427 251 * revision is returned null. In that instance, the svn revision
ocomeni 103:7b566b522427 252 * is set to n.a
ocomeni 103:7b566b522427 253 *
ocomeni 103:7b566b522427 254 * @param None
ocomeni 103:7b566b522427 255 * @retval None
ocomeni 103:7b566b522427 256 */
ocomeni 103:7b566b522427 257 static void set_fw_ver_string(void)
ocomeni 103:7b566b522427 258 {
ocomeni 103:7b566b522427 259 memset(fw_ver_string, 0, sizeof(fw_ver_string));
ocomeni 103:7b566b522427 260
ocomeni 103:7b566b522427 261 memcpy(fw_ver_string, REL_FW_VER_STRING, REL_FW_VER_STRING_LEN_BYTES);
ocomeni 103:7b566b522427 262
ocomeni 103:7b566b522427 263 uint8_t rel_fw_string_len_bytes = strlen(REL_FW_VER_STRING);
ocomeni 103:7b566b522427 264
ocomeni 103:7b566b522427 265 fw_ver_string[rel_fw_string_len_bytes] = '.';
ocomeni 103:7b566b522427 266 #ifdef BOX_MICRO_CODE
ocomeni 103:7b566b522427 267 if (strlen(SVN_FW_VERSION_STRING) == 0)
ocomeni 103:7b566b522427 268 {
ocomeni 103:7b566b522427 269 //svnversion is not installed on the machine
ocomeni 103:7b566b522427 270 memcpy(&fw_ver_string[rel_fw_string_len_bytes + 1], "n.a", 4);
ocomeni 103:7b566b522427 271 }
ocomeni 103:7b566b522427 272 else
ocomeni 103:7b566b522427 273 {
ocomeni 103:7b566b522427 274 memcpy(&fw_ver_string[rel_fw_string_len_bytes + 1], SVN_FW_VERSION_STRING, SVN_FW_VER_STRING_LEN_BYTES);
ocomeni 103:7b566b522427 275 }
ocomeni 103:7b566b522427 276 #endif
ocomeni 103:7b566b522427 277 }
ocomeni 103:7b566b522427 278
ocomeni 103:7b566b522427 279 /**
ocomeni 103:7b566b522427 280 * @brief Function to get the firmware version
ocomeni 103:7b566b522427 281 *
ocomeni 103:7b566b522427 282 * @param None
ocomeni 103:7b566b522427 283 * @retval (const char *) fw_ver_string
ocomeni 103:7b566b522427 284 */
ocomeni 103:7b566b522427 285 const char* get_fw_ver_string(void)
ocomeni 103:7b566b522427 286 {
ocomeni 103:7b566b522427 287 return fw_ver_string;
ocomeni 103:7b566b522427 288 }
ocomeni 103:7b566b522427 289
ocomeni 103:7b566b522427 290 static void set_fw_ver_bytes(void)
ocomeni 103:7b566b522427 291 {
ocomeni 103:7b566b522427 292 memset(fw_ver_bytes, 0, sizeof(fw_ver_bytes));
ocomeni 103:7b566b522427 293
ocomeni 103:7b566b522427 294 uint16_t val = 0;
ocomeni 103:7b566b522427 295 sscanf(fw_ver_string, "%hhx.%hhx.%hhx.%hx", &fw_ver_bytes[0], &fw_ver_bytes[1], &fw_ver_bytes[2], &val);
ocomeni 103:7b566b522427 296
ocomeni 103:7b566b522427 297 fw_ver_bytes[3] = (val >> 8) & 0xff;
ocomeni 103:7b566b522427 298 fw_ver_bytes[4] = val & 0xff;
ocomeni 103:7b566b522427 299 }
ocomeni 103:7b566b522427 300
ocomeni 103:7b566b522427 301 const uint8_t* get_fw_ver_bytes(void)
ocomeni 103:7b566b522427 302 {
ocomeni 103:7b566b522427 303 return fw_ver_bytes;
ocomeni 103:7b566b522427 304 }
ocomeni 103:7b566b522427 305
ocomeni 103:7b566b522427 306 void debug_setDataMode(data_mode_e mode)
ocomeni 103:7b566b522427 307 {
ocomeni 103:7b566b522427 308 dbg_data_mode = mode;
ocomeni 103:7b566b522427 309 }
ocomeni 103:7b566b522427 310
ocomeni 103:7b566b522427 311 void print_debug_hex(const uint8_t* p_buffer, uint16_t len)
ocomeni 103:7b566b522427 312 {
ocomeni 103:7b566b522427 313 //print out the rxvd EDM bytes
ocomeni 103:7b566b522427 314
ocomeni 103:7b566b522427 315 uint16_t quo = len / 8;
ocomeni 103:7b566b522427 316 uint16_t rem = len % 8;
ocomeni 103:7b566b522427 317
ocomeni 103:7b566b522427 318 uint16_t i = 0;
ocomeni 103:7b566b522427 319 uint16_t j = 0;
ocomeni 103:7b566b522427 320 for (i = 0; i < quo; i++)
ocomeni 103:7b566b522427 321 {
ocomeni 103:7b566b522427 322 dbg_printf(LOG, "[%3d]: %02x %02x %02x %02x %02x %02x %02x %02x", j,
ocomeni 103:7b566b522427 323 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2], p_buffer[j + 3],
ocomeni 103:7b566b522427 324 p_buffer[j + 4], p_buffer[j + 5], p_buffer[j + 6], p_buffer[j + 7]);
ocomeni 103:7b566b522427 325 j += 8;
ocomeni 103:7b566b522427 326 }
ocomeni 103:7b566b522427 327
ocomeni 103:7b566b522427 328 if (rem == 7)
ocomeni 103:7b566b522427 329 {
ocomeni 103:7b566b522427 330 dbg_printf(LOG, "[%3d]: %02x %02x %02x %02x %02x %02x %02x", j,
ocomeni 103:7b566b522427 331 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2], p_buffer[j + 3],
ocomeni 103:7b566b522427 332 p_buffer[j + 4], p_buffer[j + 5], p_buffer[j + 6]);
ocomeni 103:7b566b522427 333 }
ocomeni 103:7b566b522427 334 else if (rem == 6)
ocomeni 103:7b566b522427 335 {
ocomeni 103:7b566b522427 336 dbg_printf(LOG, "[%3d]: %02x %02x %02x %02x %02x %02x", j,
ocomeni 103:7b566b522427 337 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2], p_buffer[j + 3],
ocomeni 103:7b566b522427 338 p_buffer[j + 4], p_buffer[j + 5]);
ocomeni 103:7b566b522427 339 }
ocomeni 103:7b566b522427 340 else if (rem == 5)
ocomeni 103:7b566b522427 341 {
ocomeni 103:7b566b522427 342 dbg_printf(LOG, "[%3d]: %02x %02x %02x %02x %02x", j,
ocomeni 103:7b566b522427 343 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2], p_buffer[j + 3],
ocomeni 103:7b566b522427 344 p_buffer[j + 4]);
ocomeni 103:7b566b522427 345 }
ocomeni 103:7b566b522427 346 else if (rem == 4)
ocomeni 103:7b566b522427 347 {
ocomeni 103:7b566b522427 348 dbg_printf(LOG, "[%3d]: %02x %02x %02x %02x", j,
ocomeni 103:7b566b522427 349 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2], p_buffer[j + 3]);
ocomeni 103:7b566b522427 350 }
ocomeni 103:7b566b522427 351 else if (rem == 3)
ocomeni 103:7b566b522427 352 {
ocomeni 103:7b566b522427 353 dbg_printf(LOG, "[%3d]: %02x %02x %02x", j,
ocomeni 103:7b566b522427 354 p_buffer[j + 0], p_buffer[j + 1], p_buffer[j + 2]);
ocomeni 103:7b566b522427 355 }
ocomeni 103:7b566b522427 356 else if (rem == 2)
ocomeni 103:7b566b522427 357 {
ocomeni 103:7b566b522427 358 dbg_printf(LOG, "[%3d]: %02x %02x", j, p_buffer[j + 0], p_buffer[j + 1]);
ocomeni 103:7b566b522427 359 }
ocomeni 103:7b566b522427 360 else if (rem == 1)
ocomeni 103:7b566b522427 361 {
ocomeni 103:7b566b522427 362 dbg_printf(LOG, "[%3d]: %02x", j, p_buffer[j]);
ocomeni 103:7b566b522427 363 }
ocomeni 103:7b566b522427 364
ocomeni 103:7b566b522427 365 dbg_printf(LOG, "");
ocomeni 103:7b566b522427 366 }