kopia lustrzana https://github.com/Hamlib/Hamlib
Initial revision
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.0.0
rodzic
4bd5e22f9b
commit
9419ada73e
|
@ -0,0 +1,39 @@
|
|||
hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
|
||||
The purpose of this project is to provide stable, flexible,
|
||||
shared libraries that enable quicker development of Amateur
|
||||
Radio Equipment Control Applications.
|
||||
|
||||
Many Amateur Radio Transceivers come with serial interfaces
|
||||
that allows software to control the radio. This project will
|
||||
endeavour to provide shared libraries that greatly simplify
|
||||
the application programmers interaction with radio equipment.
|
||||
|
||||
The shared libs will provide functions for both radio control,
|
||||
and data retrieval from the radio.
|
||||
|
||||
Examples are:
|
||||
|
||||
1.libft747.so will provide connectivity to Yeasu
|
||||
FT 747GX Transceiver via a standard API.
|
||||
|
||||
2. libft847.so will provide connectivity to Yaesu FT 847
|
||||
"Earth Station" via a standard API.
|
||||
|
||||
3. libxxxx.so will provide connectivity to the Wiz-bang
|
||||
moon-melter 101A (yikes..)
|
||||
|
||||
These libraries will also enable developers to develop
|
||||
professional looking GUI's towards a standard control library
|
||||
API, and they would not have to worry about the underlying
|
||||
connection towards physical hardware.
|
||||
|
||||
Initially serial (RS232) connectivity will be handled, but
|
||||
I expect that IP connectivity will follow afterwards.
|
||||
|
||||
|
||||
Have Fun / Frank S.
|
||||
|
||||
73's de vk3fcs/km5ws
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
hamlib - (C) Frank Singleton 2000
|
||||
|
||||
TODO.<your rig> - (C) <your name> 2000
|
||||
This shared library provides an API for communicating
|
||||
via serial interface to a <your rig> using the <your interface> interface.
|
||||
|
||||
TODO
|
||||
----
|
||||
|
||||
1. Complete pcodes
|
||||
2. Write More extensive Test Suite
|
||||
3. Document API
|
||||
4. Document Limitations/Assumptions.
|
||||
5.
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
#
|
||||
#
|
||||
# Make file for FT-747GX CAT program shared lib
|
||||
#
|
||||
# creates: libft747.so
|
||||
#
|
||||
# $Id: Makefile,v 1.1 2000-07-18 20:53:46 frank Exp $
|
||||
#
|
||||
#
|
||||
# .h files go in INSTALL_INCLUDEDIR
|
||||
# .so files go in INSTALL_LIBDIR
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
INSTALL_LIBDIR = ./lib/
|
||||
INSTALL_INCLUDEDIR = ./include/
|
||||
|
||||
LIB_NAME = libft747.so
|
||||
LIB_SONAME = libft747.so.1
|
||||
LIB_RELEASE = libft747.so.1.0.1
|
||||
LIB_HEADER = ft747.h
|
||||
LIB_SRC = ft747.c
|
||||
LIB_OBJECTS = ft747.o
|
||||
|
||||
all: lib
|
||||
|
||||
.PHONY: lib
|
||||
lib:
|
||||
gcc -fPIC -g -Wall -c $(LIB_SRC)
|
||||
gcc -shared -Wl,-soname,$(LIB_SONAME) -o $(LIB_RELEASE) $(LIB_OBJECTS) -lc
|
||||
|
||||
# install header and lib
|
||||
|
||||
install:
|
||||
make install_lib
|
||||
make install_header
|
||||
|
||||
# install lib in MYLIBDIR
|
||||
|
||||
.PHONY: install_lib
|
||||
install_lib:
|
||||
mv $(LIB_RELEASE) $(INSTALL_LIBDIR)
|
||||
cd $(INSTALL_LIBDIR); /sbin/ldconfig -n .
|
||||
cd $(INSTALL_LIBDIR); ln -s $(LIB_SONAME) $(LIB_NAME)
|
||||
|
||||
# install libft747.h in INSTALL_INCLUDEDIR
|
||||
|
||||
.PHONY: install_header
|
||||
install_header:
|
||||
cp -f $(LIB_HEADER) $(INSTALL_INCLUDEDIR)
|
||||
|
||||
|
||||
# clean up local directory, my include and lib
|
||||
# directories also.
|
||||
|
||||
clean:
|
||||
make cleanlocal
|
||||
make cleanlib
|
||||
make cleaninclude
|
||||
|
||||
# clean up local directory
|
||||
|
||||
.PHONY: cleanlocal
|
||||
cleanlocal:
|
||||
rm -f *.o *.so*
|
||||
|
||||
# clean up local lib directory
|
||||
|
||||
.PHONY: cleanlib
|
||||
cleanlib:
|
||||
cd $(INSTALL_LIBDIR); rm -f $(LIB_NAME)*
|
||||
|
||||
|
||||
|
||||
# clean up local include directory
|
||||
|
||||
.PHONY: cleaninclude
|
||||
cleaninclude:
|
||||
cd $(INSTALL_INCLUDEDIR); rm -f $(LIB_HEADER)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
hamlib - (C) Frank Singleton 2000
|
||||
|
||||
libft747.so - (C) Frank Singleton 2000
|
||||
This shared library provides an API for communicating
|
||||
via serial interface to an FT-747GX using the "CAT" interface
|
||||
box (FIF-232C) or similar.
|
||||
|
||||
|
||||
Reference Documentation
|
||||
-----------------------
|
||||
|
||||
Operating Manual
|
||||
FT-747GX
|
||||
Yaesu Musen Co, LTD.
|
||||
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
Handles >90% of all opcodes
|
||||
|
||||
|
||||
Warnings
|
||||
--------
|
||||
|
||||
NA
|
||||
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
hamlib - (C) Frank Singleton 2000
|
||||
|
||||
TODO.ft747 - (C) Frank Singleton 2000
|
||||
This shared library provides an API for communicating
|
||||
via serial interface to an FT-747GX using the "CAT" interface
|
||||
box (FIF-232C) or similar.
|
||||
|
||||
TODO
|
||||
----
|
||||
|
||||
1. Complete pcodes
|
||||
2. Write More extensive Test Suite
|
||||
3.
|
||||
4.
|
||||
5.
|
||||
|
|
@ -0,0 +1,346 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ft747.c - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar
|
||||
*
|
||||
*
|
||||
* $Id: ft747.c,v 1.1 2000-07-18 20:54:22 frank Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#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 "ft747.h"
|
||||
|
||||
static unsigned char datain[350]; /* data read from rig */
|
||||
|
||||
struct ft747_update_data {
|
||||
unsigned char displayed_status;
|
||||
unsigned char displayed_freq[5];
|
||||
unsigned char current_band_data;
|
||||
unsigned char vfo_a_status;
|
||||
unsigned char vfo_a_freq_block[5];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Provides delay for block formation.
|
||||
* Should be 50-200 msec according to YAESU docs.
|
||||
*/
|
||||
|
||||
static void pause2() {
|
||||
usleep(50 * 1000); /* 50 msec */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a 5 character block to a file descriptor,
|
||||
* with a pause between each character.
|
||||
*
|
||||
* input:
|
||||
*
|
||||
* fd - file descriptor to write to
|
||||
* data - pointer to a command sequence array
|
||||
*
|
||||
* returns:
|
||||
*
|
||||
* 0 = OK
|
||||
* -1 = NOT OK
|
||||
*
|
||||
*/
|
||||
|
||||
static int write_block(int fd, unsigned char *data) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<5; i++) {
|
||||
if(write(fd, &data[i] , 1) < 0) {
|
||||
fputs("write() of byte failed!\n", stderr);
|
||||
return -1;
|
||||
}
|
||||
pause2(); /* 50 msec */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open serial port
|
||||
*
|
||||
* Set to 4800 8N2
|
||||
*
|
||||
* input:
|
||||
*
|
||||
* serial_port - ptr to a char (string) indicating port
|
||||
* to open (eg: "/dev/ttyS1").
|
||||
*
|
||||
* returns:
|
||||
*
|
||||
* fd - the file descriptor on success or -1 on error.
|
||||
*
|
||||
*/
|
||||
|
||||
int open_port(char *serial_port) {
|
||||
|
||||
int fd; /* File descriptor for the port */
|
||||
struct termios options;
|
||||
|
||||
|
||||
fd = open(serial_port, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
if (fd == -1) {
|
||||
|
||||
/* Could not open the port. */
|
||||
|
||||
printf("open_port: Unable to open %s - ",serial_port);
|
||||
return -1; /* bad */
|
||||
}
|
||||
|
||||
fcntl(fd, F_SETFL, 0); /* */
|
||||
|
||||
|
||||
/*
|
||||
* Get the current options for the port...
|
||||
*/
|
||||
|
||||
tcgetattr(fd, &options);
|
||||
|
||||
/*
|
||||
* Set the baud rates to 4800...
|
||||
*/
|
||||
|
||||
cfsetispeed(&options, B4800);
|
||||
cfsetospeed(&options, B4800);
|
||||
|
||||
/*
|
||||
* Enable the receiver and set local mode...
|
||||
*/
|
||||
|
||||
options.c_cflag |= (CLOCAL | CREAD);
|
||||
|
||||
/*
|
||||
* Set 8N2
|
||||
*/
|
||||
|
||||
options.c_cflag &= ~PARENB;
|
||||
options.c_cflag |= CSTOPB;
|
||||
options.c_cflag &= ~CSIZE;
|
||||
options.c_cflag |= CS8;
|
||||
|
||||
/*
|
||||
* Chose raw input, no preprocessing please ..
|
||||
*/
|
||||
|
||||
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
|
||||
/*
|
||||
* Chose raw output, no preprocessing please ..
|
||||
*/
|
||||
|
||||
options.c_oflag &= ~OPOST;
|
||||
|
||||
/*
|
||||
* Set the new options for the port...
|
||||
*/
|
||||
|
||||
tcsetattr(fd, TCSANOW, &options);
|
||||
|
||||
return (fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* 'close_port()' - Close serial port
|
||||
*
|
||||
* fd - file descriptor for open port
|
||||
*
|
||||
*
|
||||
* Returns success (0) or -1 on error.
|
||||
*/
|
||||
|
||||
int close_port(int fd) {
|
||||
|
||||
if (close(fd) <0 ) {
|
||||
printf("close_port: Unable to close port using fd %i - ",fd);
|
||||
return -1; /* oops */
|
||||
}
|
||||
return 0; /* ok */
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement OPCODES
|
||||
*/
|
||||
|
||||
void cmd_split_yes(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x01 }; /* split = on */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_split_no(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; /* split = off */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_recall_memory(int fd, int mem) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x02 }; /* recall memory*/
|
||||
|
||||
data[3] = mem;
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_vfo_to_memory(int fd, int mem) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x03 }; /* vfo to memory*/
|
||||
|
||||
data[3] = mem;
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_dlock_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x04 }; /* dial lock = off */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_dlock_on(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x04 }; /* dial lock = on */
|
||||
write_block(fd,data);
|
||||
|
||||
}
|
||||
|
||||
void cmd_select_vfo_a(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x05 }; /* select vfo A */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_select_vfo_b(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x05 }; /* select vfo B */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_memory_to_vfo(int fd, int mem) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x06 }; /* memory to vfo*/
|
||||
|
||||
data[3] = mem;
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_up500k(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x07 }; /* up 500 khz */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_down500k(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x08 }; /* down 500 khz */
|
||||
write_block(fd,data);
|
||||
}
|
||||
|
||||
void cmd_clarify_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x09 }; /* clarify off */
|
||||
write_block(fd,data);
|
||||
printf("cmd_clarify_off complete \n");
|
||||
}
|
||||
|
||||
void cmd_clarify_on(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x09 }; /* clarify on */
|
||||
write_block(fd,data);
|
||||
printf("cmd_clarify_on complete \n");
|
||||
}
|
||||
|
||||
void cmd_freq_set(int fd, unsigned int freq) {
|
||||
printf("cmd_freq_set not implemented yet \n");
|
||||
}
|
||||
|
||||
|
||||
void cmd_mode_set(int fd, int mode) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0c }; /* mode set */
|
||||
|
||||
data[3] = mode;
|
||||
write_block(fd,data);
|
||||
printf("cmd_mode_set complete \n");
|
||||
|
||||
}
|
||||
|
||||
void cmd_pacing_set(int fd, int delay) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0e }; /* pacing set */
|
||||
|
||||
data[3] = delay;
|
||||
write_block(fd,data);
|
||||
printf("cmd_pacing_set complete \n");
|
||||
|
||||
}
|
||||
|
||||
void cmd_ptt_off(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x0f }; /* ptt off */
|
||||
write_block(fd,data);
|
||||
printf("cmd_ptt_off complete \n");
|
||||
|
||||
}
|
||||
|
||||
void cmd_ptt_on(int fd) {
|
||||
|
||||
#ifndef TX_DISABLED
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
|
||||
write_block(fd,data);
|
||||
printf("cmd_ptt_on complete \n");
|
||||
#elsif
|
||||
printf("cmd_ptt_on disabled \n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void cmd_update(int fd) {
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */
|
||||
write_block(fd,data);
|
||||
printf("cmd_update complete \n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Read data from rig and store in buffer provided
|
||||
* by the user.
|
||||
*/
|
||||
|
||||
void cmd_update_store(int fd, unsigned char *buffer) {
|
||||
int bytes; /* read from rig */
|
||||
int i,n; /* counters */
|
||||
|
||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */
|
||||
write_block(fd,data);
|
||||
|
||||
/*
|
||||
* Sleep regularly until the buffer contains all 345 bytes
|
||||
* This should handle most values used for pacing.
|
||||
*/
|
||||
|
||||
bytes = 0;
|
||||
while(bytes < 345) {
|
||||
ioctl(fd, FIONREAD, &bytes); /* get bytes in buffer */
|
||||
printf("bytes = %i\n", bytes);
|
||||
sleep(1); /* wait 1 second */
|
||||
}
|
||||
|
||||
/* this should not block now */
|
||||
|
||||
n = read(fd,datain,345); /* grab 345 bytes from rig */
|
||||
|
||||
for(i=0; i<n; i++) {
|
||||
printf("i = %i ,datain[i] = %x \n", i, datain[i]);
|
||||
}
|
||||
|
||||
printf("cmd_update complete \n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* ft747.h - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This shared library provides an API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar
|
||||
*
|
||||
*
|
||||
* $Id: ft747.h,v 1.1 2000-07-18 20:54:28 frank Exp $
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Allow TX commands to be disabled
|
||||
*
|
||||
*/
|
||||
|
||||
#define TX_DISABLED
|
||||
|
||||
|
||||
/* MODES - when setting modes via cmd_mode_set() */
|
||||
|
||||
const int MODE_SET_LSB = 0x00;
|
||||
const int MODE_SET_USB = 0x01;
|
||||
const int MODE_SET_CWW = 0x02;
|
||||
const int MODE_SET_CWN = 0x03;
|
||||
const int MODE_SET_AMW = 0x04;
|
||||
const int MODE_SET_AMN = 0x05;
|
||||
const int MODE_SET_FMW = 0x06;
|
||||
const int MODE_SET_FMN = 0x07;
|
||||
|
||||
|
||||
/*
|
||||
* Status Flags
|
||||
*/
|
||||
|
||||
const int SF_DLOCK = (1<<0);
|
||||
const int SF_SPLIT = (1<<1);
|
||||
const int SF_CLAR = (1<<2);
|
||||
const int SF_VFOAB = (1<<3);
|
||||
const int SF_VFOMR = (1<<4);
|
||||
const int SF_RXTX = (1<<5);
|
||||
const int SF_RESV = (1<<6);
|
||||
const int SF_PRI = (1<<7);
|
||||
|
||||
|
||||
/*
|
||||
* Mode Bitmap. Bits 5 and 6 unused
|
||||
* When reading modes
|
||||
*/
|
||||
|
||||
const int MODE_FM = (1<<0);
|
||||
const int MODE_AM = (1<<1);
|
||||
const int MODE_CW = (1<<2);
|
||||
const int MODE_USB = (1<<3);
|
||||
const int MODE_LSB = (1<<4);
|
||||
const int MODE_NAR = (1<<7);
|
||||
|
||||
/*
|
||||
* Map band data value to band.
|
||||
*
|
||||
* Band "n" is from band_data[n] to band_data[n+1]
|
||||
*/
|
||||
|
||||
const float band_data[11] = { 0.0, 0.1, 2.5, 4.0, 7.5, 10.5, 14.5, 18.5, 21.5, 25.0, 30.0 };
|
||||
|
||||
|
||||
/*
|
||||
* Visible functions in shared lib.
|
||||
*
|
||||
*/
|
||||
|
||||
int open_port(char *serial_port); /* return fd or -1 on error */
|
||||
int close_port(int fd); /* close port using fd */
|
||||
|
||||
void cmd_split_yes(int fd);
|
||||
void cmd_split_no(int fd);
|
||||
void cmd_recall_memory(int fd, int mem);
|
||||
void cmd_vfo_to_memory(int fd, int mem);
|
||||
void cmd_dlock_off(int fd);
|
||||
void cmd_dlock_on(int fd);
|
||||
void cmd_select_vfo_a(int fd);
|
||||
void cmd_select_vfo_b(int fd);
|
||||
void cmd_memory_to_vfo(int fd, int mem);
|
||||
void cmd_up500k(int fd);
|
||||
void cmd_down500k(int fd);
|
||||
void cmd_clarify_off(int fd);
|
||||
void cmd_clarify_on(int fd);
|
||||
void cmd_freq_set(int fd, unsigned int freq);
|
||||
void cmd_mode_set(int fd, int mode);
|
||||
void cmd_pacing_set(int fd, int delay);
|
||||
void cmd_ptt_off(int fd);
|
||||
void cmd_ptt_on(int fd); /* careful.. */
|
||||
void cmd_update(int fd); /* data internal */
|
||||
void cmd_update_store(int fd, unsigned char *buffer); /* data external */
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
#
|
||||
# testlibft747 - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
# This program uses libft747.so to test an API for communicating
|
||||
# via serial interface to an FT-747GX using the "CAT" interface
|
||||
# box (FIF-232C) or similar
|
||||
#
|
||||
#
|
||||
# Make file for libft747.so shared lib test suite.
|
||||
#
|
||||
#
|
||||
# $Id: Makefile,v 1.1 2000-07-18 20:54:50 frank Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
#TEST_LIBDIR = ../lib
|
||||
#TEST_INCLUDEDIR = ../include
|
||||
|
||||
LIB_NAME = libft747.so
|
||||
LIB_HEADER = ft747.h
|
||||
|
||||
#LIB_SONAME = libft747.so.1
|
||||
#LIB_RELEASE = libft747.so.1.0.1
|
||||
|
||||
|
||||
CC = gcc
|
||||
INCLUDE = -I/usr/include -I/usr/local/include -I. -I../
|
||||
OBJ = testlibft747.o
|
||||
LDFLAG = -lm -lft747 -L../
|
||||
CFLAGS = -g -Wall -ansi -pedantic -O2 -D__USE_FIXED_PROTOTYPES__
|
||||
MAKEALL = testlibft747
|
||||
|
||||
all: $(MAKEALL)
|
||||
|
||||
testlibft747: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) $(LDFLAG) -o testlibft747 $(OBJ)
|
||||
|
||||
testlibft747.o: testlibft747.c testlibft747.h
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -c testlibft747.c
|
||||
|
||||
# clean up
|
||||
|
||||
clean:
|
||||
make cleanlocal
|
||||
|
||||
# clean up local directory
|
||||
|
||||
.PHONY: cleanlocal
|
||||
cleanlocal:
|
||||
rm -f *.o testlibft747
|
||||
|
||||
# run test program in local directory
|
||||
|
||||
.PHONY: runtest
|
||||
runtest:
|
||||
(LD_LIBRARY_PATH="../lib" ./testlibft747 )
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
/* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* testlibft747.c - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This program tests the libft747.so API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar.
|
||||
*
|
||||
*
|
||||
* $Id: testlibft747.c,v 1.1 2000-07-18 20:55:01 frank Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#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 "testlibft747.h"
|
||||
#include "ft747.h"
|
||||
|
||||
static unsigned char datain[350]; /* data read from rig */
|
||||
|
||||
struct ft747_update_data {
|
||||
unsigned char displayed_status;
|
||||
unsigned char displayed_freq[5];
|
||||
unsigned char current_band_data;
|
||||
unsigned char vfo_a_status;
|
||||
unsigned char vfo_a_freq_block[5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Decode routines for status update map
|
||||
*/
|
||||
|
||||
static void decode_status_flags(unsigned char flags) {
|
||||
|
||||
if((flags & SF_DLOCK) != 0 ) {
|
||||
printf("Dial Lock = SET \n");
|
||||
} else {
|
||||
printf("Dial Lock = CLEAR \n");
|
||||
}
|
||||
|
||||
if((flags & SF_SPLIT) != 0 ) {
|
||||
printf("Split = SET \n");
|
||||
} else {
|
||||
printf("Split = CLEAR \n");
|
||||
}
|
||||
|
||||
if((flags & SF_CLAR) != 0 ) {
|
||||
printf("Clar = SET \n");
|
||||
} else {
|
||||
printf("Clar = CLEAR \n");
|
||||
}
|
||||
|
||||
if((flags & SF_VFOAB) != 0 ) {
|
||||
printf("VFO = B \n");
|
||||
} else {
|
||||
printf("VFO = A \n");
|
||||
}
|
||||
|
||||
if((flags & SF_VFOMR) != 0 ) {
|
||||
printf("VFO/MR = MR \n");
|
||||
} else {
|
||||
printf("VFO/MR = VFO \n");
|
||||
}
|
||||
|
||||
if((flags & SF_RXTX) != 0 ) {
|
||||
printf("RX/TX = TX \n");
|
||||
} else {
|
||||
printf("RX/TX = RX \n");
|
||||
}
|
||||
|
||||
if((flags & SF_PRI) != 0 ) {
|
||||
printf("Priority Monitoring = ON \n");
|
||||
} else {
|
||||
printf("Priority Monitoring = OFF \n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode routines for status update map
|
||||
*/
|
||||
|
||||
static void decode_mode_bit_map(unsigned char mbm) {
|
||||
unsigned char mask = 0x1f;
|
||||
unsigned char mode = mbm & mask; /* grab operating mode */
|
||||
|
||||
printf("mbm = %x, mode = %x \n",mbm, mode);
|
||||
|
||||
switch(mode) {
|
||||
case 1:
|
||||
printf("Current Mode = FM \n");
|
||||
break;
|
||||
case 2:
|
||||
printf("Current Mode = AM \n");
|
||||
break;
|
||||
case 4:
|
||||
printf("Current Mode = CW \n");
|
||||
break;
|
||||
case 8:
|
||||
printf("Current Mode = USB \n");
|
||||
break;
|
||||
case 16:
|
||||
printf("Current Mode = LSB \n");
|
||||
break;
|
||||
default:
|
||||
printf("Current mode = XXXXX \n");
|
||||
break;
|
||||
}
|
||||
|
||||
if((mbm & MODE_NAR) != 0 ) {
|
||||
printf("Narrow = SET \n");
|
||||
} else {
|
||||
printf("Narrow = CLEAR \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode routines for status update map
|
||||
*/
|
||||
|
||||
static void decode_band_data(unsigned char data) {
|
||||
unsigned char mask = 0x0f;
|
||||
unsigned char bd = data & mask; /* grab band data */
|
||||
|
||||
printf("Band data is %f - %f \n", band_data[bd], band_data[bd+1]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Do a hex dump of the unsigned car array.
|
||||
*/
|
||||
|
||||
static void dump_hex(unsigned char *ptr, int size, int length) {
|
||||
int i;
|
||||
|
||||
printf("Memory Dump \n\n");
|
||||
for(i=0; i<size; i++) {
|
||||
printf(" 0x%2.2x", *(ptr+i));
|
||||
if (i % length == 15) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple test to see if we are talking to the RIG.
|
||||
*/
|
||||
|
||||
static int test(fd) {
|
||||
int n,i;
|
||||
int bytes = 0;
|
||||
struct ft747_update_data *header;
|
||||
|
||||
cmd_split_yes(fd);
|
||||
sleep(1);
|
||||
cmd_split_no(fd);
|
||||
sleep(1);
|
||||
cmd_dlock_on(fd);
|
||||
sleep(1);
|
||||
/* cmd_dlock_off(fd); */
|
||||
sleep(1);
|
||||
cmd_select_vfo_a(fd);
|
||||
sleep(1);
|
||||
cmd_up500k(fd);
|
||||
sleep(1);
|
||||
cmd_down500k(fd);
|
||||
sleep(1);
|
||||
/* cmd_memory_to_vfo(fd,1); */
|
||||
sleep(1);
|
||||
/* cmd_vfo_to_memory(fd,2); */
|
||||
sleep(1);
|
||||
cmd_mode_set(fd,3); /* cw */
|
||||
cmd_ptt_on(fd); /* stand back .. */
|
||||
sleep(1);
|
||||
cmd_ptt_off(fd); /* phew.. */
|
||||
sleep(1);
|
||||
|
||||
cmd_pacing_set(fd,0); /* set pacing */
|
||||
cmd_update(fd); /* request data from rig */
|
||||
/* sleep(1); */ /* be nice .. */
|
||||
/* n = read(fd,datain,345); */ /* grab 345 bytes from rig */
|
||||
|
||||
/* printf("n = %i, frequency = %.6s \n", n, datain[1]); */
|
||||
|
||||
|
||||
/*
|
||||
* Sleep regularly until the buffer contains all 345 bytes
|
||||
* This should handle most values used for pacing.
|
||||
*/
|
||||
|
||||
bytes = 0;
|
||||
while(bytes < 345) {
|
||||
ioctl(fd, FIONREAD, &bytes); /* get bytes in buffer */
|
||||
printf("bytes = %i\n", bytes);
|
||||
sleep(1);
|
||||
|
||||
}
|
||||
|
||||
/* this should not block now */
|
||||
|
||||
n = read(fd,datain,345); /* grab 345 bytes from rig */
|
||||
|
||||
for(i=0; i<n; i++) {
|
||||
printf("i = %i ,datain[i] = %x \n", i, datain[i]);
|
||||
}
|
||||
|
||||
header = (struct ft747_update_data *) &datain; /* overlay header onto datain */
|
||||
|
||||
printf("Frequency = %x.%x%x%x \n", header->displayed_freq[1],
|
||||
header->displayed_freq[2],
|
||||
header->displayed_freq[3],
|
||||
header->displayed_freq[4]
|
||||
);
|
||||
|
||||
decode_status_flags(datain[0]); /* decode flags */
|
||||
printf("Displayed Memory = %i \n", datain[23]);
|
||||
decode_mode_bit_map(datain[24]); /* decode mode bit map */
|
||||
decode_band_data(datain[6]); /* decode current band data */
|
||||
|
||||
dump_hex(datain, 345, 16); /* do a hex dump */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main program starts here..
|
||||
*/
|
||||
|
||||
|
||||
int main(void) {
|
||||
|
||||
|
||||
int fd;
|
||||
|
||||
fd = open_port(SERIAL_PORT);
|
||||
printf("port opened ok \n");
|
||||
|
||||
test(fd);
|
||||
printf("testing communication result ok \n");
|
||||
|
||||
close(fd);
|
||||
printf("port closed ok \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
*
|
||||
* testlibft747.h - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com)
|
||||
* This program tests the libft747.so API for communicating
|
||||
* via serial interface to an FT-747GX using the "CAT" interface
|
||||
* box (FIF-232C) or similar.
|
||||
*
|
||||
*
|
||||
* $Id: testlibft747.h,v 1.1 2000-07-18 20:55:08 frank Exp $
|
||||
*/
|
||||
|
||||
|
||||
#define SERIAL_PORT "/dev/ttyS1"
|
||||
|
Ładowanie…
Reference in New Issue