Print d868uv frequencies.

This commit is contained in:
Serge Vakulenko 2018-10-25 15:26:26 -07:00
parent b03daba8ab
commit 0e7b2cbf62
4 changed files with 84 additions and 39 deletions

View File

@ -104,8 +104,11 @@ typedef struct {
#define BW_12_5_KHZ 0
#define BW_25_KHZ 1
_unused8 : 2, // 0
neg_tx_offset : 1; // Negative TX offset?
_unused8 : 1, // 0
repeater_mode : 2; // Sign of TX frequency offset
#define RM_SIMPLEX 0 // TX frequency = RX frequency
#define RM_TXPOS 1 // Positive TX offset
#define RM_TXNEG 2 // Negative TX offset
// Byte 9
uint8_t rx_ctcss : 1, // CTCSS Decode
@ -453,6 +456,73 @@ static int have_channels(int mode)
return 0;
}
//
// Print frequency (BCD value).
//
static void print_rx_freq(FILE *out, unsigned data)
{
fprintf(out, "%d%d%d.%d%d%d", (data >> 4) & 15, data & 15,
(data >> 12) & 15, (data >> 8) & 15,
(data >> 20) & 15, (data >> 16) & 15);
if ((data & 0xff) == 0) {
fputs(" ", out);
} else {
fprintf(out, "%d", (data >> 28) & 15);
if (((data >> 24) & 15) == 0) {
fputs(" ", out);
} else {
fprintf(out, "%d", (data >> 24) & 15);
}
}
}
//
// Convert a 4-byte frequency value from binary coded decimal
// to integer format (in Hertz).
//
static int bcd_to_hz(unsigned bcd)
{
int a = (bcd >> 4) & 15;
int b = bcd & 15;
int c = (bcd >> 12) & 15;
int d = (bcd >> 8) & 15;
int e = (bcd >> 20) & 15;
int f = (bcd >> 16) & 15;
int g = (bcd >> 28) & 15;
int h = (bcd >> 24) & 15;
return (((((((a*10 + b) * 10 + c) * 10 + d) * 10 + e) * 10 + f) * 10 + g) * 10 + h) * 10;
}
//
// Print the transmit offset or frequency.
// TX value is a delta.
//
static void print_tx_offset(FILE *out, unsigned tx_offset_bcd, unsigned mode)
{
int offset;
switch (mode) {
default:
case RM_SIMPLEX: // TX frequency = RX frequency
fprintf(out, "+0 ");
break;
case RM_TXPOS: // Positive TX offset
offset = bcd_to_hz(tx_offset_bcd);
fprintf(out, "+");
print_mhz(out, offset);
break;
case RM_TXNEG: // Negative TX offset
offset = bcd_to_hz(tx_offset_bcd);
fprintf(out, "-");
print_mhz(out, offset);
break;
}
}
//
// Print base parameters of the channel:
// Name
@ -469,16 +539,16 @@ static void print_chan_base(FILE *out, channel_t *ch, int cnum)
fprintf(out, "%5d ", cnum);
print_ascii(out, ch->name, 16, 1);
fprintf(out, " ");
print_freq(out, ch->rx_frequency);
print_rx_freq(out, ch->rx_frequency);
fprintf(out, " ");
print_offset_delta(out, ch->rx_frequency, ch->tx_offset);
print_tx_offset(out, ch->tx_offset, ch->repeater_mode);
fprintf(out, "%-4s ", POWER_NAME[ch->power]);
fprintf(out, "%-5s ", POWER_NAME[ch->power]);
if (ch->scan_list_index == 0)
if (ch->scan_list_index == 0xff)
fprintf(out, "- ");
else
fprintf(out, "%-4d ", ch->scan_list_index);
fprintf(out, "%-4d ", ch->scan_list_index + 1);
//TODO
// if (ch->tot == 0)
@ -533,15 +603,15 @@ static void print_digital_channels(FILE *out, int verbose)
// Contact Name
fprintf(out, "%-5d %-3d ", ch->color_code, 1 + ch->slot2);
if (ch->group_list_index == 0)
if (ch->group_list_index == 0xff)
fprintf(out, "- ");
else
fprintf(out, "%-4d ", ch->group_list_index);
fprintf(out, "%-4d ", ch->group_list_index + 1);
if (ch->contact_index == 0)
if (ch->contact_index == 0xffff)
fprintf(out, "-");
else
fprintf(out, "%-4d", ch->contact_index);
fprintf(out, "%-4d", ch->contact_index + 1);
#if 0
// Print contact name as a comment.
//TODO
@ -590,7 +660,7 @@ static void print_analog_channels(FILE *out, int verbose)
fprintf(out, "# 13) Bandwidth in kHz: 12.5, 20, 25\n");
fprintf(out, "#\n");
}
fprintf(out, "Analog Name Receive Transmit Power Scan AS TOT RO Admit Squelch RxTone TxTone Width");
fprintf(out, "Analog Name Receive Transmit Power Scan TOT RO Admit Squelch RxTone TxTone Width");
fprintf(out, "\n");
for (i=0; i<NCHAN; i++) {
channel_t *ch = get_channel(i);

View File

@ -948,9 +948,9 @@ static void print_analog_channels(FILE *out, int verbose)
fprintf(out, "# 13) Bandwidth in kHz: 12.5, 20, 25\n");
fprintf(out, "#\n");
}
fprintf(out, "Analog Name Receive Transmit Power Scan AS TOT RO Admit Squelch RxTone TxTone Width");
fprintf(out, "Analog Name Receive Transmit Power Scan TOT RO Admit Squelch RxTone TxTone Width");
#ifdef PRINT_RARE_PARAMS
fprintf(out, " Dly RxRef TxRef LW VOX TA RxSign TxSign ID");
fprintf(out, " AS Dly RxRef TxRef LW VOX TA RxSign TxSign ID");
#endif
fprintf(out, "\n");
for (i=0; i<NCHAN; i++) {

24
util.c
View File

@ -557,30 +557,6 @@ void print_offset(FILE *out, unsigned rx_bcd, unsigned tx_bcd)
}
}
//
// Print the transmit offset or frequency.
// TX value is a delta.
//
void print_offset_delta(FILE *out, unsigned rx_bcd, unsigned tx_delta_bcd)
{
int rx_hz = freq_to_hz(rx_bcd);
int delta = freq_to_hz(tx_delta_bcd);
int tx_hz = rx_hz + delta;
if (delta == 0) {
fprintf(out, "+0 ");
} else if (delta > 0 && delta/50000 <= 255) {
fprintf(out, "+");
print_mhz(out, delta);
} else if (delta < 0 && -delta/50000 <= 255) {
fprintf(out, "-");
print_mhz(out, -delta);
} else {
fprintf(out, " ");
print_mhz(out, tx_hz);
}
}
//
// Compare channel index for qsort().
//

1
util.h
View File

@ -201,7 +201,6 @@ void print_mhz(FILE *out, unsigned hz);
// Print the transmit offset or frequency.
//
void print_offset(FILE *out, unsigned rx_bcd, unsigned tx_bcd);
void print_offset_delta(FILE *out, unsigned rx_bcd, unsigned delta_bcd);
//
// Compare channel index for qsort().