2000-07-25 01:23:20 +00:00
|
|
|
/* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
|
|
|
*
|
|
|
|
* testlibft847.c - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
|
|
|
* This program tests the libft847.so API for communicating
|
|
|
|
* via serial interface to an FT-847 using the "CAT" interface.
|
|
|
|
*
|
|
|
|
*
|
2000-07-29 02:39:15 +00:00
|
|
|
* $Id: testlibft847.c,v 1.6 2000-07-29 02:39:15 javabear Exp $
|
2000-07-25 01:23:20 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h> /* Standard input/output definitions */
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
#include <fcntl.h> /* File control definitions */
|
|
|
|
#include <errno.h> /* Error number definitions */
|
|
|
|
#include <termios.h> /* POSIX terminal control definitions */
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include "testlibft847.h"
|
|
|
|
#include "ft847.h"
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned char datain[5]; /* data read from rig */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-07-28 02:04:49 +00:00
|
|
|
* Decode routine for TX status update map
|
2000-07-25 01:23:20 +00:00
|
|
|
*/
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
static void decode_tx_status_flags(unsigned char txflag) {
|
2000-07-25 01:23:20 +00:00
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
printf("TX Status = %i \n", txflag);
|
|
|
|
printf("TXSF_PTT_STATUS = %i \n",TXSF_PTT_STATUS);
|
|
|
|
|
|
|
|
if((txflag & TXSF_PTT_STATUS) != 0 ) {
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("PTT = OFF (RX) \n");
|
2000-07-26 00:37:26 +00:00
|
|
|
} else {
|
|
|
|
printf("PTT = ON (TX) \n");
|
2000-07-25 01:23:20 +00:00
|
|
|
}
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
printf("PO/ALC Meter Data = %i \n", txflag & TXSF_POALC_METER_MASK);
|
2000-07-25 01:23:20 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-07-28 02:04:49 +00:00
|
|
|
* Decode routine for RX status update map
|
2000-07-25 01:23:20 +00:00
|
|
|
*/
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
static void decode_rx_status_flags(unsigned char rxflag) {
|
2000-07-25 01:23:20 +00:00
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
if((rxflag & RXSF_DISC_CENTER) != 0 ) {
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("Discriminator = Off Center \n");
|
|
|
|
} else {
|
|
|
|
printf("Discriminator = Centered \n");
|
|
|
|
}
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
if((rxflag & RXSF_SQUELCH_STATUS) != 0 ) {
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("Squelch = Squelch On (no signal) \n");
|
|
|
|
} else {
|
|
|
|
printf("Squelch = Squelch Off (signal present) \n");
|
|
|
|
}
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
if((rxflag & RXSF_CTCSS_DCS_CODE) != 0 ) {
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("CTCSS/DCS Code = Un-Matched \n");
|
|
|
|
} else {
|
|
|
|
printf("CTCSS/DCS Code = Matched \n");
|
|
|
|
}
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
printf("S-Meter Meter Data = %i \n", rxflag & RXSF_SMETER_MASK);
|
2000-07-25 01:23:20 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode routine for Mode Status
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void decode_mode(unsigned char mode) {
|
|
|
|
|
|
|
|
switch(mode) {
|
|
|
|
case 0:
|
|
|
|
printf("Current Mode = LSB \n");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
printf("Current Mode = USB \n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
printf("Current Mode = CW \n");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
printf("Current Mode = CWR \n");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
printf("Current Mode = AM \n");
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
printf("Current Mode = FM \n");
|
|
|
|
break;
|
|
|
|
case 82:
|
|
|
|
printf("Current Mode = CW(N) \n");
|
|
|
|
break;
|
|
|
|
case 83:
|
|
|
|
printf("Current Mode = CW(N)-R \n");
|
|
|
|
break;
|
|
|
|
case 84:
|
|
|
|
printf("Current Mode = AM(N) \n");
|
|
|
|
break;
|
|
|
|
case 88:
|
|
|
|
printf("Current Mode = FM(N) \n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Current mode = XXXXX \n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Simple test to see if we are talking to the RIG.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int test(fd) {
|
2000-07-26 00:09:29 +00:00
|
|
|
unsigned char data1;
|
2000-07-29 02:39:15 +00:00
|
|
|
int i;
|
2000-07-25 01:23:20 +00:00
|
|
|
|
2000-07-26 00:09:29 +00:00
|
|
|
cmd_cat_off(fd); /* cat off */
|
2000-07-25 01:23:20 +00:00
|
|
|
sleep(1);
|
2000-07-26 00:09:29 +00:00
|
|
|
cmd_cat_on(fd); /* cat on */
|
|
|
|
sleep(1);
|
|
|
|
cmd_sat_on(fd); /* sat mode on */
|
2000-07-28 02:04:49 +00:00
|
|
|
sleep(5);
|
2000-07-26 00:09:29 +00:00
|
|
|
cmd_sat_off(fd); /* sat mode off */
|
|
|
|
sleep(1);
|
2000-07-26 00:37:26 +00:00
|
|
|
|
|
|
|
data1 = cmd_get_rx_status(fd);
|
2000-07-28 02:04:49 +00:00
|
|
|
printf("data1 = %i \n", data1);
|
|
|
|
|
2000-07-26 00:37:26 +00:00
|
|
|
decode_rx_status_flags(data1);
|
|
|
|
sleep(1);
|
2000-07-29 02:39:15 +00:00
|
|
|
|
|
|
|
for (i=0; i<10; i++) {
|
|
|
|
data1 = cmd_get_rx_status(fd);
|
|
|
|
decode_rx_status_flags(data1);
|
|
|
|
sleep(1);
|
|
|
|
cmd_get_freq_mode_status_main_vfo(fd);
|
|
|
|
sleep(1);
|
|
|
|
}
|
2000-07-26 00:09:29 +00:00
|
|
|
cmd_cat_off(fd); /* cat off */
|
2000-07-25 22:55:57 +00:00
|
|
|
|
2000-07-25 01:23:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main program starts here..
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
|
|
|
|
|
|
|
|
int fd;
|
|
|
|
|
2000-07-25 22:55:57 +00:00
|
|
|
fd = rig_open(SERIAL_PORT);
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("port %s opened ok \n",SERIAL_PORT);
|
|
|
|
|
|
|
|
test(fd);
|
|
|
|
printf("testing communication result ok \n");
|
|
|
|
|
2000-07-25 22:55:57 +00:00
|
|
|
rig_close(fd);
|
2000-07-25 01:23:20 +00:00
|
|
|
printf("port %s closed ok \n",SERIAL_PORT);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|