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-09-04 19:58:56 +00:00
|
|
|
* $Id: testlibft847.c,v 1.16 2000-09-04 19:58:56 javabear Exp $
|
2000-07-25 01:23:20 +00:00
|
|
|
*
|
2000-08-19 04:07:00 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2000-07-25 01:23:20 +00:00
|
|
|
*/
|
|
|
|
|
2000-08-19 04:07:00 +00:00
|
|
|
|
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>
|
|
|
|
|
2000-09-04 17:51:35 +00:00
|
|
|
#include "rig.h"
|
2000-07-25 01:23:20 +00:00
|
|
|
#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 20:31:30 +00:00
|
|
|
unsigned char mode;
|
2000-07-29 02:39:15 +00:00
|
|
|
int i;
|
2000-07-29 20:31:30 +00:00
|
|
|
long int frq; /* freq */
|
2000-07-25 01:23:20 +00:00
|
|
|
|
2000-07-30 02:02:15 +00:00
|
|
|
cmd_set_cat_off(fd); /* cat off */
|
2000-07-25 01:23:20 +00:00
|
|
|
sleep(1);
|
2000-07-30 02:02:15 +00:00
|
|
|
cmd_set_cat_on(fd); /* cat on */
|
2000-07-26 00:09:29 +00:00
|
|
|
sleep(1);
|
2000-07-30 02:02:15 +00:00
|
|
|
cmd_set_sat_on(fd); /* sat mode on */
|
2000-07-28 02:04:49 +00:00
|
|
|
sleep(5);
|
2000-07-30 02:02:15 +00:00
|
|
|
cmd_set_sat_off(fd); /* sat mode off */
|
|
|
|
sleep(3);
|
|
|
|
cmd_set_opmode_main_vfo(fd,MODE_AM);
|
2000-07-26 00:09:29 +00:00
|
|
|
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-30 05:04:04 +00:00
|
|
|
decode_rx_status_flags(data1);
|
|
|
|
|
2000-07-28 02:04:49 +00:00
|
|
|
|
2000-07-30 02:02:15 +00:00
|
|
|
/* decode_rx_status_flags(data1); */
|
2000-07-26 00:37:26 +00:00
|
|
|
sleep(1);
|
2000-07-29 02:39:15 +00:00
|
|
|
|
2000-07-29 23:13:53 +00:00
|
|
|
for (i=0; i<4; i++) {
|
2000-07-30 05:04:04 +00:00
|
|
|
data1 = cmd_get_rx_status(fd);
|
|
|
|
decode_rx_status_flags(data1);
|
|
|
|
sleep(1);
|
2000-07-29 20:31:30 +00:00
|
|
|
frq = cmd_get_freq_mode_status_main_vfo(fd, &mode);
|
|
|
|
printf("freq = %ld Hz and mode = %x \n",frq, mode );
|
|
|
|
|
2000-07-29 02:39:15 +00:00
|
|
|
sleep(1);
|
|
|
|
}
|
2000-07-30 02:02:15 +00:00
|
|
|
|
2000-07-29 23:13:53 +00:00
|
|
|
cmd_set_freq_main_vfo_hz(fd,439700000,MODE_FM);
|
|
|
|
sleep(5);
|
|
|
|
cmd_set_freq_main_vfo_hz(fd,123456780,MODE_CW);
|
|
|
|
sleep(5);
|
|
|
|
cmd_set_freq_main_vfo_hz(fd,770000,MODE_AM);
|
|
|
|
sleep(5);
|
|
|
|
|
2000-07-30 02:02:15 +00:00
|
|
|
cmd_set_freq_sat_rx_vfo_hz(fd,137125000,MODE_FM);
|
|
|
|
sleep(5);
|
|
|
|
cmd_set_freq_sat_rx_vfo_hz(fd,137125000,MODE_FM);
|
|
|
|
sleep(5);
|
|
|
|
cmd_set_freq_sat_tx_vfo_hz(fd,437875000,MODE_FMN);
|
|
|
|
sleep(5);
|
|
|
|
|
|
|
|
cmd_set_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) {
|
|
|
|
|
2000-09-03 23:44:18 +00:00
|
|
|
struct rig_caps *rc; /* points to rig caps */
|
2000-07-25 01:23:20 +00:00
|
|
|
|
|
|
|
int fd;
|
2000-09-03 23:44:18 +00:00
|
|
|
|
|
|
|
rc = rig_get_caps(); /* find capabilities */
|
|
|
|
|
2000-09-04 17:51:35 +00:00
|
|
|
printf("rig_name = %s \n", rc->rig_name);
|
|
|
|
printf("Initial serial_port_name = %s \n", rc->serial_port_name);
|
2000-09-03 23:44:18 +00:00
|
|
|
|
2000-09-04 17:51:35 +00:00
|
|
|
strcpy(rc->serial_port_name,SERIAL_PORT); /* put wanted serial port in caps */
|
|
|
|
|
|
|
|
|
|
|
|
/* fd = rig_open(SERIAL_PORT); */
|
|
|
|
/* printf("port %s opened ok \n",SERIAL_PORT); */
|
|
|
|
|
|
|
|
fd = rig_open(rc);
|
|
|
|
printf("port %s opened ok \n", rc->serial_port_name);
|
|
|
|
|
2000-07-25 01:23:20 +00:00
|
|
|
test(fd);
|
|
|
|
printf("testing communication result ok \n");
|
|
|
|
|
2000-07-25 22:55:57 +00:00
|
|
|
rig_close(fd);
|
2000-09-04 17:51:35 +00:00
|
|
|
printf("port %s closed ok \n", rc->serial_port_name);
|
2000-07-25 01:23:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-09-04 03:45:54 +00:00
|
|
|
|
|
|
|
|