Logo Search packages:      
Sourcecode: hamlib version File versions  Download package

void dump_hex ( const unsigned char  ptr[],
size_t  size 
)

Do a hex dump of the unsigned char array.

Parameters:
ptr Pointer to memory area
size Number of chars to words to dump

Definition at line 63 of file debug.c.

References rig_debug(), RIG_DEBUG_TRACE, and rig_need_debug().

Referenced by read_block(), read_string(), and write_block().

{
  int i;
  char buf[DUMP_HEX_WIDTH+1];

  if (!rig_need_debug(RIG_DEBUG_TRACE))
              return;

  buf[DUMP_HEX_WIDTH] = '\0';

  for(i=0; i<size; i++) {
    if (i % DUMP_HEX_WIDTH == 0)
      rig_debug(RIG_DEBUG_TRACE,"%.4x\t",i);

    rig_debug(RIG_DEBUG_TRACE," %.2x", ptr[i]);

      if (ptr[i] >= ' ' && ptr[i] < 0x7f)
            buf[i%DUMP_HEX_WIDTH] = ptr[i];
      else
            buf[i%DUMP_HEX_WIDTH] = '.';

    if (i % DUMP_HEX_WIDTH == DUMP_HEX_WIDTH-1)
      rig_debug(RIG_DEBUG_TRACE,"\t%s\n",buf);
  }

  /* Add some spaces in order to align right ASCII dump column */
  if ((i / DUMP_HEX_WIDTH) > 0) {
    int j;
    for (j = i % DUMP_HEX_WIDTH; j < DUMP_HEX_WIDTH; j++)
      rig_debug(RIG_DEBUG_TRACE,"   ");
  }

  if (i % DUMP_HEX_WIDTH != DUMP_HEX_WIDTH-1) {
      buf[i % DUMP_HEX_WIDTH] = '\0';
    rig_debug(RIG_DEBUG_TRACE,"\t%s\n",buf);
  }

} 


Generated by  Doxygen 1.6.0   Back to index