added intial channel support

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1209 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.4
Stéphane Fillod, F8CFE 2002-10-08 21:54:58 +00:00
rodzic e670d2c8de
commit 0780ba058e
3 zmienionych plików z 50 dodań i 19 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
* Hamlib bindings - swig interface file
* Copyright (c) 2001,2002 by Stephane Fillod
*
* $Id: hamlib.swg,v 1.3 2002-10-07 21:44:51 fillods Exp $
* $Id: hamlib.swg,v 1.4 2002-10-08 21:54:58 fillods Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -40,6 +40,8 @@
*/
%include "ignore.swg"
%rename(Chan) channel;
%include <hamlib/rig_dll.h>
%include <hamlib/riglist.h>

Wyświetl plik

@ -11,6 +11,7 @@ hamlib::rig_set_debug($hamlib::RIG_DEBUG_TRACE);
$rig = new hamlib::Rig($hamlib::RIG_MODEL_DUMMY);
$rig->open();
# 1073741944 is token value for "itu_region"
$rpath = $rig->get_conf("rig_pathname");
$region = $rig->get_conf(1073741944);
print "get_conf: path=\"$rpath\", ITU region=$region\n";
@ -42,24 +43,26 @@ print "level: $lvl\n";
$chan = new hamlib::Chan($hamlib::RIG_VFO_A);
$rig->get_channel(\$chan);
$rig->get_channel($chan);
print "get_channel status: $rig->{error_status}\n";
print "VFO: $chan->{fields}->{vfo}, $chan->{fields}->{freq}\n";
print "VFO: $chan->{vfo}, $chan->{freq}\n";
$rig->close();
($long1, $lat1) = locator2longlat("IN98EC");
($long2, $lat2) = locator2longlat("DM33DX");
$loc1 = longlat2locator($long1, $lat1);
$loc2 = longlat2locator($long2, $lat2);
# TODO:
($long1, $lat1) = hamlib::locator2longlat("IN98EC");
($long2, $lat2) = hamlib::locator2longlat("DM33DX");
$loc1 = hamlib::longlat2locator($long1, $lat1);
$loc2 = hamlib::longlat2locator($long2, $lat2);
print "Loc1: $loc1\n";
print "Loc2: $loc2\n";
($dist, $az) = qrb($long1, $lat1, $long2, $lat2);
$longpath = distance_long_path($dist);
($dist, $az) = hamlib::qrb($long1, $lat1, $long2, $lat2);
$longpath = hamlib::distance_long_path($dist);
print "Distance: $dist km, long path: $longpath\n";
($deg, $min, $sec) = dec2dms($az);
$az2 = dms2dec($deg, $min, $sec);
($deg, $min, $sec) = hamlib::dec2dms($az);
$az2 = hamlib::dms2dec($deg, $min, $sec);
print "Bearing: $az, $deg° $min' $sec\", recoded: $az2\n"

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib bindings - Rig interface
* Copyright (c) 2001,2002 by Stephane Fillod
*
* $Id: rig.swg,v 1.3 2002-10-07 21:44:51 fillods Exp $
* $Id: rig.swg,v 1.4 2002-10-08 21:54:58 fillods Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@ -34,6 +34,25 @@ typedef struct Rig {
#define MAX_STATIC 256
%extend channel {
channel(vfo_t vfo = RIG_VFO_CURR, int ch = 0) {
channel_t *chan;
chan = (channel_t*)malloc(sizeof(channel_t));
if (!chan)
return NULL;
memset(chan, 0, sizeof(channel_t));
chan->vfo = vfo;
chan->channel_num = ch;
return chan;
}
~channel (void) {
/* TODO: free up ext_levels */
free(self);
}
}
/*
* decalre wrapper method with one argument besides RIG* and optional no target vfo
*/
@ -282,7 +301,6 @@ typedef struct Rig {
#define _VFO_DECL
METHOD1(set_vfo, vfo_t) /* particular case */
METHOD1(set_powerstat, powerstat_t)
METHOD1(set_channel, const_channel_t_p)
METHOD1(set_trn, int)
METHOD1(has_set_level, setting_t)
METHOD1(has_set_parm, setting_t)
@ -353,17 +371,25 @@ typedef struct Rig {
//METHOD2GET(get_ext_parm, token_t, value_t)
void set_channel(const struct channel *chan) {
self->error_status = rig_set_channel(self->rig, chan);
}
void get_channel(struct channel *chan) {
self->error_status = rig_get_channel(self->rig, chan);
/* TODO: handle ext_level's */
}
/* get_channel() returns current VFO data
* get_channel(10) returns content of memory #10
* get_channel(0, RIG_VFO_A) returns VFO A data
*/
const channel_t *get_channel(int channel_num = INT_MAX, vfo_t vfo = RIG_VFO_MEM) {
static channel_t chan;
chan.channel_num = channel_num;
chan.vfo = channel_num != INT_MAX ? vfo : RIG_VFO_CURR;
self->error_status = rig_get_channel(self->rig, &chan);
struct channel *get_channel(int channel_num = INT_MAX, vfo_t vfo = RIG_VFO_MEM) {
channel_t *chan;
chan = new_channel(channel_num, channel_num != INT_MAX ? vfo : RIG_VFO_CURR);
self->error_status = rig_get_channel(self->rig, chan);
/* TODO: copy ext_level's */
return &chan;
return chan;
}
const char *get_conf(token_t tok) {