git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@64 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.0.1
Frank Singleton, VK3FCS 2000-07-30 05:09:51 +00:00
rodzic fa7fd393fb
commit d63d4ec9df
5 zmienionych plików z 32 dodań i 107 usunięć

Wyświetl plik

@ -5,7 +5,7 @@
* Provides useful routines for read/write serial data for communicating
* via serial interface .
*
* $Id: serial.c,v 1.5 2000-07-30 04:38:33 javabear Exp $
* $Id: serial.c,v 1.6 2000-07-30 05:08:24 javabear Exp $
*
*/
@ -185,7 +185,6 @@ int write_block(int fd, unsigned char *txbuffer) {
int read_sleep(int fd, unsigned char *rxbuffer, int num ) {
int bytes = 0;
int n = 0;
int i;
printf("serial:read_sleep called with num = %i \n",num);

Wyświetl plik

@ -7,7 +7,7 @@
* box (FIF-232C) or similar
*
*
* $Id: ft747.c,v 1.6 2000-07-30 04:02:56 javabear Exp $
* $Id: ft747.c,v 1.7 2000-07-30 05:06:24 javabear Exp $
*
*/
@ -171,7 +171,7 @@ void cmd_set_ptt_on(int fd) {
*/
void cmd_get_update_store(int fd, unsigned char *buffer) {
int i,n; /* counters */
int n; /* counter */
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x10 }; /* request update from rig */

Wyświetl plik

@ -6,7 +6,7 @@
* box (FIF-232C) or similar.
*
*
* $Id: testlibft747.c,v 1.6 2000-07-30 05:04:04 javabear Exp $
* $Id: testlibft747.c,v 1.7 2000-07-30 05:05:10 javabear Exp $
*
*/

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an FT-847 using the "CAT" interface.
*
*
* $Id: ft847.c,v 1.13 2000-07-30 04:26:39 javabear Exp $
* $Id: ft847.c,v 1.14 2000-07-30 05:07:17 javabear Exp $
*
*/
@ -24,12 +24,8 @@
static unsigned char datain[5]; /* data read from rig */
static char calc_packed_from_char(unsigned char dec );
static char calc_char_from_packed(unsigned char pkd );
static long int calc_freq_from_packed4(unsigned char *in);
static void calc_packed4_from_freq(long int freq, unsigned char *out);
static long int calc_freq_from_packed4_b(unsigned char *in);
/*
* Function definitions below
@ -100,10 +96,8 @@ void cmd_set_sat_off(int fd) {
void cmd_set_freq_main_vfo(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4) {
int i;
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x00, 0x01 }; /* set freq, main vfo*/
data[0] = d1;
data[1] = d2;
data[2] = d3;
@ -309,7 +303,7 @@ long int cmd_get_freq_mode_status_main_vfo(int fd, unsigned char *mode) {
/* main vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4_b(datain); /* 1st 4 bytes */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
@ -328,7 +322,7 @@ long int cmd_get_freq_mode_status_sat_rx_vfo(int fd, unsigned char *mode ) {
/* sat rx vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4_b(datain); /* 1st 4 bytes */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
@ -347,7 +341,7 @@ long int cmd_get_freq_mode_status_sat_tx_vfo(int fd, unsigned char *mode) {
/* sat tx vfo*/
write_block(fd,data);
read_sleep(fd,datain,5); /* wait and read for 5 byte to be read */
f = calc_freq_from_packed4_b(datain); /* 1st 4 bytes */
f = calc_freq_from_packed4(datain); /* 1st 4 bytes */
*mode = datain[4]; /* last byte */
return f; /* return freq in Hz */
@ -428,43 +422,19 @@ void cmd_set_freq_sat_tx_vfo_hz(int fd,long int freq, unsigned char mode) {
}
/*
* Private helper functions....
*
*/
/*
* Calculate freq from packed decimal (4 bytes, 8 digits)
* and return frequency in Hz.
*
*/
static long int calc_freq_from_packed4(unsigned char *in) {
long int f; /* frequnecy in Hz */
unsigned char sfreq[9]; /* 8 digits + \0 */
printf("frequency/mode = %.2x%.2x%.2x%.2x %.2x \n", datain[0], datain[1], datain[2],datain[3],datain[4]);
snprintf(sfreq,9,"%.2x%.2x%.2x%.2x",in[0], in[1], in[2], in[3]);
f = atol(sfreq);
f = f *10; /* yaesu returns freq to 10 Hz, so must */
/* scale to return Hz*/
printf("frequency = %ld Hz\n", f);
return f; /* Hz */
}
/*
* Calculate freq from packed decimal (4 bytes, 8 digits)
* and return frequency in Hz. No string routines.
*
*/
static long int calc_freq_from_packed4_b(unsigned char *in) {
static long int calc_freq_from_packed4(unsigned char *in) {
long int f; /* frequnecy in Hz */
unsigned char d1,d2,d3,d4;
@ -483,7 +453,7 @@ static long int calc_freq_from_packed4_b(unsigned char *in) {
f = f *10; /* yaesu requires freq as multiple of 10 Hz, so must */
/* scale to return Hz*/
printf("frequency = %ld Hz\n", f);
printf("ft847:frequency = %ld Hz\n", f);
return f; /* Hz */
}
@ -499,7 +469,6 @@ static long int calc_freq_from_packed4_b(unsigned char *in) {
static void calc_packed4_from_freq(long int freq, unsigned char *out) {
unsigned char d1,d2,d3,d4;
long int f1,f2,f3,f4;
long int testf;
freq = freq / 10; /* yaesu ft847 only accepts 10Hz resolution */
@ -508,12 +477,6 @@ static void calc_packed4_from_freq(long int freq, unsigned char *out) {
f3 = (freq - (f1 * 1000000) - (f2 * 10000)) / 100; /* get 10khz/1khz part */
f4 = (freq - (f1 * 1000000) - (f2 * 10000) - (f3 * 100)); /* get 10khz/1khz part */
printf("Decimal: f1 = %ld, f2 = %ld, f3 = %ld, f4 = %ld \n", f1,f2,f3,f4);
printf("Decimal: f1 = %.2ld, f2 = %.2ld, f3 = %.2ld, f4 = %.2ld \n", f1,f2,f3,f4);
testf = f1*1000000 + f2*10000 + f3*100 +f4; /* just checking */
printf("testf = %ld \n",testf);
d1 = calc_packed_from_char(f1);
d2 = calc_packed_from_char(f2);
d3 = calc_packed_from_char(f3);
@ -530,53 +493,3 @@ static void calc_packed4_from_freq(long int freq, unsigned char *out) {
/*
* Convert char to packed decimal
* eg: 33 (0x21) => 0x33
*
*/
static char calc_packed_from_char(unsigned char dec ) {
char d1,d2,pkd;
d1 = dec/10;
d2 = dec - (d1 * 10);
pkd = (d1*16)+d2;
printf("dec = %i \n", dec);
printf("dec = %x \n", dec);
printf("dec (packed) = %.2x \n", pkd);
return pkd;
}
/*
* Convert packed decimal to decimal
* eg: 0x33 (51) => 33 decimal
*
*/
static char calc_char_from_packed(unsigned char pkd ) {
char d1,d2,dec;
d1 = pkd/16;
d2 = pkd - (d1 * 16);
dec = (d1*10)+d2;
printf("pkd (hex) = %x \n", pkd);
printf("pkd (dec) = %i \n", pkd);
printf("dec = %.2x \n", dec);
return dec;
}

Wyświetl plik

@ -6,7 +6,7 @@
* via serial interface to an FT-847 using the "CAT" interface.
*
*
* $Id: ft847.h,v 1.7 2000-07-30 00:29:52 javabear Exp $
* $Id: ft847.h,v 1.8 2000-07-30 05:09:51 javabear Exp $
*/
/*
@ -65,12 +65,14 @@ int rig_close(int fd);
*
*/
void cmd_cat_on(int fd);
void cmd_cat_off(int fd);
void cmd_ptt_on(int fd);
void cmd_ptt_off(int fd);
void cmd_sat_on(int fd);
void cmd_sat_off(int fd);
void cmd_set_cat_on(int fd);
void cmd_set_cat_off(int fd);
void cmd_set_ptt_on(int fd);
void cmd_set_ptt_off(int fd);
void cmd_set_sat_on(int fd);
void cmd_set_sat_off(int fd);
void cmd_set_freq_main_vfo(int fd, unsigned char d1, unsigned char d2,
unsigned char d3, unsigned char d4);
@ -124,6 +126,17 @@ long int cmd_get_freq_mode_status_sat_tx_vfo(int fd, unsigned char *mode);
*/
void cmd_set_freq_main_vfo_hz(int fd,long int freq, unsigned char mode);
void cmd_set_freq_main_sat_rx_hz(int fd,long int freq, unsigned char mode);
void cmd_set_freq_main_sat_tx_hz(int fd,long int freq, unsigned char mode);
void cmd_set_freq_sat_rx_vfo_hz(int fd,long int freq, unsigned char mode);
void cmd_set_freq_sat_tx_vfo_hz(int fd,long int freq, unsigned char mode);