From 73b87d41590ba99f3ee8fa9cb3bb9b3408751135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Thu, 14 Sep 2000 00:44:21 +0000 Subject: [PATCH] file creation, not in a compilable/working state git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@90 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- ic706/Makefile | 120 +++++++++++++++++++++++++++++++ ic706/TODO.ic706 | 16 +++++ ic706/ic706.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++ ic706/ic706.h | 43 +++++++++++ 4 files changed, 361 insertions(+) create mode 100644 ic706/Makefile create mode 100644 ic706/TODO.ic706 create mode 100644 ic706/ic706.c create mode 100644 ic706/ic706.h diff --git a/ic706/Makefile b/ic706/Makefile new file mode 100644 index 000000000..c26847fa3 --- /dev/null +++ b/ic706/Makefile @@ -0,0 +1,120 @@ +# +# +# Make file for IC706 program shared lib +# +# creates: libic706.so +# +# $Id: Makefile,v 1.1 2000-09-14 00:44:21 f4cfe Exp $ +# +# +# .h files go in INSTALL_INCLUDEDIR +# .so files go in INSTALL_LIBDIR +# +# + + +INSTALL_LIBDIR = ./lib/ +INSTALL_INCLUDEDIR = ./include/ +INCLUDE = -I/usr/include -I/usr/local/include -I. -I../common + +LIB_NAME = libic706.so +LIB_SONAME = libic706.so.1 +LIB_RELEASE = libic706.so.1.0.1 +LIB_HEADER = ic706.h +LIB_SRC = ic706.c +LIB_OBJECTS = ic706.o + +CC = gcc +CFLAGS = -fPIC -g -Wall + +all: lib + +.PHONY: lib +lib: + $(CC) $(CFLAGS) $(INCLUDE) -c $(LIB_SRC) + $(CC) -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 libic706.h in INSTALL_INCLUDEDIR + +.PHONY: install_header +install_header: + cp -f $(LIB_HEADER) $(INSTALL_INCLUDEDIR) + +# build lib and install and build test suite, but DONT run it + +.PHONY: build_all +build_all: + make all + make install + (cd test && $(MAKE) all) + +# build everything and run test suite ( stand back ..) + +.PHONY: verify +verify: + make build_all + (cd test && $(MAKE) runtest) + +# clean up local directory, my include and lib +# directories also. + +clean: + make cleanlocal + make cleanlib + make cleaninclude + +# clean up local directory, my include and lib and test +# directories also. +.PHONY: cleanall +cleanall: + make cleanlocal + make cleanlib + make cleaninclude + make cleantest + + +# 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) + + +# clean up test directory + +.PHONY: cleantest +cleantest: + (cd test && $(MAKE) clean) + + + + + diff --git a/ic706/TODO.ic706 b/ic706/TODO.ic706 new file mode 100644 index 000000000..66bf7c960 --- /dev/null +++ b/ic706/TODO.ic706 @@ -0,0 +1,16 @@ +hamlib - (C) Frank Singleton 2000 + +TODO.ic706 - Copyright (C) 2000 Stephane Fillod +This shared library provides an API for communicating +via serial interface to an IC-706 using the "CI-V" interface. + +TODO +---- + +0. complete this TODO list :) +1. Complete pcodes +2. Write More extensive Test Suite +3. +4. +5. + diff --git a/ic706/ic706.c b/ic706/ic706.c new file mode 100644 index 000000000..ffb5cd545 --- /dev/null +++ b/ic706/ic706.c @@ -0,0 +1,182 @@ +/* + * hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com) + * + * ic706.c - Copyright (C) 2000 Stephane Fillod + * This shared library provides an API for communicating + * via serial interface to an IC-706 using the "CI-V" interface. + * + * + * $Id: ic706.c,v 1.1 2000-09-14 00:44:21 f4cfe Exp $ + * + * + * + * 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. + * + */ + +#include +#include /* Standard input/output definitions */ +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include /* File control definitions */ +#include /* Error number definitions */ +#include /* POSIX terminal control definitions */ +#include + +#include +#include +#include +#include "ic706.h" + +#define IC706_ALL_RX_MODES (RIG_MODE_AM| RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB| RIG_MODE_RTTY| RIG_MODE_FM| RIG_MODE_WFM| RIG_MODE_NFM| RIG_MODE_NAM| RIG_MODE_CWR) + +/* tx doesn't have WFM. + * 100W in all modes but AM (40W) + */ +#define IC706_OTHER_TX_MODES (RIG_MODE_AM| RIG_MODE_CW| RIG_MODE_USB| RIG_MODE_LSB| RIG_MODE_RTTY| RIG_MODE_FM| RIG_MODE_NFM| RIG_MODE_NAM| RIG_MODE_CWR) +#define IC706_AM_TX_MODES (RIG_MODE_AM| RIG_MODE_NAM) + + +/* + * ic706 rigs capabilities. + * Notice that some rigs share the same functions. + * Also this struct is READONLY! + */ +const struct rig_caps ic706_caps = { + RIG_MODEL_IC706, "IC-706", "Icom", "0.1", RIG_STATUS_NEW, + RIG_TYPE_MOBILE, 1200, 57600, 8, 1, RIG_PARITY_NONE, + { {30000,199999999,IC706_ALL_RX_MODES,-1,-1}, {0,0,0,0,0}, }, /* rx range */ + { {1800000,1999999,IC706_OTHER_TX_MODES,5000,100000}, /* 100W class */ + {1800000,1999999,IC706_AM_TX_MODES,2000,40000}, /* 40W class */ + {3500000,3999999,IC706_OTHER_TX_MODES,5000,100000}, + {3500000,3999999,IC706_AM_TX_MODES,2000,40000}, + /* TODO: complete HF list. */ + {144000000,148000000,IC706_OTHER_TX_MODES,5000,20000}, /* not sure.. */ + {144000000,148000000,IC706_AM_TX_MODES,2000,20000}, /* ?? */ + {0,0,0,0,0} }, + ic706_init, ic706_cleanup, NULL /* probe not supported */, + ic706_set_freq_main_vfo_hz +}; + +const struct rig_caps ic706mkiig_caps = { + RIG_MODEL_IC706MKIIG, "IC-706MKIIG", "Icom", "0.1", RIG_STATUS_NEW, + RIG_TYPE_MOBILE, 1200, 57600, 8, 1, RIG_PARITY_NONE, + { {30000,199999999,IC706_ALL_RX_MODES,-1,-1}, /* this trx also has UHF */ + {400000000,470000000,IC706_ALL_RX_MODES,-1,-1}, {0,0,0,0,0}, }, + { {1800000,1999999,IC706_OTHER_TX_MODES,5000,100000}, /* 100W class */ + {1800000,1999999,IC706_AM_TX_MODES,2000,40000}, /* 40W class */ + {3500000,3999999,IC706_OTHER_TX_MODES,5000,100000}, + {3500000,3999999,IC706_AM_TX_MODES,2000,40000}, + /* TODO: complete HF list. */ + {144000000,148000000,IC706_OTHER_TX_MODES,5000,50000}, /* 50W */ + {144000000,148000000,IC706_AM_TX_MODES,2000,20000}, /* AM VHF is 20W */ + {430000000,450000000,IC706_OTHER_TX_MODES,5000,20000}, + {430000000,450000000,IC706_AM_TX_MODES,2000,8000}, + {0,0,0,0,0}, }, + ic706_init, ic706_cleanup, NULL /* probe not supported */, + ic706_set_freq_main_vfo_hz +}; + + +/* + * Function definitions below + */ + +/* + * setup *priv + * serial port is already open (rig->state->fd) + */ +static int ic706_init(RIG *rig) +{ + struct ic706_priv_data *p; + + if (!rig) + return -1; + p = (struct ic706_priv_data*)malloc(sizeof(struct ic706_priv_data)); + if (!p) { + /* whoops! memory shortage! */ + return -2; + } + /* TODO: CI-V address should be customizable */ + p->trx_civ_address = 0x58; /* Transceiver's default address */ + p->ctrl_civ_address = 0xe0; + + rig->state.priv = (void*)p; + + return 0; +} + +/* + * the serial port is closed by the frontend + */ +static int ic706_cleanup(RIG *rig) +{ + if (!rig) + return -1; + + if (rig->state.priv) + free(rig->state.priv); + rig->state.priv = NULL; + + return 0; +} + +/* + * TODO: implement (ie. rewrite it) this function properly, + * right now it just serves as a backend example + */ +static int ic706_set_freq_main_vfo_hz(struct rig_state *rig_s, freq_t freq, rig_mode_t mode) +{ + struct ic706_priv_data *p; + unsigned char buf[16]; + int cmd_len; + + if (!rig_s) + return -1; + + p = (struct ic706_priv_data*)rig_s->priv; + + buf[0] = 0xfe; /* Preamble */ + buf[1] = 0xfe; + buf[2] = p->trx_civ_address; + buf[3] = p->ctrl_civ_address; + if (p->civ_731_mode) { + buf[4] = freq2bcd(freq,0); /* BCD freq, freq2bcd to be written!*/ + buf[5] = freq2bcd(freq,1); + buf[6] = freq2bcd(freq,2); + buf[7] = freq2bcd(freq,3); + buf[8] = 0xfd; /* EOM code */ + cmd_len = 9; + } else { + buf[4] = freq2bcd(freq,0); /* BCD freq, freq2bcd to be written!*/ + buf[5] = freq2bcd(freq,1); + buf[6] = freq2bcd(freq,2); + buf[7] = freq2bcd(freq,3); + buf[8] = freq2bcd(freq,4); + buf[9] = 0xfd; /* EOM code */ + cmd_len = 10; + } + + /* should check return code and that write wrote cmd_len chars! */ + write(rig_s->fd, buf, cmd_len); + + /* wait for ACK ... etc.. */ + /* then set the mode ... */ + + return 0; +} + + + diff --git a/ic706/ic706.h b/ic706/ic706.h new file mode 100644 index 000000000..19067a137 --- /dev/null +++ b/ic706/ic706.h @@ -0,0 +1,43 @@ +/* + * hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com) + * + * ic706.h - Copyright (C) 2000 Stephane Fillod + * This shared library provides an API for communicating + * via serial interface to an IC-706 using the "CI-V" interface. + * + * + * $Id: ic706.h,v 1.1 2000-09-14 00:44:21 f4cfe Exp $ + * + * + * 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. + * + */ + +#ifndef _IC706_H +#define _IC706_H 1 + + +struct ic706_priv_data { + unsigned char trx_civ_address; /* the remote equipment's CI-V address*/ + unsigned char ctrl_civ_address; /* the controller's CI-V address */ + int civ_731_mode; /* Off: freqs on 5 bytes, On: freqs on 4 bytes */ +}; + +static int ic706_init(RIG *rig); +static int ic706_cleanup(RIG *rig); +static int ic706_set_freq_main_vfo_hz(struct rig_state *rig_s, freq_t freq, rig_mode_t mode); + +#endif /* _IC706_H */ +