1 /*
2  *  Hamlib R&S backend - ESMC description
3  *  Copyright (c) 2009 by Stephane Fillod
4  *
5  *
6  *   This library is free software; you can redistribute it and/or
7  *   modify it under the terms of the GNU Lesser General Public
8  *   License as published by the Free Software Foundation; either
9  *   version 2.1 of the License, or (at your option) any later version.
10  *
11  *   This library is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *   Lesser General Public License for more details.
15  *
16  *   You should have received a copy of the GNU Lesser General Public
17  *   License along with this library; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include <stdlib.h>
27 
28 #include <hamlib/rig.h>
29 #include "rs.h"
30 
31 
32 /* TODO: LOG and PULSE ? */
33 #define ESMC_MODES (RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_WFM)
34 
35 #define ESMC_FUNC (RIG_FUNC_SQL|RIG_FUNC_AFC)
36 
37 #define ESMC_LEVEL_ALL (RIG_LEVEL_ATT|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_RF|RIG_LEVEL_STRENGTH)
38 
39 #define ESMC_PARM_ALL (RIG_PARM_NONE)
40 
41 #define ESMC_VFO (RIG_VFO_A)
42 
43 #define ESMC_VFO_OPS (RIG_OP_NONE)
44 
45 #define ESMC_MEM_CAP {    \
46         .freq = 1,      \
47         .mode = 1,      \
48         .width = 1,     \
49         .ant = 1,     \
50         .funcs = ESMC_FUNC, \
51         .levels = RIG_LEVEL_SET(ESMC_LEVEL_ALL), \
52         .channel_desc=1, \
53         .flags = RIG_CHFLAG_SKIP, \
54 }
55 
56 
57 /*
58  * ESMC rig capabilities.
59  *
60  * Needs option ESMC-R2 for computer operation RS232C/RS422/RS485
61  *
62  * http://www2.rohde-schwarz.com/file/ESMC_25.pdf
63  */
64 
65 const struct rig_caps esmc_caps =
66 {
67     RIG_MODEL(RIG_MODEL_ESMC),
68     .model_name = "ESMC",
69     .mfg_name =  "Rohde&Schwarz",
70     .version =  BACKEND_VER ".0",
71     .copyright =  "LGPL",
72     .status =  RIG_STATUS_ALPHA,
73     .rig_type =  RIG_TYPE_RECEIVER,
74     .ptt_type =  RIG_PTT_NONE,
75     .dcd_type =  RIG_DCD_RIG,
76     .port_type =  RIG_PORT_SERIAL,
77     .serial_rate_min =  300,    /* 7E2 */
78     .serial_rate_max =  115200, /* 7E1, RTS/CTS */
79     .serial_data_bits =  7,
80     .serial_stop_bits =  1,
81     .serial_parity =  RIG_PARITY_EVEN,
82     .serial_handshake =  RIG_HANDSHAKE_HARDWARE,
83     .write_delay =  0,
84     .post_write_delay =  0,
85     .timeout =  200,
86     .retry =  3,
87 
88     .has_get_func =  ESMC_FUNC,
89     .has_set_func =  ESMC_FUNC,
90     .has_get_level =  ESMC_LEVEL_ALL,
91     .has_set_level =  RIG_LEVEL_SET(ESMC_LEVEL_ALL),
92     .has_get_parm =  ESMC_PARM_ALL,
93     .has_set_parm =  RIG_PARM_SET(ESMC_PARM_ALL),
94     .level_gran =  {},
95     .parm_gran =  {},
96     .ctcss_list =  NULL,
97     .dcs_list =  NULL,
98     .preamp =   { RIG_DBLST_END },
99     .attenuator =   { 30, RIG_DBLST_END },
100     .max_rit =  Hz(0),
101     .max_xit =  Hz(0),
102     .max_ifshift =  Hz(0),
103     .targetable_vfo =  0,
104     .transceive =  RIG_TRN_OFF,
105     .bank_qty =   0,
106     .chan_desc_sz =  7, /* FIXME */
107     .vfo_ops =  ESMC_VFO_OPS,
108 
109     .chan_list =  {
110         { 0, 999, RIG_MTYPE_MEM, ESMC_MEM_CAP },
111         RIG_CHAN_END,
112     },
113 
114     /*
115      * With following options:
116      * ESMC-T2 20 MHz to 1.3 GHz
117      * ESMC-T0 0.5 MHz to 30 MHz
118      * ESMC-FE 20 MHz to 3 GHz
119      */
120     .rx_range_list1 =  {
121         {kHz(20), MHz(650), ESMC_MODES, -1, -1, ESMC_VFO},
122         RIG_FRNG_END,
123     },
124     .tx_range_list1 =  { RIG_FRNG_END, },
125     .rx_range_list2 =  {
126         {kHz(20), MHz(650), ESMC_MODES, -1, -1, ESMC_VFO},
127         RIG_FRNG_END,
128     },
129     .tx_range_list2 =  { RIG_FRNG_END, },
130 
131     .tuning_steps =  {
132         {ESMC_MODES, 1},
133         {ESMC_MODES, 10},
134         {ESMC_MODES, 100},
135         {ESMC_MODES, 1000},
136         RIG_TS_END,
137     },
138 
139     /* mode/filter list, remember: order matters! */
140     .filters =  {
141         {RIG_MODE_WFM, kHz(200)},
142         {RIG_MODE_FM | RIG_MODE_AM, kHz(15)},
143         {ESMC_MODES, kHz(2.5)},
144         {ESMC_MODES, kHz(0.5)},
145         {ESMC_MODES, kHz(8)},
146         {ESMC_MODES, kHz(15)},
147         {ESMC_MODES, kHz(30)},
148         {ESMC_MODES, kHz(50)},
149         {ESMC_MODES, kHz(100)},
150         {ESMC_MODES, kHz(200)},
151         {ESMC_MODES, kHz(500)},
152         {ESMC_MODES, MHz(1)},
153         {ESMC_MODES, MHz(2)},
154         {ESMC_MODES, MHz(4)},
155         {ESMC_MODES, MHz(8)},
156         RIG_FLT_END,
157     },
158     .priv =  NULL,
159 
160     .set_freq =  rs_set_freq,
161     .get_freq =  rs_get_freq,
162     .set_mode =  rs_set_mode,
163     .get_mode =  rs_get_mode,
164     .set_level =  rs_set_level,
165     .get_level =  rs_get_level,
166     .set_func =  rs_set_func,
167     .get_func =  rs_get_func,
168     .get_info =  rs_get_info,
169 
170 #if 0
171     /* TODO */
172     .rig_open =  rs_rig_open,
173     .set_channel =  rs_set_channel,
174     .get_channel =  rs_get_channel,
175 #endif
176 };
177 
178 /*
179  * Function definitions below
180  */
181 
182