Hamlib/tests/testbcd.c
Daniele Forsi d7b332c3f7 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 09:02:48 +02:00

71 lines
1.4 KiB
C

/*
* Very simple test program to check BCD conversion against some other --SF
* This is mainly to test freq2bcd and bcd2freq functions.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <hamlib/rig.h>
#include "misc.h"
#define MAXDIGITS 32
int main(int argc, char *argv[])
{
unsigned char b[(MAXDIGITS + 1) / 2];
freq_t f = 0;
int digits = 10;
int i;
if (argc != 2 && argc != 3)
{
fprintf(stderr, "Usage: %s <freq> [digits]\n", argv[0]);
exit(1);
}
f = (freq_t)atoll(argv[1]);
if (argc > 2)
{
digits = atoi(argv[2]);
if (digits > MAXDIGITS)
{
exit(1);
}
}
printf("Little Endian mode\n");
printf("Frequency: %"PRIfreq"\n", f);
to_bcd(b, f, digits);
printf("BCD: %2.2x", b[0]);
for (i = 1; i < (digits + 1) / 2; i++)
{
printf(",%2.2x", b[i]);
}
// cppcheck-suppress *
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]);
for (i = 1; i < (digits + 1) / 2; i++)
{
printf(",%2.2x", b[i]);
}
printf("\nResult after recoding: %"PRIll"\n",
(int64_t)from_bcd_be(b, digits));
return 0;
}