2000-10-01 12:52:17 +00:00
|
|
|
|
2013-05-08 02:35:06 +00:00
|
|
|
/*
|
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
|
|
|
* Very simple test program to check BCD conversion against some other --SF
|
2000-10-01 12:52:17 +00:00
|
|
|
* This is mainly to test freq2bcd and bcd2freq functions.
|
|
|
|
*/
|
|
|
|
|
2022-02-04 13:41:36 +00:00
|
|
|
#include <hamlib/config.h>
|
2005-01-25 00:22:14 +00:00
|
|
|
|
2000-10-01 12:52:17 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-10-08 21:43:00 +00:00
|
|
|
#include <hamlib/rig.h>
|
2001-02-11 23:25:37 +00:00
|
|
|
#include "misc.h"
|
2000-10-01 12:52:17 +00:00
|
|
|
|
2002-09-06 14:12:35 +00:00
|
|
|
#define MAXDIGITS 32
|
2000-10-01 12:52:17 +00:00
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
int main(int argc, char *argv[])
|
2000-10-01 12:52:17 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
unsigned char b[(MAXDIGITS + 1) / 2];
|
|
|
|
freq_t f = 0;
|
|
|
|
int digits = 10;
|
|
|
|
int i;
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (argc != 2 && argc != 3)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr, "Usage: %s <freq> [digits]\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
f = (freq_t)atoll(argv[1]);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (argc > 2)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
digits = atoi(argv[2]);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (digits > MAXDIGITS)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Little Endian mode\n");
|
|
|
|
printf("Frequency: %"PRIfreq"\n", f);
|
|
|
|
to_bcd(b, f, digits);
|
|
|
|
printf("BCD: %2.2x", b[0]);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
for (i = 1; i < (digits + 1) / 2; i++)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf(",%2.2x", b[i]);
|
|
|
|
}
|
|
|
|
|
2020-03-23 15:13:02 +00:00
|
|
|
// cppcheck-suppress *
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("\nResult after recoding: %"PRIll"\n", (int64_t)from_bcd(b, digits));
|
|
|
|
|
|
|
|
printf("\nBig Endian mode\n");
|
|
|
|
printf("Frequency: %"PRIfreq"\n", f);
|
|
|
|
to_bcd_be(b, f, digits);
|
|
|
|
printf("BCD: %2.2x", b[0]);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
for (i = 1; i < (digits + 1) / 2; i++)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf(",%2.2x", b[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nResult after recoding: %"PRIll"\n",
|
|
|
|
(int64_t)from_bcd_be(b, digits));
|
|
|
|
|
|
|
|
return 0;
|
2000-10-01 12:52:17 +00:00
|
|
|
}
|