summaryrefslogtreecommitdiff
path: root/spectro/dtp51.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-02 19:25:17 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-10-02 19:25:17 +0200
commitc2ca7be5a751879159f3cb591a64bb9568b79762 (patch)
tree04e38d4f4a2aad4d789bda0a65b7abb80a3439a2 /spectro/dtp51.c
parent45c152c326d87478fbf41714b4b8e2f7b57a282b (diff)
parent3db384424bd7398ffbb7a355cab8f15f3add009f (diff)
Updated version 1.9.1+repack from 'upstream/1.9.1+repack'
with Debian dir 98a996367aa69ae41accf9c6d369f600bc94de80
Diffstat (limited to 'spectro/dtp51.c')
-rw-r--r--spectro/dtp51.c84
1 files changed, 55 insertions, 29 deletions
diff --git a/spectro/dtp51.c b/spectro/dtp51.c
index ab1999d..0b2ecab 100644
--- a/spectro/dtp51.c
+++ b/spectro/dtp51.c
@@ -202,7 +202,7 @@ dtp51_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
} else if (fc == fc_Hardware) {
fcc = "0104CF\r";
} else {
- fc = fc_none;
+ fc = fc_None;
fcc = "0004CF\r";
}
@@ -225,37 +225,36 @@ dtp51_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
/* The tick to give up on */
etime = msec_time() + (long)(1000.0 * tout + 0.5);
- while (msec_time() < etime) {
-
- /* Until we time out, find the correct baud rate */
- for (i = ci; msec_time() < etime;) {
- if ((se = p->icom->set_ser_port(p->icom, fc_none, brt[i], parity_none,
- stop_1, length_8)) != ICOM_OK) {
- a1logd(p->log, 1, "dtp51_init_coms: set_ser_port failed ICOM err 0x%x\n",se);
- return dtp51_interp_code((inst *)p, icoms2dtp51_err(se));
- }
+ /* Until we time out, find the correct baud rate */
+ for (i = ci; msec_time() < etime;) {
+ a1logd(p->log, 4, "dtp51_init_coms: Trying %s baud, %d msec to go\n",
+ baud_rate_to_str(brt[i]), etime- msec_time());
+ if ((se = p->icom->set_ser_port(p->icom, fc_None, brt[i], parity_none,
+ stop_1, length_8)) != ICOM_OK) {
+ a1logd(p->log, 1, "dtp51_init_coms: set_ser_port failed ICOM err 0x%x\n",se);
+ return dtp51_interp_code((inst *)p, icoms2dtp51_err(se));
+ }
- if (((ev = dtp51_command(p, "\r", buf, MAX_MES_SIZE, 0.5)) & inst_mask)
- != inst_coms_fail)
- break; /* We've got coms */
+ if (((ev = dtp51_command(p, "\r", buf, MAX_MES_SIZE, 0.5)) & inst_mask)
+ != inst_coms_fail)
+ goto got_coms; /* We've got coms or user abort */
- /* Check for user abort */
- if (p->uicallback != NULL) {
- inst_code ev;
- if ((ev = p->uicallback(p->uic_cntx, inst_negcoms)) == inst_user_abort) {
- a1logd(p->log, 1, "dtp22_init_coms: user aborted\n");
- return inst_user_abort;
- }
+ /* Check for user abort */
+ if (p->uicallback != NULL) {
+ inst_code ev;
+ if ((ev = p->uicallback(p->uic_cntx, inst_negcoms)) == inst_user_abort) {
+ a1logd(p->log, 1, "dtp22_init_coms: user aborted\n");
+ return inst_user_abort;
}
- if (++i >= 5)
- i = 0;
}
- break; /* Got coms */
+ if (++i >= 5)
+ i = 0;
}
- if (msec_time() >= etime) { /* We haven't established comms */
- return inst_coms_fail;
- }
+ /* We haven't established comms */
+ return inst_coms_fail;
+
+ got_coms:;
/* Set the handshaking */
if ((ev = dtp51_command(p, fcc, buf, MAX_MES_SIZE, 1.5)) != inst_ok)
@@ -595,6 +594,7 @@ inst_code dtp51_calibrate(
inst *pp,
inst_cal_type *calt, /* Calibration type to do/remaining */
inst_cal_cond *calc, /* Current condition/desired condition */
+inst_calc_id_type *idtype, /* Condition identifier type */
char id[CALIDLEN] /* Condition identifier (ie. white reference ID) */
) {
dtp51 *p = (dtp51 *)pp;
@@ -606,6 +606,7 @@ char id[CALIDLEN] /* Condition identifier (ie. white reference ID) */
if (!p->inited)
return inst_no_init;
+ *idtype = inst_calc_id_none;
id[0] = '\000';
if ((ev = dtp51_get_n_a_cals((inst *)p, &needed, &available)) != inst_ok)
@@ -857,8 +858,7 @@ inst_code dtp51_set_mode(inst *pp, inst_mode m) {
* was assume that all of these can be done before initialisation.
*/
static inst_code
-dtp51_get_set_opt(inst *pp, inst_opt_type m, ...)
-{
+dtp51_get_set_opt(inst *pp, inst_opt_type m, ...) {
dtp51 *p = (dtp51 *)pp;
static char buf[MAX_MES_SIZE];
@@ -868,7 +868,31 @@ dtp51_get_set_opt(inst *pp, inst_opt_type m, ...)
return inst_ok;
}
- return inst_unsupported;
+ /* Get the current effective xcalstd */
+ if (m == inst_opt_get_xcalstd) {
+ xcalstd *standard;
+ va_list args;
+
+ va_start(args, m);
+ standard = va_arg(args, xcalstd *);
+ va_end(args);
+
+ *standard = p->native_calstd;
+
+ return inst_ok;
+ }
+
+ /* Use default implementation of other inst_opt_type's */
+ {
+ inst_code rv;
+ va_list args;
+
+ va_start(args, m);
+ rv = inst_get_set_opt_def(pp, m, args);
+ va_end(args);
+
+ return rv;
+ }
}
/* Constructor */
@@ -896,5 +920,7 @@ extern dtp51 *new_dtp51(icoms *icom, instType itype) {
p->icom = icom;
p->itype = itype;
+ p->native_calstd = xcalstd_xrdi; /* Not alterable */
+
return p;
}