Skip to content

Commit 728db84

Browse files
committed
Finish tests/*
1 parent 07f8023 commit 728db84

File tree

9 files changed

+40
-42
lines changed

9 files changed

+40
-42
lines changed

extra/gnuradio/gnuradio.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int gr_init(RIG *rig)
132132
rig->state.priv = (void*)priv;
133133

134134
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__ );
135-
rig->state.rigport.type.rig = RIG_PORT_NONE;
135+
RIGORT(rig)->type.rig = RIG_PORT_NONE;
136136

137137
memset(priv->parms, 0, RIG_SETTING_MAX*sizeof(value_t));
138138

tests/ampctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ int main(int argc, char *argv[])
328328

329329
if (amp_file)
330330
{
331-
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
331+
strncpy(AMPPORT(my_amp)->pathname, amp_file, HAMLIB_FILPATHLEN - 1);
332332
strncpy(my_amp->state.ampport_deprecated.pathname, amp_file,
333333
HAMLIB_FILPATHLEN - 1);
334334
}
335335

336336
/* FIXME: bound checking and port type == serial */
337337
if (serial_rate != 0)
338338
{
339-
my_amp->state.ampport.parm.serial.rate = serial_rate;
339+
AMPPORT(my_amp)->parm.serial.rate = serial_rate;
340340
my_amp->state.ampport_deprecated.parm.serial.rate = serial_rate;
341341
}
342342

tests/ampctl_parse.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ declare_proto_amp(get_powerstat)
19901990
declare_proto_amp(send_cmd)
19911991
{
19921992
int retval;
1993-
struct amp_state *rs;
1993+
hamlib_port_t *ampp = AMPPORT(amp);
19941994
int backend_num, cmd_len;
19951995
#define BUFSZ 128
19961996
unsigned char bufcmd[BUFSZ];
@@ -2038,11 +2038,9 @@ declare_proto_amp(send_cmd)
20382038
eom_buf[2] = send_cmd_term;
20392039
}
20402040

2041-
rs = &amp->state;
2041+
rig_flush(ampp);
20422042

2043-
rig_flush(&rs->ampport);
2044-
2045-
retval = write_block(&rs->ampport, bufcmd, cmd_len);
2043+
retval = write_block(ampp, bufcmd, cmd_len);
20462044

20472045
if (retval != RIG_OK)
20482046
{
@@ -2060,7 +2058,7 @@ declare_proto_amp(send_cmd)
20602058
* assumes CR or LF is end of line char
20612059
* for all ascii protocols
20622060
*/
2063-
retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
2061+
retval = read_string(ampp, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1);
20642062

20652063
if (retval < 0)
20662064
{

tests/rig_bench.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ int main(int argc, const char *argv[])
6767
my_rig->caps->version,
6868
rig_strstatus(my_rig->caps->status));
6969

70-
printf("Serial speed: %d baud\n", my_rig->state.rigport.parm.serial.rate);
70+
printf("Serial speed: %d baud\n", RIGPORT(my_rig)->parm.serial.rate);
7171
#if 0 // if we want to bench serial or network I/O use this time
7272
rig_set_cache_timeout_ms(my_rig, HAMLIB_CACHE_ALL, 0);
7373
#endif
7474

75-
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
75+
strncpy(RIGPORT(my_rig)->pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
7676

7777
retcode = rig_open(my_rig);
7878

tests/rigctl_parse.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,7 @@ declare_proto_rig(set_ptt)
25762576
if (rig->caps->ptt_type != RIG_PTT_RIG_MICDATA)
25772577
{
25782578
rig_debug(RIG_DEBUG_ERR, "%s: pttport.type.ptt=%d\n", __func__,
2579-
rig->state.pttport.type.ptt);
2579+
PTTPORT(rig)->type.ptt);
25802580
ptt = RIG_PTT_ON;
25812581
}
25822582

@@ -4654,7 +4654,7 @@ declare_proto_rig(dump_state)
46544654
{
46554655
fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops);
46564656
fprintf(fout, "ptt_type=0x%x\n",
4657-
rig->state.pttport.type.ptt);
4657+
PTTPORT(rig)->type.ptt);
46584658
fprintf(fout, "targetable_vfo=0x%x\n", rig->caps->targetable_vfo);
46594659
fprintf(fout, "has_set_vfo=%d\n", rig->caps->set_vfo != NULL);
46604660
fprintf(fout, "has_get_vfo=%d\n", rig->caps->get_vfo != NULL);
@@ -5005,7 +5005,7 @@ extern int flrig_cat_string(RIG *rig, const char *arg);
50055005
declare_proto_rig(send_cmd)
50065006
{
50075007
int retval;
5008-
struct rig_state *rs = &rig->state;
5008+
hamlib_port_t *rp = RIGPORT(rig);
50095009
int backend_num, cmd_len;
50105010
#define BUFSZ 512
50115011
char bufcmd[BUFSZ * 5]; // allow for 5 chars for binary
@@ -5015,7 +5015,7 @@ declare_proto_rig(send_cmd)
50155015
int rxbytes = BUFSZ;
50165016
int simulate = rig->caps->rig_model == RIG_MODEL_DUMMY ||
50175017
rig->caps->rig_model == RIG_MODEL_NONE ||
5018-
rs->rigport.rig == RIG_PORT_NONE;
5018+
rp->rig == RIG_PORT_NONE;
50195019

50205020
ENTERFUNC2;
50215021

@@ -5120,7 +5120,7 @@ declare_proto_rig(send_cmd)
51205120
}
51215121

