kopia lustrzana https://github.com/Hamlib/Hamlib
using rig_open and rig_close and serial.h
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@28 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.0.0
rodzic
5cbc606531
commit
1ae52ab67f
151
ft747/ft747.c
151
ft747/ft747.c
|
@ -7,7 +7,7 @@
|
||||||
* box (FIF-232C) or similar
|
* box (FIF-232C) or similar
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Id: ft747.c,v 1.1 2000-07-18 20:54:22 frank Exp $
|
* $Id: ft747.c,v 1.2 2000-07-27 00:43:58 javabear Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -20,18 +20,11 @@
|
||||||
#include <termios.h> /* POSIX terminal control definitions */
|
#include <termios.h> /* POSIX terminal control definitions */
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include "serial.h"
|
||||||
#include "ft747.h"
|
#include "ft747.h"
|
||||||
|
|
||||||
static unsigned char datain[350]; /* data read from rig */
|
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
|
* Function definitions below
|
||||||
|
@ -39,144 +32,22 @@ struct ft747_update_data {
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provides delay for block formation.
|
* Open serial connection to rig.
|
||||||
* Should be 50-200 msec according to YAESU docs.
|
* returns fd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void pause2() {
|
|
||||||
usleep(50 * 1000); /* 50 msec */
|
int rig_open(char *serial_port) {
|
||||||
return;
|
return open_port(serial_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a 5 character block to a file descriptor,
|
* Closes serial connection to rig.
|
||||||
* 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 rig_close(int fd) {
|
||||||
int i;
|
return close_port(fd);
|
||||||
|
|
||||||
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 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -289,7 +160,7 @@ void cmd_ptt_off(int fd) {
|
||||||
|
|
||||||
void cmd_ptt_on(int fd) {
|
void cmd_ptt_on(int fd) {
|
||||||
|
|
||||||
#ifndef TX_DISABLED
|
#ifdef TX_ENABLED
|
||||||
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
|
static unsigned char data[] = { 0x00, 0x00, 0x00, 0x01, 0x0f }; /* ptt on */
|
||||||
write_block(fd,data);
|
write_block(fd,data);
|
||||||
printf("cmd_ptt_on complete \n");
|
printf("cmd_ptt_on complete \n");
|
||||||
|
|
Ładowanie…
Reference in New Issue