mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
Make fifo routines print hex when needed
This commit is contained in:
parent
ef4489172a
commit
c5cc47dcd1
13
src/fifo.c
13
src/fifo.c
@ -1,5 +1,6 @@
|
||||
#include <hamlib/rig.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "fifo.h"
|
||||
|
||||
|
||||
@ -24,8 +25,12 @@ int push(FIFO_RIG *fifo, const char *msg)
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
fifo->data[fifo->tail] = msg[i];
|
||||
if (isprint(msg[i]))
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: push %c (%d,%d)\n", __func__, msg[i],
|
||||
fifo->head, fifo->tail);
|
||||
else
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: push 0x%02x (%d,%d)\n", __func__, msg[i],
|
||||
fifo->head, fifo->tail);
|
||||
|
||||
if (fifo->tail + 1 == fifo->head) { return -RIG_EDOM; }
|
||||
|
||||
@ -42,8 +47,12 @@ int peek(FIFO_RIG *fifo)
|
||||
if (fifo->tail > 1023 || fifo->head > 1023) return -1;
|
||||
if (fifo->tail == fifo->head) { return -1; }
|
||||
char c = fifo->data[fifo->head];
|
||||
if (isprint(c))
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: peek %c (%d,%d)\n", __func__, c, fifo->head,
|
||||
fifo->tail);
|
||||
else
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: peek 0x%02x (%d,%d)\n", __func__, c, fifo->head,
|
||||
fifo->tail);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -52,8 +61,12 @@ int pop(FIFO_RIG *fifo)
|
||||
if (fifo->tail == fifo->head) { return -1; }
|
||||
|
||||
char c = fifo->data[fifo->head];
|
||||
if (isprint(c))
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: pop %c (%d,%d)\n", __func__, c, fifo->head,
|
||||
fifo->tail);
|
||||
else
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: pop 0x%02x (%d,%d)\n", __func__, c, fifo->head,
|
||||
fifo->tail);
|
||||
fifo->head = (fifo->head + 1) % HAMLIB_FIFO_SIZE;
|
||||
return c;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user