51225122
rig_debug(RIG_DEBUG_TRACE, "%s: rigport=%d, bufcmd=%s, cmd_len=%d\n", __func__,
5123-
rs->rigport.fd, hasbinary(bufcmd, cmd_len) ? "BINARY" : bufcmd, cmd_len);
5123+
rp->fd, hasbinary(bufcmd, cmd_len) ? "BINARY" : bufcmd, cmd_len);
51245124

51255125
set_transaction_active(rig);
51265126

@@ -5131,17 +5131,17 @@ declare_proto_rig(send_cmd)
51315131
}
51325132
else
51335133
{
5134-
rig_flush(&rs->rigport);
5134+
rig_flush(rp);
51355135

51365136
// we don't want the 'w' command to wait too long
5137-
int save_retry = rs->rigport.retry;
5138-
rs->rigport.retry = 0;
5139-
retval = write_block(&rs->rigport, (unsigned char *) bufcmd, cmd_len);
5140-
rs->rigport.retry = save_retry;
5137+
int save_retry = rp->retry;
5138+
rp->retry = 0;
5139+
retval = write_block(rp, (unsigned char *) bufcmd, cmd_len);
5140+
rp->retry = save_retry;
51415141

51425142
if (retval != RIG_OK)
51435143
{
5144-
rig_flush_force(&rs->rigport, 1);
5144+
rig_flush_force(rp, 1);
51455145
set_transaction_inactive(rig);
51465146
RETURNFUNC2(retval);
51475147
}
@@ -5193,7 +5193,7 @@ declare_proto_rig(send_cmd)
51935193
else
51945194
{
51955195
/* Assumes CR or LF is end of line char for all ASCII protocols. */
5196-
retval = read_string(&rs->rigport, buf, rxbytes, eom_buf,
5196+
retval = read_string(rp, buf, rxbytes, eom_buf,
51975197
strlen(eom_buf), 0, 1);
51985198

51995199
if (retval < 0)
@@ -5245,7 +5245,7 @@ declare_proto_rig(send_cmd)
52455245
strncat(hexbuf, hex, hexbufbytes - 1);
52465246
}
52475247

5248-
rig_flush_force(&rs->rigport, 1);
5248+
rig_flush_force(rp, 1);
52495249
set_transaction_inactive(rig);
52505250

52515251
rig_debug(RIG_DEBUG_TRACE, "%s: binary=%s, retval=%d\n", __func__, hexbuf,
@@ -5262,7 +5262,7 @@ declare_proto_rig(send_cmd)
52625262
}
52635263
while (retval > 0 && rxbytes == BUFSZ);
52645264

5265-
rig_flush_force(&rs->rigport, 1);
5265+
rig_flush_force(rp, 1);
52665266
set_transaction_inactive(rig);
52675267

52685268
// we use fwrite in case of any nulls in binary return
@@ -5786,7 +5786,7 @@ declare_proto_rig(cm108_get_bit)
57865786

57875787
if (n != 1) { return -RIG_EINVAL; }
57885788

5789-
int retval = rig_cm108_get_bit(&rig->state.pttport, gpio, &bit);
5789+
int retval = rig_cm108_get_bit(PTTPORT(rig), gpio, &bit);
57905790

57915791
if (retval != RIG_OK)
57925792
{
@@ -5826,7 +5826,7 @@ declare_proto_rig(cm108_set_bit)
58265826
if (n != 1) { return -RIG_EINVAL; }
58275827

58285828
rig_debug(RIG_DEBUG_TRACE, "%s: set gpio=%d, bit=%d\n", __func__, gpio, bit);
5829-
int retval = rig_cm108_set_bit(&rig->state.pttport, gpio, bit);
5829+
int retval = rig_cm108_set_bit(PTTPORT(rig), gpio, bit);
58305830

58315831
if (retval != RIG_OK)
58325832
{

tests/rigctltcp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ int main(int argc, char *argv[])
686686

687687
if (rig_file)
688688
{
689-
strncpy(my_rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
689+
strncpy(RIGPORT(my_rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
690690
}
691691

692692
my_rig->state.twiddle_timeout = twiddle_timeout;
@@ -701,7 +701,7 @@ int main(int argc, char *argv[])
701701
*/
702702
if (ptt_type != RIG_PTT_NONE)
703703
{
704-
my_rig->state.pttport.type.ptt = ptt_type;
704+
PTTPORT(my_rig)->type.ptt = ptt_type;
705705
my_rig->state.pttport_deprecated.type.ptt = ptt_type;
706706
// This causes segfault since backend rig_caps are const
707707
// rigctld will use the rig->state version of this for clients
@@ -716,7 +716,7 @@ int main(int argc, char *argv[])
716716

717717
if (ptt_file)
718718
{
719-
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
719+
strncpy(PTTPORT(my_rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
720720
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file,
721721
HAMLIB_FILPATHLEN - 1);
722722
}
@@ -731,7 +731,7 @@ int main(int argc, char *argv[])
731731
/* FIXME: bound checking and port type == serial */
732732
if (serial_rate != 0)
733733
{
734-
my_rig->state.rigport.parm.serial.rate = serial_rate;
734+
RIGPORT(my_rig)->parm.serial.rate = serial_rate;
735735
my_rig->state.rigport_deprecated.parm.serial.rate = serial_rate;
736736
}
737737

@@ -1309,7 +1309,7 @@ void *handle_socket(void *arg)
13091309
if (cmd[0] != 0)
13101310
{
13111311
memset(reply, 0, sizeof(reply));
1312-
rig_flush(&my_rig->state.rigport);
1312+
rig_flush(RIGPORT(my_rig));
13131313
retcode = rig_send_raw(my_rig, cmd, nbytes, reply, sizeof(reply),
13141314
term);
13151315

tests/rigsmtr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ int main(int argc, char *argv[])
265265

266266
if (rig_file)
267267
{
268-
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
268+
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
269269
}
270270

271271
/* FIXME: bound checking and port type == serial */
272272
if (serial_rate != 0)
273273
{
274-
rig->state.rigport.parm.serial.rate = serial_rate;
274+
RIGPORT(rig)->parm.serial.rate = serial_rate;
275275
}
276276

277277
if (civaddr)
@@ -329,13 +329,13 @@ int main(int argc, char *argv[])
329329

330330
if (rot_file)
331331
{
332-
strncpy(rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
332+
strncpy(ROTPORT(rot)->pathname, rot_file, HAMLIB_FILPATHLEN - 1);
333333
}
334334

335335
/* FIXME: bound checking and port type == serial */
336336
if (rot_serial_rate != 0)
337337
{
338-
rot->state.rotport.parm.serial.rate = rot_serial_rate;
338+
ROTPORT(rot)->parm.serial.rate = rot_serial_rate;
339339
}
340340

341341
retcode = rot_open(rot);

tests/rigswr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,23 +257,23 @@ int main(int argc, char *argv[])
257257

258258
if (ptt_type != RIG_PTT_NONE)
259259
{
260-
rig->state.pttport.type.ptt = ptt_type;
260+
PTTPORT(rig)->type.ptt = ptt_type;
261261
}
262262

263263
if (ptt_file)
264264
{
265-
strncpy(rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
265+
strncpy(PTTPORT(rig)->pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
266266
}
267267

268268
if (rig_file)
269269
{
270-
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
270+
strncpy(RIGPORT(rig)->pathname, rig_file, HAMLIB_FILPATHLEN - 1);
271271
}
272272

273273
/* FIXME: bound checking and port type == serial */
274274
if (serial_rate != 0)
275275
{
276-
rig->state.rigport.parm.serial.rate = serial_rate;
276+
RIGPORT(rig)->parm.serial.rate = serial_rate;
277277
}
278278

279279
if (civaddr)
@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
283283

284284

285285
if (!rig_has_get_level(rig, RIG_LEVEL_SWR)
286-
|| rig->state.pttport.type.ptt == RIG_PTT_NONE)
286+
|| PTTPORT(rig)->type.ptt == RIG_PTT_NONE)
287287
{
288288

289289
fprintf(stderr,

tests/testtrn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main(int argc, const char *argv[])
5252
exit(1); /* whoops! something went wrong (mem alloc?) */
5353
}
5454

55-
strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
55+
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), SERIAL_PORT);
5656

5757
if (rig_open(my_rig))
5858
{

0 commit comments

Comments
 (0)