summaryrefslogtreecommitdiff
path: root/spectro
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-11-06 05:38:49 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-11-06 05:38:49 +0100
commit9491825ddff7a294d1f49061bae7044e426aeb2e (patch)
tree06e651099f87140ec534ae47fb8ce1ac6ec7976d /spectro
parentfa756339d4204bff7f2820067f58214d32780d17 (diff)
Imported Upstream version 1.8.3
Diffstat (limited to 'spectro')
-rwxr-xr-x[-rw-r--r--]spectro/IntsLib_Readme.txt0
-rwxr-xr-x[-rw-r--r--]spectro/Jamfile0
-rwxr-xr-x[-rw-r--r--]spectro/License.txt0
-rwxr-xr-x[-rw-r--r--]spectro/License2.txt0
-rwxr-xr-x[-rw-r--r--]spectro/License3.txt0
-rwxr-xr-x[-rw-r--r--]spectro/LzmaDec.c0
-rwxr-xr-x[-rw-r--r--]spectro/LzmaDec.h0
-rwxr-xr-x[-rw-r--r--]spectro/LzmaTypes.h0
-rwxr-xr-x[-rw-r--r--]spectro/Makefile.OSX0
-rwxr-xr-x[-rw-r--r--]spectro/Makefile.SA0
-rwxr-xr-x[-rw-r--r--]spectro/Makefile.UNIX0
-rwxr-xr-x[-rw-r--r--]spectro/Makefile.WNT0
-rwxr-xr-x[-rw-r--r--]spectro/Readme.txt0
-rwxr-xr-x[-rw-r--r--]spectro/SOtele.sp0
-rwxr-xr-x[-rw-r--r--]spectro/afiles0
-rwxr-xr-x[-rw-r--r--]spectro/aglob.c1
-rwxr-xr-x[-rw-r--r--]spectro/aglob.h0
-rwxr-xr-x[-rw-r--r--]spectro/average.c0
-rwxr-xr-x[-rw-r--r--]spectro/base64.c0
-rwxr-xr-x[-rw-r--r--]spectro/base64.h0
-rwxr-xr-x[-rw-r--r--]spectro/ccwin.c0
-rwxr-xr-x[-rw-r--r--]spectro/ccwin.h0
-rwxr-xr-x[-rw-r--r--]spectro/ccxx.ti10
-rwxr-xr-x[-rw-r--r--]spectro/ccxxmake.c5
-rwxr-xr-x[-rw-r--r--]spectro/chartread.c19
-rwxr-xr-x[-rw-r--r--]spectro/colorhug.c1
-rwxr-xr-x[-rw-r--r--]spectro/colorhug.h0
-rwxr-xr-x[-rw-r--r--]spectro/conv.c9
-rwxr-xr-x[-rw-r--r--]spectro/conv.h0
-rwxr-xr-x[-rw-r--r--]spectro/cubecal.h0
-rwxr-xr-x[-rw-r--r--]spectro/dispcal.c0
-rwxr-xr-x[-rw-r--r--]spectro/dispread.c0
-rwxr-xr-x[-rw-r--r--]spectro/dispsup.c0
-rwxr-xr-x[-rw-r--r--]spectro/dispsup.h0
-rwxr-xr-x[-rw-r--r--]spectro/disptechs.c0
-rwxr-xr-x[-rw-r--r--]spectro/disptechs.h0
-rwxr-xr-x[-rw-r--r--]spectro/dispwin.c7
-rwxr-xr-x[-rw-r--r--]spectro/dispwin.h0
-rwxr-xr-x[-rw-r--r--]spectro/dtp20.c5
-rwxr-xr-x[-rw-r--r--]spectro/dtp20.h0
-rwxr-xr-x[-rw-r--r--]spectro/dtp22.c3
-rwxr-xr-x[-rw-r--r--]spectro/dtp22.h0
-rwxr-xr-x[-rw-r--r--]spectro/dtp41.c5
-rwxr-xr-x[-rw-r--r--]spectro/dtp41.h0
-rwxr-xr-x[-rw-r--r--]spectro/dtp51.c3
-rwxr-xr-x[-rw-r--r--]spectro/dtp51.h0
-rwxr-xr-x[-rw-r--r--]spectro/dtp92.c3
-rwxr-xr-x[-rw-r--r--]spectro/dtp92.h0
-rwxr-xr-x[-rw-r--r--]spectro/ex1.c11
-rwxr-xr-x[-rw-r--r--]spectro/ex1.h0
-rwxr-xr-x[-rw-r--r--]spectro/fakeread.c0
-rwxr-xr-x[-rw-r--r--]spectro/hcfr.c1
-rwxr-xr-x[-rw-r--r--]spectro/hcfr.h0
-rwxr-xr-x[-rw-r--r--]spectro/hidio.c0
-rwxr-xr-x[-rw-r--r--]spectro/hidio.h0
-rwxr-xr-x[-rw-r--r--]spectro/huey.c5
-rwxr-xr-x[-rw-r--r--]spectro/huey.h0
-rwxr-xr-x[-rw-r--r--]spectro/i1d3.c58
-rwxr-xr-x[-rw-r--r--]spectro/i1d3.h1
-rwxr-xr-x[-rw-r--r--]spectro/i1disp.c3
-rwxr-xr-x[-rw-r--r--]spectro/i1disp.h0
-rwxr-xr-x[-rw-r--r--]spectro/i1pro.c3
-rwxr-xr-x[-rw-r--r--]spectro/i1pro.h0
-rwxr-xr-x[-rw-r--r--]spectro/i1pro_imp.c123
-rwxr-xr-x[-rw-r--r--]spectro/i1pro_imp.h8
-rwxr-xr-x[-rw-r--r--]spectro/icoms.c0
-rwxr-xr-x[-rw-r--r--]spectro/icoms.h0
-rwxr-xr-x[-rw-r--r--]spectro/icoms_nt.c0
-rwxr-xr-x[-rw-r--r--]spectro/icoms_ux.c0
-rwxr-xr-x[-rw-r--r--]spectro/ifiles0
-rwxr-xr-x[-rw-r--r--]spectro/illumread.c0
-rwxr-xr-x[-rw-r--r--]spectro/inflate.c0
-rwxr-xr-x[-rw-r--r--]spectro/inst.c18
-rwxr-xr-x[-rw-r--r--]spectro/inst.h4
-rwxr-xr-x[-rw-r--r--]spectro/instappsup.c2
-rwxr-xr-x[-rw-r--r--]spectro/instappsup.h0
-rwxr-xr-x[-rw-r--r--]spectro/instlib.ksh0
-rwxr-xr-x[-rw-r--r--]spectro/instlib.txt0
-rwxr-xr-x[-rw-r--r--]spectro/insttypeinst.h0
-rwxr-xr-x[-rw-r--r--]spectro/insttypes.c0
-rwxr-xr-x[-rw-r--r--]spectro/insttypes.h0
-rwxr-xr-x[-rw-r--r--]spectro/iusb.h0
-rwxr-xr-x[-rw-r--r--]spectro/kleink10.c114
-rwxr-xr-x[-rw-r--r--]spectro/kleink10.h0
-rwxr-xr-x[-rw-r--r--]spectro/linear.cal2
-rwxr-xr-x[-rw-r--r--]spectro/linear.sp0
-rwxr-xr-x[-rw-r--r--]spectro/madvrwin.c0
-rwxr-xr-x[-rw-r--r--]spectro/madvrwin.h0
-rwxr-xr-x[-rw-r--r--]spectro/mongoose.c0
-rwxr-xr-x[-rw-r--r--]spectro/mongoose.h0
-rwxr-xr-x[-rw-r--r--]spectro/munki.c3
-rwxr-xr-x[-rw-r--r--]spectro/munki.h0
-rwxr-xr-x[-rw-r--r--]spectro/munki_imp.c0
-rwxr-xr-x[-rw-r--r--]spectro/munki_imp.h0
-rwxr-xr-x[-rw-r--r--]spectro/oemarch.c0
-rwxr-xr-x[-rw-r--r--]spectro/oemarch.h0
-rwxr-xr-x[-rw-r--r--]spectro/oeminst.c0
-rwxr-xr-x[-rw-r--r--]spectro/pollem.c0
-rwxr-xr-x[-rw-r--r--]spectro/pollem.h0
-rwxr-xr-x[-rw-r--r--]spectro/rspec.c4
-rwxr-xr-x[-rw-r--r--]spectro/rspec.h6
-rwxr-xr-x[-rw-r--r--]spectro/smcube.c13
-rwxr-xr-x[-rw-r--r--]spectro/smcube.h0
-rwxr-xr-x[-rw-r--r--]spectro/spec2cie.c2
-rwxr-xr-x[-rw-r--r--]spectro/specbos.c1
-rwxr-xr-x[-rw-r--r--]spectro/specbos.h0
-rwxr-xr-x[-rw-r--r--]spectro/spotread.c0
-rwxr-xr-x[-rw-r--r--]spectro/spyd2.c30
-rwxr-xr-x[-rw-r--r--]spectro/spyd2.h1
-rwxr-xr-x[-rw-r--r--]spectro/ss.c3
-rwxr-xr-x[-rw-r--r--]spectro/ss.h0
-rwxr-xr-x[-rw-r--r--]spectro/ss_imp.c0
-rwxr-xr-x[-rw-r--r--]spectro/ss_imp.h0
-rwxr-xr-x[-rw-r--r--]spectro/strange.cal2
-rwxr-xr-x[-rw-r--r--]spectro/synthcal.c0
-rwxr-xr-x[-rw-r--r--]spectro/synthread.c0
-rwxr-xr-x[-rw-r--r--]spectro/usbio.c4
-rwxr-xr-x[-rw-r--r--]spectro/usbio.h0
-rwxr-xr-x[-rw-r--r--]spectro/usbio_bsd.c0
-rwxr-xr-x[-rw-r--r--]spectro/usbio_lx.c0
-rwxr-xr-x[-rw-r--r--]spectro/usbio_nt.c2
-rwxr-xr-x[-rw-r--r--]spectro/usbio_ox.c0
-rwxr-xr-x[-rw-r--r--]spectro/vinflate.c0
-rwxr-xr-x[-rw-r--r--]spectro/webwin.c0
-rwxr-xr-x[-rw-r--r--]spectro/webwin.h0
-rwxr-xr-x[-rw-r--r--]spectro/xdg_bds.c0
-rwxr-xr-x[-rw-r--r--]spectro/xdg_bds.h0
127 files changed, 376 insertions, 109 deletions
diff --git a/spectro/IntsLib_Readme.txt b/spectro/IntsLib_Readme.txt
index 7d9fb0c..7d9fb0c 100644..100755
--- a/spectro/IntsLib_Readme.txt
+++ b/spectro/IntsLib_Readme.txt
diff --git a/spectro/Jamfile b/spectro/Jamfile
index 9eb292f..9eb292f 100644..100755
--- a/spectro/Jamfile
+++ b/spectro/Jamfile
diff --git a/spectro/License.txt b/spectro/License.txt
index a871fcf..a871fcf 100644..100755
--- a/spectro/License.txt
+++ b/spectro/License.txt
diff --git a/spectro/License2.txt b/spectro/License2.txt
index 05ca889..05ca889 100644..100755
--- a/spectro/License2.txt
+++ b/spectro/License2.txt
diff --git a/spectro/License3.txt b/spectro/License3.txt
index 94a9ed0..94a9ed0 100644..100755
--- a/spectro/License3.txt
+++ b/spectro/License3.txt
diff --git a/spectro/LzmaDec.c b/spectro/LzmaDec.c
index 8c1a148..8c1a148 100644..100755
--- a/spectro/LzmaDec.c
+++ b/spectro/LzmaDec.c
diff --git a/spectro/LzmaDec.h b/spectro/LzmaDec.h
index 6045fae..6045fae 100644..100755
--- a/spectro/LzmaDec.h
+++ b/spectro/LzmaDec.h
diff --git a/spectro/LzmaTypes.h b/spectro/LzmaTypes.h
index 7732c24..7732c24 100644..100755
--- a/spectro/LzmaTypes.h
+++ b/spectro/LzmaTypes.h
diff --git a/spectro/Makefile.OSX b/spectro/Makefile.OSX
index 485cbf4..485cbf4 100644..100755
--- a/spectro/Makefile.OSX
+++ b/spectro/Makefile.OSX
diff --git a/spectro/Makefile.SA b/spectro/Makefile.SA
index 2d57742..2d57742 100644..100755
--- a/spectro/Makefile.SA
+++ b/spectro/Makefile.SA
diff --git a/spectro/Makefile.UNIX b/spectro/Makefile.UNIX
index adafa67..adafa67 100644..100755
--- a/spectro/Makefile.UNIX
+++ b/spectro/Makefile.UNIX
diff --git a/spectro/Makefile.WNT b/spectro/Makefile.WNT
index 83eef28..83eef28 100644..100755
--- a/spectro/Makefile.WNT
+++ b/spectro/Makefile.WNT
diff --git a/spectro/Readme.txt b/spectro/Readme.txt
index b9fe0aa..b9fe0aa 100644..100755
--- a/spectro/Readme.txt
+++ b/spectro/Readme.txt
diff --git a/spectro/SOtele.sp b/spectro/SOtele.sp
index f63d90e..f63d90e 100644..100755
--- a/spectro/SOtele.sp
+++ b/spectro/SOtele.sp
diff --git a/spectro/afiles b/spectro/afiles
index 984bac5..984bac5 100644..100755
--- a/spectro/afiles
+++ b/spectro/afiles
diff --git a/spectro/aglob.c b/spectro/aglob.c
index 2ba37d5..dbf9157 100644..100755
--- a/spectro/aglob.c
+++ b/spectro/aglob.c
@@ -42,6 +42,7 @@
# include <pthread.h>
#endif
+#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
diff --git a/spectro/aglob.h b/spectro/aglob.h
index dbb5025..dbb5025 100644..100755
--- a/spectro/aglob.h
+++ b/spectro/aglob.h
diff --git a/spectro/average.c b/spectro/average.c
index 5a8fb3f..5a8fb3f 100644..100755
--- a/spectro/average.c
+++ b/spectro/average.c
diff --git a/spectro/base64.c b/spectro/base64.c
index 388d121..388d121 100644..100755
--- a/spectro/base64.c
+++ b/spectro/base64.c
diff --git a/spectro/base64.h b/spectro/base64.h
index 726f20a..726f20a 100644..100755
--- a/spectro/base64.h
+++ b/spectro/base64.h
diff --git a/spectro/ccwin.c b/spectro/ccwin.c
index 1e9a18d..1e9a18d 100644..100755
--- a/spectro/ccwin.c
+++ b/spectro/ccwin.c
diff --git a/spectro/ccwin.h b/spectro/ccwin.h
index 9fb902d..9fb902d 100644..100755
--- a/spectro/ccwin.h
+++ b/spectro/ccwin.h
diff --git a/spectro/ccxx.ti1 b/spectro/ccxx.ti1
index 47f2b13..47f2b13 100644..100755
--- a/spectro/ccxx.ti1
+++ b/spectro/ccxx.ti1
diff --git a/spectro/ccxxmake.c b/spectro/ccxxmake.c
index 4202c67..418affc 100644..100755
--- a/spectro/ccxxmake.c
+++ b/spectro/ccxxmake.c
@@ -27,6 +27,9 @@
/*
TTBD:
+ Would be nice to have a way of not changing the target
+ instruments absolute calibration.
+
Would be nice to have a veryify option that produces
a fit report of a matrix vs. the input files.
@@ -34,7 +37,7 @@
(See post from umberto.guidali@tiscali.it)
Would be nice to be able to use an i1D3 to correct other instruments,
- or an i1D3 created .ti3 as the reference.
+ or an i1D3 created .ti3 as the reference. (can do this with .ti3 files).
Would be nice to have an option of providing two ICC profiles,
instead of using .ti3 files (?? How well would it work though ?)
diff --git a/spectro/chartread.c b/spectro/chartread.c
index 0fc7646..9cf6c22 100644..100755
--- a/spectro/chartread.c
+++ b/spectro/chartread.c
@@ -198,6 +198,7 @@ alphix *paix, /* Pass (row) index generators */
alphix *saix, /* Step (patch) index generators */
int ixord, /* Index order, 0 = pass then step */
int rstart, /* Random start/chart id */
+int rand, /* Random order used - can do auto strip ID & Bi-Dir */
int hex, /* Hexagon test patches */
icompath *ipath, /* Instrument path to open */
flow_control fc, /* flow control */
@@ -1389,7 +1390,7 @@ a1log *log /* verb, debug & error log */
int xbdir; /* Expected pass overall pass direction */
double xwerror = 0.0; /* Expected pass worst error in best strip */
- if (disbidi == 0 && (cap2 & inst2_bidi_scan))
+ if (rand && disbidi == 0 && (cap2 & inst2_bidi_scan))
dirrg = 2; /* Enable bi-directional strip recognition */
/* DTP51 has a nasty habit of misaligning test squares by +/- 1 */
@@ -1463,7 +1464,7 @@ a1log *log /* verb, debug & error log */
}
}
}
- if (emit_warnings != 0 && boroi != oroi) { /* Looks like the wrong strip */
+ if (emit_warnings != 0 && rand && boroi != oroi) { /* Looks like the wrong strip */
char *mm = NULL;
mm = paix->aix(paix, boroi);
#ifdef DEBUG
@@ -2110,6 +2111,7 @@ int main(int argc, char *argv[]) {
alphix *paix, *saix; /* Pass and Step index generators */
int ixord = 0; /* Index order, 0 = pass then step */
int rstart = 0; /* Random start/chart id */
+ int rand = 0; /* Random patch order, - can use auto strip ID and Bi-Di */
int hex = 0; /* Hexagon pattern layout */
time_t clk = time(0);
struct tm *tsp = localtime(&clk);
@@ -2472,10 +2474,13 @@ int main(int argc, char *argv[]) {
ixord = 1;
}
- if ((ti = icg->find_kword(icg, 0, "RANDOM_START")) >= 0)
+ if ((ti = icg->find_kword(icg, 0, "RANDOM_START")) >= 0) {
rstart = atoi(icg->t[0].kdata[ti]);
- else if ((ti = icg->find_kword(icg, 0, "CHART_ID")) >= 0)
+ rand = 1;
+ } else if ((ti = icg->find_kword(icg, 0, "CHART_ID")) >= 0) {
rstart = atoi(icg->t[0].kdata[ti]);
+ rand = 0;
+ }
if ((ti = icg->find_kword(icg, 0, "HEXAGON_PATCHES")) >= 0)
hex = 1;
@@ -2503,6 +2508,10 @@ int main(int argc, char *argv[]) {
tlen = atof(icg->t[0].kdata[ti]);
}
+ if (itype != instDTP20 && !rand && disbidi == 0) {
+ warning("Can't do bi-directional strip recognition without randomize patch locations");
+ }
+
if (verb) {
printf("Steps in each Pass = %d\n",stipa);
printf("Passes in each Strip = ");
@@ -2838,7 +2847,7 @@ int main(int argc, char *argv[]) {
/* Read all of the strips in */
if (read_strips(itype, scols, &atype, npat, totpa, stipa, pis, paix,
- saix, ixord, rstart, hex, ipath, fc, plen, glen, tlen,
+ saix, ixord, rstart, rand, hex, ipath, fc, plen, glen, tlen,
trans, emis, displ, dtype, fe, nocal, disbidi, highres, ccxxname, obType,
scan_tol, pbypatch, xtern, spectral, uvmode, accurate_expd,
emit_warnings, g_log) == 0) {
diff --git a/spectro/colorhug.c b/spectro/colorhug.c
index 1b2a56d..7397314 100644..100755
--- a/spectro/colorhug.c
+++ b/spectro/colorhug.c
@@ -825,6 +825,7 @@ colorhug_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
inst_del_disptype_list(p->dtlist, p->ndtlist);
+ p->vdel(pp);
free(p);
}
}
diff --git a/spectro/colorhug.h b/spectro/colorhug.h
index 90fff6f..90fff6f 100644..100755
--- a/spectro/colorhug.h
+++ b/spectro/colorhug.h
diff --git a/spectro/conv.c b/spectro/conv.c
index 1a8c78b..94023db 100644..100755
--- a/spectro/conv.c
+++ b/spectro/conv.c
@@ -68,6 +68,7 @@
//#include <stdbool.h>
#include <sys/sysctl.h>
#include <sys/param.h>
+#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/serial/IOSerialKeys.h>
@@ -263,12 +264,14 @@ static int beep_msec;
/* Delayed beep handler */
static int delayed_beep(void *pp) {
msec_sleep(beep_delay);
+ a1logd(g_log,8, "msec_beep activate\n");
Beep(beep_freq, beep_msec);
return 0;
}
/* Activate the system beeper */
void msec_beep(int delay, int freq, int msec) {
+ a1logd(g_log,8, "msec_beep %d msec\n",msec);
if (delay > 0) {
if (beep_thread != NULL)
beep_thread->del(beep_thread);
@@ -278,6 +281,7 @@ void msec_beep(int delay, int freq, int msec) {
if ((beep_thread = new_athread(delayed_beep, NULL)) == NULL)
a1logw(g_log, "msec_beep: Delayed beep failed to create thread\n");
} else {
+ a1logd(g_log,8, "msec_beep activate\n");
Beep(freq, msec);
}
}
@@ -549,6 +553,8 @@ void empty_con_chars(void) {
}
/* Sleep for the given number of msec */
+/* (Note that OS X 10.9+ App Nap can wreck this, unless */
+/* it is turned off.) */
void msec_sleep(unsigned int msec) {
#ifdef NEVER
if (msec > 1000) {
@@ -779,6 +785,7 @@ static int beep_msec;
/* Delayed beep handler */
static int delayed_beep(void *pp) {
msec_sleep(beep_delay);
+ a1logd(g_log,8, "msec_beep activate\n");
#ifdef __APPLE__
# if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
AudioServicesPlayAlertSound(kUserPreferredAlert);
@@ -794,6 +801,7 @@ static int delayed_beep(void *pp) {
/* Activate the system beeper */
void msec_beep(int delay, int freq, int msec) {
+ a1logd(g_log,8, "msec_beep %d msec\n",msec);
if (delay > 0) {
if (beep_thread != NULL)
beep_thread->del(beep_thread);
@@ -803,6 +811,7 @@ void msec_beep(int delay, int freq, int msec) {
if ((beep_thread = new_athread(delayed_beep, NULL)) == NULL)
a1logw(g_log, "msec_beep: Delayed beep failed to create thread\n");
} else {
+ a1logd(g_log,8, "msec_beep activate\n");
#ifdef __APPLE__
# if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
AudioServicesPlayAlertSound(kUserPreferredAlert);
diff --git a/spectro/conv.h b/spectro/conv.h
index 4e14dd9..4e14dd9 100644..100755
--- a/spectro/conv.h
+++ b/spectro/conv.h
diff --git a/spectro/cubecal.h b/spectro/cubecal.h
index 60f7380..60f7380 100644..100755
--- a/spectro/cubecal.h
+++ b/spectro/cubecal.h
diff --git a/spectro/dispcal.c b/spectro/dispcal.c
index 97337cd..97337cd 100644..100755
--- a/spectro/dispcal.c
+++ b/spectro/dispcal.c
diff --git a/spectro/dispread.c b/spectro/dispread.c
index 8a78fcc..8a78fcc 100644..100755
--- a/spectro/dispread.c
+++ b/spectro/dispread.c
diff --git a/spectro/dispsup.c b/spectro/dispsup.c
index 57a598e..57a598e 100644..100755
--- a/spectro/dispsup.c
+++ b/spectro/dispsup.c
diff --git a/spectro/dispsup.h b/spectro/dispsup.h
index bca3070..bca3070 100644..100755
--- a/spectro/dispsup.h
+++ b/spectro/dispsup.h
diff --git a/spectro/disptechs.c b/spectro/disptechs.c
index 70e150f..70e150f 100644..100755
--- a/spectro/disptechs.c
+++ b/spectro/disptechs.c
diff --git a/spectro/disptechs.h b/spectro/disptechs.h
index 9860eac..9860eac 100644..100755
--- a/spectro/disptechs.h
+++ b/spectro/disptechs.h
diff --git a/spectro/dispwin.c b/spectro/dispwin.c
index 69536f3..fffbaee 100644..100755
--- a/spectro/dispwin.c
+++ b/spectro/dispwin.c
@@ -3624,6 +3624,9 @@ static void create_my_win(NSRect rect, osx_cntx_t *cx) {
[cx->view setCntx:(void *)cx];
[cx->window setContentView: cx->view];
+ /* Moves the window to the front of the screen list within its level, */
+ /* and show the window (i.e. make it "key") */
+ /* Trigger crash on OS X 10.11 El Capitan ? */
[cx->window makeKeyAndOrderFront: nil];
/* Use a null color transform to ensure device values */
@@ -6451,7 +6454,7 @@ main(int argc, char *argv[]) {
/* Try darkening it */
for (j = 0; j < 3; j++) {
for (i = 0; i < dw->r->nent; i++) {
- dw->r->v[j][i] = pow(dw->or->v[j][i], 2.0);
+ dw->r->v[j][i] = pow(dw->or->v[j][i], 1.6);
}
}
printf("Darkening screen\n");
@@ -6464,7 +6467,7 @@ main(int argc, char *argv[]) {
/* Try lightening it */
for (j = 0; j < 3; j++) {
for (i = 0; i < dw->r->nent; i++) {
- dw->r->v[j][i] = pow(dw->or->v[j][i], 0.5);
+ dw->r->v[j][i] = pow(dw->or->v[j][i], 0.625);
}
}
printf("Lightening screen\n");
diff --git a/spectro/dispwin.h b/spectro/dispwin.h
index b5e14ce..b5e14ce 100644..100755
--- a/spectro/dispwin.h
+++ b/spectro/dispwin.h
diff --git a/spectro/dtp20.c b/spectro/dtp20.c
index a504803..6af2484 100644..100755
--- a/spectro/dtp20.c
+++ b/spectro/dtp20.c
@@ -217,7 +217,7 @@ double top) { /* Timout in seconds */
}
/* Establish communications with a DTP20 */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return DTP20_COMS_FAIL on failure to establish communications */
static inst_code
dtp20_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
dtp20 *p = (dtp20 *)pp;
@@ -1402,7 +1402,8 @@ dtp20_del(inst *pp) {
dtp20 *p = (dtp20 *)pp;
if (p->icom != NULL)
p->icom->del(p->icom);
- free (p);
+ p->vdel(pp);
+ free(p);
}
/* Set the instrument capabilities */
diff --git a/spectro/dtp20.h b/spectro/dtp20.h
index c575c67..c575c67 100644..100755
--- a/spectro/dtp20.h
+++ b/spectro/dtp20.h
diff --git a/spectro/dtp22.c b/spectro/dtp22.c
index d332ffc..2cb3634 100644..100755
--- a/spectro/dtp22.c
+++ b/spectro/dtp22.c
@@ -164,7 +164,7 @@ dtp22_command(dtp22 *p, char *in, char *out, int bsize, double to) {
/* Establish communications with a DTP22 */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return DTP22_COMS_FAIL on failure to establish communications */
static inst_code
dtp22_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
dtp22 *p = (dtp22 *) pp;
@@ -930,6 +930,7 @@ dtp22_del(inst *pp) {
dtp22 *p = (dtp22 *)pp;
if (p->icom != NULL)
p->icom->del(p->icom);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/dtp22.h b/spectro/dtp22.h
index 95dce16..95dce16 100644..100755
--- a/spectro/dtp22.h
+++ b/spectro/dtp22.h
diff --git a/spectro/dtp41.c b/spectro/dtp41.c
index 5c3361c..44ac6c6 100644..100755
--- a/spectro/dtp41.c
+++ b/spectro/dtp41.c
@@ -145,7 +145,7 @@ dtp41_command(dtp41 *p, char *in, char *out, int bsize, double to) {
/* Establish communications with a DTP41 */
/* Use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return DTP41_COMS_FAIL on failure to establish communications */
static inst_code
dtp41_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
dtp41 *p = (dtp41 *)pp;
@@ -1085,7 +1085,8 @@ dtp41_del(inst *pp) {
dtp41 *p = (dtp41 *)pp;
if (p->icom != NULL)
p->icom->del(p->icom);
- free (p);
+ p->vdel(pp);
+ free(p);
}
/* Interogate the device to discover its capabilities */
diff --git a/spectro/dtp41.h b/spectro/dtp41.h
index 529f94c..529f94c 100644..100755
--- a/spectro/dtp41.h
+++ b/spectro/dtp41.h
diff --git a/spectro/dtp51.c b/spectro/dtp51.c
index cfd1265..ab1999d 100644..100755
--- a/spectro/dtp51.c
+++ b/spectro/dtp51.c
@@ -180,7 +180,7 @@ double to) { /* Timout in seconts */
/* Establish communications with a DTP51 */
/* Use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return DTP51_COMS_FAIL on failure to establish communications */
static inst_code
dtp51_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
dtp51 *p = (dtp51 *)pp;
@@ -787,6 +787,7 @@ dtp51_del(inst *pp) {
dtp51 *p = (dtp51 *)pp;
if (p->icom != NULL)
p->icom->del(p->icom);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/dtp51.h b/spectro/dtp51.h
index 329c5d6..329c5d6 100644..100755
--- a/spectro/dtp51.h
+++ b/spectro/dtp51.h
diff --git a/spectro/dtp92.c b/spectro/dtp92.c
index 1ed9bc1..3b6dacd 100644..100755
--- a/spectro/dtp92.c
+++ b/spectro/dtp92.c
@@ -169,7 +169,7 @@ dtp92_command(dtp92 *p, char *in, char *out, int bsize, double to) {
/* Establish communications with a DTP92 */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return DTP92_COMS_FAIL on failure to establish communications */
static inst_code
dtp92_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
dtp92 *p = (dtp92 *) pp;
@@ -1023,6 +1023,7 @@ dtp92_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
inst_del_disptype_list(p->dtlist, p->ndtlist);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/dtp92.h b/spectro/dtp92.h
index 317fb7a..317fb7a 100644..100755
--- a/spectro/dtp92.h
+++ b/spectro/dtp92.h
diff --git a/spectro/ex1.c b/spectro/ex1.c
index 93d0a31..b336cbc 100644..100755
--- a/spectro/ex1.c
+++ b/spectro/ex1.c
@@ -147,6 +147,10 @@ static int ex1_set_boxcar(ex1 *p, int nobox);
static int ex1_measure(ex1 *p, double *raw);
+static int ex1_save_calibration(ex1 *p);
+static int ex1_restore_calibration(ex1 *p);
+static int ex1_touch_calibration(ex1 *p);
+
/* ----------------------------------------------------------------- */
/* Establish communications with a ex1 */
@@ -1038,6 +1042,7 @@ ex1_del(inst *pp) {
if (p->conv != NULL)
p->conv->del(p->conv);
+ p->vdel(pp);
free(p);
}
}
@@ -1234,7 +1239,7 @@ extern ex1 *new_ex1(icoms *icom, instType itype) {
/* =============================================================================== */
/* Calibration info save/restore */
-int ex1_save_calibration(ex1 *p) {
+static int ex1_save_calibration(ex1 *p) {
int ev = EX1_OK;
int i;
char fname[100]; /* Name */
@@ -1280,7 +1285,7 @@ int ex1_save_calibration(ex1 *p) {
}
/* Restore the all modes calibration from the local system */
-int ex1_restore_calibration(ex1 *p) {
+static int ex1_restore_calibration(ex1 *p) {
int ev = EX1_OK;
int i, j;
char fname[100]; /* Name */
@@ -1353,7 +1358,7 @@ int ex1_restore_calibration(ex1 *p) {
return ev;
}
-int ex1_touch_calibration(ex1 *p) {
+static int ex1_touch_calibration(ex1 *p) {
int ev = EX1_OK;
char fname[100]; /* Name */
int rv;
diff --git a/spectro/ex1.h b/spectro/ex1.h
index d69b7ca..d69b7ca 100644..100755
--- a/spectro/ex1.h
+++ b/spectro/ex1.h
diff --git a/spectro/fakeread.c b/spectro/fakeread.c
index 3cad93a..3cad93a 100644..100755
--- a/spectro/fakeread.c
+++ b/spectro/fakeread.c
diff --git a/spectro/hcfr.c b/spectro/hcfr.c
index d0a8261..a6c457e 100644..100755
--- a/spectro/hcfr.c
+++ b/spectro/hcfr.c
@@ -637,6 +637,7 @@ hcfr_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
inst_del_disptype_list(p->dtlist, p->ndtlist);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/hcfr.h b/spectro/hcfr.h
index 8910cec..8910cec 100644..100755
--- a/spectro/hcfr.h
+++ b/spectro/hcfr.h
diff --git a/spectro/hidio.c b/spectro/hidio.c
index c930755..c930755 100644..100755
--- a/spectro/hidio.c
+++ b/spectro/hidio.c
diff --git a/spectro/hidio.h b/spectro/hidio.h
index 90a741b..90a741b 100644..100755
--- a/spectro/hidio.h
+++ b/spectro/hidio.h
diff --git a/spectro/huey.c b/spectro/huey.c
index 79f8089..b09ed2c 100644..100755
--- a/spectro/huey.c
+++ b/spectro/huey.c
@@ -159,7 +159,7 @@ static char *inst_desc(int cc) {
/* The Huey is set up as an HID device, which can ease the need */
/* for providing a kernel driver on MSWindows systems, */
/* but it doesn't seem to actually be used as an HID device. */
-/* We allow for communicating via libusb, or an HID driver. */
+/* We allow for communicating via usbio, or an HID driver. */
static inst_code
huey_command(
huey *p, /* huey object */
@@ -1026,7 +1026,7 @@ static inst_code set_default_disp_type(huey *p);
/* Establish communications with a HUEY */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return HUEY_COMS_FAIL on failure to establish communications */
static inst_code
huey_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
huey *p = (huey *) pp;
@@ -1400,6 +1400,7 @@ huey_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
inst_del_disptype_list(p->dtlist, p->ndtlist);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/huey.h b/spectro/huey.h
index aec96a0..aec96a0 100644..100755
--- a/spectro/huey.h
+++ b/spectro/huey.h
diff --git a/spectro/i1d3.c b/spectro/i1d3.c
index 689f328..df7d3f0 100644..100755
--- a/spectro/i1d3.c
+++ b/spectro/i1d3.c
@@ -34,6 +34,10 @@
and agreed to support.
*/
+/* TTBD:
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -70,6 +74,8 @@
#define I1D3_MEAS_TIMEOUT 40.0 /* Longest reading timeout in seconds */
/* Typically 20.0 is the maximum needed. */
+#define I1D3_SAT_FREQ 100000.0 /* L2F sensor frequency limit */
+
static inst_code i1d3_interp_code(inst *pp, int ec);
static inst_code i1d3_check_unlock(i1d3 *p);
@@ -105,6 +111,12 @@ static int icoms2i1d3_err(int se, int torc) {
/* and byte 1 is the sub code for command 0x00 . The response is byte 0 */
/* error code, byte 1 echoing the major command number. */
/* Major code 00 works when locked ? */
+/* Response codes:
+
+ 00 OK
+ 83 After pulse count measure in low light. Means ???
+
+ */
typedef enum {
i1d3_getinfo = 0x0000, /* Product name + Firmware version + Firmware Date string */
i1d3_status = 0x0001, /* status number ?? */
@@ -174,7 +186,7 @@ static char *inst_desc(i1Disp3CC cc) {
/* The i1d3 is set up as an HID device, which can ease the need */
/* for providing a kernel driver on MSWindows systems, */
/* but it doesn't seem to actually be used as an HID device. */
-/* We allow for communicating via libusb, or an HID driver. */
+/* We allow for communicating via usbio, or an HID driver. */
static inst_code
i1d3_command(
i1d3 *p, /* i1d3 object */
@@ -265,6 +277,21 @@ i1d3_command(
rv = i1d3_interp_code((inst *)p, I1D3_BAD_RD_LENGTH);
}
+ /* Hmm. Not sure about this bug workaround. Is this a rev B thing ? */
+ /* May get status 0x83 on i1d3_measure2 when there are no transitions ? */
+ /* If so, ignore the error. */
+ if (rv == inst_ok && cc == i1d3_measure2 && recv[1] == 0x02 && recv[0] == 0x83) {
+ int i;
+ for (i = 2; i < 14; i++) {
+ if (recv[i] != 0)
+ break;
+ }
+ if (i >= 14) { /* returned all zero's */
+ if (!nd) a1logd(p->log, 1, "i1d3_command: ignoring status byte = 0x%x\n",recv[0]);
+ recv[0] = 0x00; /* Fudge OK status */
+ }
+ }
+
/* The first byte returned seems to be a command result error code. */
if (rv == inst_ok && recv[0] != 0x00) {
if (!nd) a1logd(p->log, 1, "i1d3_command: status byte != 00 = 0x%x\n",recv[0]);
@@ -756,7 +783,7 @@ static inst_code
i1d3_freq_measure(
i1d3 *p, /* Object */
double *inttime, /* Integration time in seconds. (Return clock rounded) */
- double rgb[3] /* Return the RGB values */
+ double rgb[3] /* Return the RGB count values */
) {
int intclks;
unsigned char todev[64];
@@ -1568,6 +1595,11 @@ i1d3_take_emis_measurement(
}
a1logd(p->log,3,"Got %f %f %f raw, %f %f %f Hz\n",rmeas[0],rmeas[1],rmeas[2],rgb[0],rgb[1],rgb[2]);
+
+ for (i = 0; i < 3; i++) {
+ if (rgb[i] > I1D3_SAT_FREQ)
+ return i1d3_interp_code((inst *)p, I1D3_TOOBRIGHT);
+ }
}
/* If some period measurement will be done */
@@ -1863,6 +1895,11 @@ i1d3_take_emis_measurement(
a1logd(p->log,3,"Got %f %f %f raw, %f %f %f Hz after re-measure\n",rmeas[0],rmeas[1],rmeas[2],rgb[0],rgb[1],rgb[2]);
+ for (i = 0; i < 3; i++) {
+ if (rgb[i] > I1D3_SAT_FREQ)
+ return i1d3_interp_code((inst *)p, I1D3_TOOBRIGHT);
+ }
+
} else {
/* Use period measurement of the target number of edges */
/* (Note that if the patch isn't constant and drops compared to */
@@ -1907,6 +1944,11 @@ i1d3_take_emis_measurement(
}
a1logd(p->log,3,"Cooked RGB = %f %f %f\n",rgb[0],rgb[1],rgb[2]);
+
+ for (i = 0; i < 3; i++) {
+ if (rgb[i] > I1D3_SAT_FREQ)
+ return i1d3_interp_code((inst *)p, I1D3_TOOBRIGHT);
+ }
return inst_ok;
}
@@ -1983,7 +2025,7 @@ static inst_code i1d3_decode_intEE(
p->serial_no[20] = '\000';
strncpy(p->vers_no, (char *)buf + 0x2C, 10);
- p->serial_no[10] = '\000';
+ p->vers_no[10] = '\000';
/* Read the black level offset */
for (i = 0; i < 3; i++) {
@@ -2395,7 +2437,7 @@ i1d3_set_cal(i1d3 *p) {
/* ------------------------------------------------------------------------ */
/* Establish communications with a I1D3 */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return I1D3_COMS_FAIL on failure to establish communications */
static inst_code
i1d3_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
i1d3 *p = (i1d3 *) pp;
@@ -3287,6 +3329,9 @@ i1d3_interp_error(inst *pp, int ec) {
case I1D3_INT_THREADFAILED:
return "Starting diffuser position thread failed";
+ case I1D3_TOOBRIGHT:
+ return "Too bright to read accuractly";
+
case I1D3_NO_COMS:
return "Communications hasn't been established";;
case I1D3_NOT_INITED:
@@ -3355,11 +3400,13 @@ i1d3_interp_code(inst *pp, int ec) {
case I1D3_BAD_EX_CHSUM:
return inst_hardware_fail | ec;
+ case I1D3_TOOBRIGHT:
+ return inst_misread | ec;
+
/* Unused:
inst_notify
inst_warning
inst_unknown_model
- inst_misread
inst_nonesaved
inst_nochmatch
inst_needs_cal
@@ -3411,6 +3458,7 @@ i1d3_del(inst *pp) {
if (p->samples != NULL)
free(p->samples);
amutex_del(p->lock);
+ p->vdel(pp);
free(p);
}
}
diff --git a/spectro/i1d3.h b/spectro/i1d3.h
index 47f3858..bb239df 100644..100755
--- a/spectro/i1d3.h
+++ b/spectro/i1d3.h
@@ -63,6 +63,7 @@
#define I1D3_BAD_RET_STAT 0x13
#define I1D3_BAD_RET_CMD 0x14
#define I1D3_NOT_INITED 0x15
+#define I1D3_TOOBRIGHT 0x16
/* Internal errors */
#define I1D3_BAD_MEM_ADDRESS 0x20
diff --git a/spectro/i1disp.c b/spectro/i1disp.c
index 437e1fa..489c6cd 100644..100755
--- a/spectro/i1disp.c
+++ b/spectro/i1disp.c
@@ -1737,7 +1737,7 @@ i1disp_compute_factors(
/* Establish communications with a I1DISP */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return I1DISP_COMS_FAIL on failure to establish communications */
static inst_code
i1disp_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
i1disp *p = (i1disp *) pp;
@@ -2240,6 +2240,7 @@ i1disp_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
inst_del_disptype_list(p->dtlist, p->ndtlist);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/i1disp.h b/spectro/i1disp.h
index 45e21db..45e21db 100644..100755
--- a/spectro/i1disp.h
+++ b/spectro/i1disp.h
diff --git a/spectro/i1pro.c b/spectro/i1pro.c
index 96335cc..816aee5 100644..100755
--- a/spectro/i1pro.c
+++ b/spectro/i1pro.c
@@ -79,7 +79,7 @@ static inst_code i1pro_interp_code(i1pro *p, i1pro_code ec);
/* Establish communications with a I1DISP */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return I1PRO_COMS_FAIL on failure to establish communications */
static inst_code
i1pro_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
i1pro *p = (i1pro *) pp;
@@ -806,6 +806,7 @@ i1pro_del(inst *pp) {
del_i1proimp(p);
if (p->icom != NULL)
p->icom->del(p->icom);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/i1pro.h b/spectro/i1pro.h
index 4366e4f..4366e4f 100644..100755
--- a/spectro/i1pro.h
+++ b/spectro/i1pro.h
diff --git a/spectro/i1pro_imp.c b/spectro/i1pro_imp.c
index 0b6fc69..8577f8c 100644..100755
--- a/spectro/i1pro_imp.c
+++ b/spectro/i1pro_imp.c
@@ -149,6 +149,8 @@
/* Should be good up to 275 cd/m^2 */
#define DISP_INTT3 0.3 /* High brightness display spot mode seconds per reading, */
/* Should be good up to 700 cd/m^2 */
+#define DISP_INTT4 0.1 /* Very high brightness display spot mode seconds per reading, */
+ /* Should be good up to 2000 cd/m^2 ? */
#define ADARKINT_MAX 2.0 /* Max cal time for adaptive dark cal */
#define ADARKINT_MAX2 4.0 /* Max cal time for adaptive dark cal Rev E or no high gain */
@@ -398,6 +400,7 @@ void del_i1proimp(i1pro *p) {
free_dvector(s->dark_data, -1, m->nraw-1);
free_dvector(s->dark_data2, -1, m->nraw-1);
free_dvector(s->dark_data3, -1, m->nraw-1);
+ free_dvector(s->dark_data4, -1, m->nraw-1);
free_dvector(s->white_data, -1, m->nraw-1);
free_dmatrix(s->idark_data, 0, 3, -1, m->nraw-1);
@@ -958,6 +961,7 @@ i1pro_code i1pro_imp_init(i1pro *p) {
s->dark_data = dvectorz(-1, m->nraw-1);
s->dark_data2 = dvectorz(-1, m->nraw-1);
s->dark_data3 = dvectorz(-1, m->nraw-1);
+ s->dark_data4 = dvectorz(-1, m->nraw-1);
s->cal_valid = 0; /* Scale cal invalid */
s->cal_factor[0] = dvectorz(0, m->nwav[0]-1);
@@ -972,6 +976,7 @@ i1pro_code i1pro_imp_init(i1pro *p) {
s->dark_int_time = DISP_INTT; /* 2.0 */
s->dark_int_time2 = DISP_INTT2; /* 0.8 */
s->dark_int_time3 = DISP_INTT3; /* 0.3 */
+ s->dark_int_time4 = DISP_INTT4; /* 0.1 */
s->idark_int_time[0] = s->idark_int_time[2] = m->min_int_time;
if (p->itype == instI1Pro2) {
@@ -1057,12 +1062,14 @@ i1pro_code i1pro_imp_init(i1pro *p) {
s->dark_int_time = s->inttime;
s->dark_int_time2 = DISP_INTT2; /* Alternate disp integration time (ie. 0.8) */
s->dark_int_time3 = DISP_INTT3; /* Alternate disp integration time (ie. 0.3) */
+ s->dark_int_time4 = DISP_INTT4; /* Alternate disp integration time (ie. 0.1) */
s->dadaptime = 0.0;
s->wadaptime = 0.10;
s->dcaltime = DISP_INTT; /* ie. determines number of measurements */
s->dcaltime2 = DISP_INTT2 * 2; /* Make it 1.6 seconds (ie, 2 x 0.8 seconds) */
s->dcaltime3 = DISP_INTT3 * 3; /* Make it 0.9 seconds (ie, 3 x 0.3 seconds) */
+ s->dcaltime4 = DISP_INTT4 * 3; /* Make it 0.3 seconds (ie, 3 x 0.1 seconds) */
s->wcaltime = 0.0;
s->dreadtime = 0.0;
s->wreadtime = DISP_INTT;
@@ -1620,10 +1627,10 @@ i1pro_code i1pro_imp_calibrate(
|| (s->emiss && !s->adaptive && !s->scan)
|| (s->trans && !s->adaptive))) {
int stm;
- int usesdct23 = 0; /* Is a mode that uses dcaltime2 & 3 */
+ int usesdct234 = 0; /* Is a mode that uses dcaltime2, 3 & 4 */
if (s->emiss && !s->adaptive && !s->scan)
- usesdct23 = 1;
+ usesdct234 = 1;
nummeas = i1pro_comp_nummeas(p, s->dcaltime, s->inttime);
@@ -1637,7 +1644,7 @@ i1pro_code i1pro_imp_calibrate(
a1logd(p->log,2,"Execution time of dark calib time %f sec = %d msec\n",s->inttime,msec_time() - stm);
/* Special display mode alternate integration time black measurement */
- if (usesdct23) {
+ if (usesdct234) {
nummeas = i1pro_comp_nummeas(p, s->dcaltime2, s->dark_int_time2);
a1logd(p->log,2,"Doing 2nd initial black calibration with dcaltime2 %f, dark_int_time2 %f, nummeas %d, gainmode %d\n", s->dcaltime2, s->dark_int_time2, nummeas, s->gainmode);
stm = msec_time();
@@ -1658,6 +1665,17 @@ i1pro_code i1pro_imp_calibrate(
return ev;
}
a1logd(p->log,2,"Execution time of 3rd dark calib time %f sec = %d msec\n",s->inttime,msec_time() - stm);
+
+ nummeas = i1pro_comp_nummeas(p, s->dcaltime4, s->dark_int_time4);
+ a1logd(p->log,2,"Doing 4th initial black calibration with dcaltime4 %f, dark_int_time4 %f, nummeas %d, gainmode %d\n", s->dcaltime4, s->dark_int_time4, nummeas, s->gainmode);
+ nummeas = i1pro_comp_nummeas(p, s->dcaltime4, s->dark_int_time4);
+ stm = msec_time();
+ if ((ev = i1pro_dark_measure(p, s->dark_data4,
+ nummeas, &s->dark_int_time4, s->gainmode)) != I1PRO_OK) {
+ m->mmode = mmode; /* Restore actual mode */
+ return ev;
+ }
+ a1logd(p->log,2,"Execution time of 4rd dark calib time %f sec = %d msec\n",s->inttime,msec_time() - stm);
}
s->dark_valid = 1;
s->want_dcalib = 0;
@@ -1686,13 +1704,15 @@ i1pro_code i1pro_imp_calibrate(
ss->dark_gain_mode = s->dark_gain_mode;
for (k = -1; k < m->nraw; k++)
ss->dark_data[k] = s->dark_data[k];
- /* If this is a mode with dark_data2/3, tranfer it too */
- if (usesdct23 && ss->emiss && !ss->adaptive && !ss->scan) {
+ /* If this is a mode with dark_data2/3/4, tranfer it too */
+ if (usesdct234 && ss->emiss && !ss->adaptive && !ss->scan) {
ss->dark_int_time2 = s->dark_int_time2;
- ss->dark_int_time3 = s->dark_int_time2;
+ ss->dark_int_time3 = s->dark_int_time3;
+ ss->dark_int_time4 = s->dark_int_time4;
for (k = -1; k < m->nraw; k++) {
ss->dark_data2[k] = s->dark_data2[k];
ss->dark_data3[k] = s->dark_data3[k];
+ ss->dark_data4[k] = s->dark_data4[k];
}
}
}
@@ -2276,6 +2296,9 @@ i1pro_code i1pro_imp_calibrate(
} else if (s->dispswap == 2) {
tv = s->inttime; s->inttime = s->dark_int_time3; s->dark_int_time3 = tv;
tt = s->dark_data; s->dark_data = s->dark_data3; s->dark_data3 = tt;
+ } else if (s->dispswap == 3) {
+ tv = s->inttime; s->inttime = s->dark_int_time4; s->dark_int_time4 = tv;
+ tt = s->dark_data; s->dark_data = s->dark_data4; s->dark_data4 = tt;
}
s->dispswap = 0;
@@ -2284,30 +2307,43 @@ i1pro_code i1pro_imp_calibrate(
nummeas = i1pro_comp_nummeas(p, s->wreadtime, s->inttime);
ev = i1pro_whitemeasure(p, NULL, NULL, data , &scale, nummeas,
&s->inttime, s->gainmode, s->targoscale, 0);
- /* Switch to the alternate if things are too bright */
- /* We do this simply by swapping the alternate values in. */
if (ev == I1PRO_RD_SENSORSATURATED || scale < 1.0) {
- a1logd(p->log,2,"Switching to alternate display integration time %f seconds\n",s->dark_int_time2);
+ a1logd(p->log,2,"Switching to 2nd display integration time %f seconds\n",s->dark_int_time2);
+ /* swap in 2nd display integration time */
tv = s->inttime; s->inttime = s->dark_int_time2; s->dark_int_time2 = tv;
tt = s->dark_data; s->dark_data = s->dark_data2; s->dark_data2 = tt;
s->dispswap = 1;
/* Do another measurement of the full display white, and if it's close to */
- /* saturation, switch to the 3rd alternate display integration time */
+ /* saturation, switch to the 3rd display integration time */
nummeas = i1pro_comp_nummeas(p, s->wreadtime, s->inttime);
ev = i1pro_whitemeasure(p, NULL, NULL, data , &scale, nummeas,
&s->inttime, s->gainmode, s->targoscale, 0);
- /* Switch to the 3rd alternate if things are too bright */
- /* We do this simply by swapping the alternate values in. */
if (ev == I1PRO_RD_SENSORSATURATED || scale < 1.0) {
- a1logd(p->log,2,"Switching to 3rd alternate display integration time %f seconds\n",s->dark_int_time3);
+ a1logd(p->log,2,"Switching to 3rd display integration time %f seconds\n",s->dark_int_time3);
/* Undo previous swap */
tv = s->inttime; s->inttime = s->dark_int_time2; s->dark_int_time2 = tv;
tt = s->dark_data; s->dark_data = s->dark_data2; s->dark_data2 = tt;
- /* swap in 2nd alternate */
+ /* swap in 3rd time */
tv = s->inttime; s->inttime = s->dark_int_time3; s->dark_int_time3 = tv;
tt = s->dark_data; s->dark_data = s->dark_data3; s->dark_data3 = tt;
s->dispswap = 2;
+
+ /* Do another measurement of the full display white, and if it's close to */
+ /* saturation, switch to the 4th display integration time */
+ nummeas = i1pro_comp_nummeas(p, s->wreadtime, s->inttime);
+ ev = i1pro_whitemeasure(p, NULL, NULL, data , &scale, nummeas,
+ &s->inttime, s->gainmode, s->targoscale, 0);
+ if (ev == I1PRO_RD_SENSORSATURATED || scale < 1.0) {
+ a1logd(p->log,2,"Switching to 4th display integration time %f seconds\n",s->dark_int_time3);
+ /* Undo previous swap */
+ tv = s->inttime; s->inttime = s->dark_int_time3; s->dark_int_time3 = tv;
+ tt = s->dark_data; s->dark_data = s->dark_data3; s->dark_data3 = tt;
+ /* swap in 4th time */
+ tv = s->inttime; s->inttime = s->dark_int_time4; s->dark_int_time4 = tv;
+ tt = s->dark_data; s->dark_data = s->dark_data4; s->dark_data4 = tt;
+ s->dispswap = 3;
+ }
}
}
free_dvector(data, -1, m->nraw-1);
@@ -2947,16 +2983,16 @@ i1pro_code i1pro_imp_measure(
/* and try again. */
if (s->emiss && !s->scan && !s->adaptive
&& ev == I1PRO_RD_SENSORSATURATED
- && s->dispswap < 2) {
+ && s->dispswap < 3) {
double *tt, tv;
if (s->dispswap == 0) {
- a1logd(p->log,2,"Switching to alternate display integration time %f seconds\n",s->dark_int_time2);
+ a1logd(p->log,2,"Switching to 2nd display integration time %f seconds\n",s->dark_int_time2);
tv = s->inttime; s->inttime = s->dark_int_time2; s->dark_int_time2 = tv;
tt = s->dark_data; s->dark_data = s->dark_data2; s->dark_data2 = tt;
s->dispswap = 1;
} else if (s->dispswap == 1) {
- a1logd(p->log,2,"Switching to 2nd alternate display integration time %f seconds\n",s->dark_int_time3);
+ a1logd(p->log,2,"Switching to 3rd display integration time %f seconds\n",s->dark_int_time3);
/* Undo first swap */
tv = s->inttime; s->inttime = s->dark_int_time2; s->dark_int_time2 = tv;
tt = s->dark_data; s->dark_data = s->dark_data2; s->dark_data2 = tt;
@@ -2964,6 +3000,15 @@ i1pro_code i1pro_imp_measure(
tv = s->inttime; s->inttime = s->dark_int_time3; s->dark_int_time3 = tv;
tt = s->dark_data; s->dark_data = s->dark_data3; s->dark_data3 = tt;
s->dispswap = 2;
+ } else if (s->dispswap == 2) {
+ a1logd(p->log,2,"Switching to 4th display integration time %f seconds\n",s->dark_int_time4);
+ /* Undo 2nd swap */
+ tv = s->inttime; s->inttime = s->dark_int_time3; s->dark_int_time3 = tv;
+ tt = s->dark_data; s->dark_data = s->dark_data3; s->dark_data3 = tt;
+ /* Do 3rd swap */
+ tv = s->inttime; s->inttime = s->dark_int_time4; s->dark_int_time4 = tv;
+ tt = s->dark_data; s->dark_data = s->dark_data4; s->dark_data4 = tt;
+ s->dispswap = 3;
}
/* Recompute number of measurements and realloc measurement buffer */
free(mbuf);
@@ -4145,6 +4190,8 @@ i1pro_code i1pro_save_calibration(i1pro *p) {
write_doubles(&x, fp, s->dark_data2-1, m->nraw+1);
write_doubles(&x, fp, &s->dark_int_time3, 1);
write_doubles(&x, fp, s->dark_data3-1, m->nraw+1);
+ write_doubles(&x, fp, &s->dark_int_time4, 1);
+ write_doubles(&x, fp, s->dark_data4-1, m->nraw+1);
write_ints(&x, fp, &s->dark_gain_mode, 1);
if (!s->emiss) {
@@ -4288,7 +4335,10 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
read_doubles(&x, fp, &dd, 1);
for (j = -1; j < m->nraw; j++)
read_doubles(&x, fp, &dd, 1);
- read_doubles(&x, fp, &dd, 1);
+ read_doubles(&x, fp, &dd, 1); /* dark_data3 */
+ for (j = -1; j < m->nraw; j++)
+ read_doubles(&x, fp, &dd, 1);
+ read_doubles(&x, fp, &dd, 1); /* dark_data4 */
for (j = -1; j < m->nraw; j++)
read_doubles(&x, fp, &dd, 1);
read_ints(&x, fp, &di, 1);
@@ -4338,6 +4388,7 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
ts.dark_data = dvectorz(-1, m->nraw-1);
ts.dark_data2 = dvectorz(-1, m->nraw-1);
ts.dark_data3 = dvectorz(-1, m->nraw-1);
+ ts.dark_data4 = dvectorz(-1, m->nraw-1);
ts.cal_factor[0] = dvectorz(0, m->nwav[0]-1);
ts.cal_factor[1] = dvectorz(0, m->nwav[1]-1);
ts.white_data = dvectorz(-1, m->nraw-1);
@@ -4384,6 +4435,8 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
read_doubles(&x, fp, ts.dark_data2-1, m->nraw+1);
read_doubles(&x, fp, &ts.dark_int_time3, 1);
read_doubles(&x, fp, ts.dark_data3-1, m->nraw+1);
+ read_doubles(&x, fp, &ts.dark_int_time4, 1);
+ read_doubles(&x, fp, ts.dark_data4-1, m->nraw+1);
read_ints(&x, fp, &ts.dark_gain_mode, 1);
if (!ts.emiss) {
@@ -4419,6 +4472,7 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
&& (s->adaptive || fabs(s->dark_int_time - ts.dark_int_time) < 0.01)
&& (s->adaptive || fabs(s->dark_int_time2 - ts.dark_int_time2) < 0.01)
&& (s->adaptive || fabs(s->dark_int_time3 - ts.dark_int_time3) < 0.01)
+ && (s->adaptive || fabs(s->dark_int_time4 - ts.dark_int_time4) < 0.01)
&& (!s->adaptive || fabs(s->idark_int_time[0] - ts.idark_int_time[0]) < 0.01)
&& (!s->adaptive || fabs(s->idark_int_time[1] - ts.idark_int_time[1]) < 0.01)
&& (!s->adaptive || fabs(s->idark_int_time[2] - ts.idark_int_time[2]) < 0.01)
@@ -4451,6 +4505,9 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
s->dark_int_time3 = ts.dark_int_time3;
for (j = -1; j < m->nraw; j++)
s->dark_data3[j] = ts.dark_data3[j];
+ s->dark_int_time4 = ts.dark_int_time4;
+ for (j = -1; j < m->nraw; j++)
+ s->dark_data4[j] = ts.dark_data4[j];
s->dark_gain_mode = ts.dark_gain_mode;
if (!ts.emiss) {
s->cal_valid = ts.cal_valid;
@@ -4480,7 +4537,7 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
a1logd(p->log,2,"emis = %d : %d, trans = %d : %d, ref = %d : %d\n",s->emiss,ts.emiss,s->trans,ts.trans,s->reflective,ts.reflective);
a1logd(p->log,2,"scan = %d : %d, flash = %d : %d, ambi = %d : %d, adapt = %d : %d\n",s->scan,ts.scan,s->flash,ts.flash,s->ambient,ts.ambient,s->adaptive,ts.adaptive);
a1logd(p->log,2,"inttime = %f : %f\n",s->inttime,ts.inttime);
- a1logd(p->log,2,"darkit1 = %f : %f, 2 = %f : %f, 3 = %f : %f\n",s->dark_int_time,ts.dark_int_time,s->dark_int_time2,ts.dark_int_time2,s->dark_int_time3,ts.dark_int_time3);
+ a1logd(p->log,2,"darkit1 = %f : %f, 2 = %f : %f, 3 = %f : %f, 4 = %f : %f\n",s->dark_int_time,ts.dark_int_time,s->dark_int_time2,ts.dark_int_time2,s->dark_int_time3,ts.dark_int_time3,s->dark_int_time4,ts.dark_int_time4);
a1logd(p->log,2,"idarkit0 = %f : %f, 1 = %f : %f, 2 = %f : %f, 3 = %f : %f\n",s->idark_int_time[0],ts.idark_int_time[0],s->idark_int_time[1],ts.idark_int_time[1],s->idark_int_time[2],ts.idark_int_time[2],s->idark_int_time[3],ts.idark_int_time[3]);
}
}
@@ -4489,6 +4546,7 @@ i1pro_code i1pro_restore_calibration(i1pro *p) {
free_dvector(ts.dark_data, -1, m->nraw-1);
free_dvector(ts.dark_data2, -1, m->nraw-1);
free_dvector(ts.dark_data3, -1, m->nraw-1);
+ free_dvector(ts.dark_data4, -1, m->nraw-1);
free_dvector(ts.white_data, -1, m->nraw-1);
free_dmatrix(ts.idark_data, 0, 3, -1, m->nraw-1);
@@ -4549,6 +4607,8 @@ i1pro_establish_high_power(i1pro *p) {
if ((ev = i1pro_getmisc(p, &m->fwrev, NULL, &m->maxpve, NULL, &m->powmode)) != I1PRO_OK)
return ev;
+ a1logd(p->log,2,"CPLD rev = %d\n",m->cpldrev);
+
if (m->powmode != 8) { /* In high power mode */
if ((ev = i1pro_reset(p, 0x1f)) != I1PRO_OK)
return ev;
@@ -10724,14 +10784,14 @@ i1pro_readEEProm(
0xC4, 0, 0, pbuf, len, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_readEEProm: read failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_readEEProm: read failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
/* Now read the bytes */
se = p->icom->usb_read(p->icom, NULL, 0x82, buf, size, &rwbytes, 5.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_readEEProm: read failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_readEEProm: read failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -10812,7 +10872,7 @@ i1pro_writeEEProm(
0xC3, 0, 0, pbuf, len, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,2,"i1pro_writeEEProm: write failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,2,"i1pro_writeEEProm: write failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -10820,7 +10880,7 @@ i1pro_writeEEProm(
se = p->icom->usb_write(p->icom, NULL, 0x03, buf, size, &rwbytes, 5.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_writeEEProm: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_writeEEProm: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -10837,7 +10897,7 @@ i1pro_writeEEProm(
se = p->icom->usb_write(p->icom, NULL, 0x03, pbuf, 1, &rwbytes, 5.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_writeEEProm: write failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_writeEEProm: write failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -10889,7 +10949,7 @@ i1pro_getmisc(
0xC9, 0, 0, pbuf, 8, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_getmisc: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_getmisc: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -10937,7 +10997,7 @@ i1pro_getmeasparams(
0xC2, 0, 0, pbuf, 8, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_getmeasparams: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_getmeasparams: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -11002,7 +11062,7 @@ i1pro_setmeasparams(
0xC1, 0, 0, pbuf, 8, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_setmeasparams: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_setmeasparams: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -11318,10 +11378,13 @@ i1pro_setmcmode(
0xCF, 0, 0, pbuf, 1, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_setmcmode: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_setmcmode: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
+ /* Hmm. Give the instrument a little time to reconfigure itself. */
+ msec_sleep(10);
+
a1logd(p->log,2,"i1pro_setmcmode: done, ICOM err 0x%x (%d msec)\n",
se, msec_time()-stime);
return rv;
@@ -11358,7 +11421,7 @@ i1pro_getmcmode(
0xD1, 0, 0, pbuf, 6, 2.0);
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_getmcmode: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_getmcmode: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
@@ -11403,7 +11466,7 @@ i1pro_code i1pro_waitfor_switch(i1pro *p, double top) {
}
if ((rv = icoms2i1pro_err(se)) != I1PRO_OK) {
- a1logd(p->log,1,"i1pro_waitfor_switch: failed with ICOM err 0x%x\n",se);
+ a1logd(p->log,1,"i1pro_waitfor_switch: failed with ICOM err 0x%x (%d msec)\n",se, msec_time()-stime);
return rv;
}
diff --git a/spectro/i1pro_imp.h b/spectro/i1pro_imp.h
index 6bf8de4..5a2cef2 100644..100755
--- a/spectro/i1pro_imp.h
+++ b/spectro/i1pro_imp.h
@@ -127,6 +127,7 @@ struct _i1pro_state {
/* Display mode calibration state (emmis && !scan && !adaptive) */
int dispswap; /* 0 = default time, 1 = dark_int_time2, 2 = dark_int_time3 */
+ /* 3 = dark_int_time4 */
double done_dintsel; /* A display integration time selection has been done */
time_t diseldate; /* Date/time of last display integration time selection */
double dcaltime2; /* Target dark calibration time - sets number of readings */
@@ -135,6 +136,9 @@ struct _i1pro_state {
double dcaltime3; /* Target dark calibration time - sets number of readings */
double dark_int_time3; /* Integration time used for dark data 3 */
double *dark_data3; /* [-1 nraw] of dark level to subtract for dark_int_time3. */
+ double dcaltime4; /* Target dark calibration time - sets number of readings */
+ double dark_int_time4; /* Integration time used for dark data 4 */
+ double *dark_data4; /* [-1 nraw] of dark level to subtract for dark_int_time4. */
}; typedef struct _i1pro_state i1pro_state;
@@ -200,8 +204,8 @@ struct _i1proimp {
/* Values read from GetMisc() */
int fwrev; /* int - Firmware revision number, from getmisc() */
/* Used for internal switching ?? */
- /* 101 = Rev A, 202 = Rev A update, 302 = Rev B, 502 = Rev D */
- /* 629 = Rev E (i1pro2) */
+ /* 101 = Rev A, 202 = Rev A update, 302 = Rev B, */
+ /* 502, 505, 631 = Rev D, 629 = Rev E (i1pro2) */
int cpldrev; /* int - CPLD revision number in EEProm */
/* Not used internaly ???? */
diff --git a/spectro/icoms.c b/spectro/icoms.c
index b69b72a..b69b72a 100644..100755
--- a/spectro/icoms.c
+++ b/spectro/icoms.c
diff --git a/spectro/icoms.h b/spectro/icoms.h
index 2a282f0..2a282f0 100644..100755
--- a/spectro/icoms.h
+++ b/spectro/icoms.h
diff --git a/spectro/icoms_nt.c b/spectro/icoms_nt.c
index 14258e9..14258e9 100644..100755
--- a/spectro/icoms_nt.c
+++ b/spectro/icoms_nt.c
diff --git a/spectro/icoms_ux.c b/spectro/icoms_ux.c
index 7fb7359..7fb7359 100644..100755
--- a/spectro/icoms_ux.c
+++ b/spectro/icoms_ux.c
diff --git a/spectro/ifiles b/spectro/ifiles
index 706d0b7..706d0b7 100644..100755
--- a/spectro/ifiles
+++ b/spectro/ifiles
diff --git a/spectro/illumread.c b/spectro/illumread.c
index 381f6b6..381f6b6 100644..100755
--- a/spectro/illumread.c
+++ b/spectro/illumread.c
diff --git a/spectro/inflate.c b/spectro/inflate.c
index 55d8e65..55d8e65 100644..100755
--- a/spectro/inflate.c
+++ b/spectro/inflate.c
diff --git a/spectro/inst.c b/spectro/inst.c
index 949e34f..8976669 100644..100755
--- a/spectro/inst.c
+++ b/spectro/inst.c
@@ -581,6 +581,18 @@ static inst_config config_enum(inst *p, int ec) {
}
/* ---------------------------------------------- */
+
+/* Delete things set/done by new_inst() */
+static inst_code virtual_del(inst *p) {
+
+#if defined(__APPLE__)
+ osx_latencycritical_end();
+#endif
+
+ return inst_ok;
+}
+
+
/* Virtual constructor. */
/* Return NULL for unknown instrument, */
/* or serial instrument if nocoms == 0. */
@@ -702,6 +714,8 @@ void *cntx /* Context for callback */
return NULL;
}
+ p->vdel = virtual_del;
+
/* Add default methods if constructor did not supply them */
if (p->init_coms == NULL)
p->init_coms = init_coms;
@@ -785,6 +799,10 @@ void *cntx /* Context for callback */
/* Set the provided user interaction callback */
p->set_uicallback(p, uicallback, cntx);
+#if defined(__APPLE__)
+ osx_latencycritical_start();
+#endif
+
return p;
}
diff --git a/spectro/inst.h b/spectro/inst.h
index d47f7ea..736a879 100644..100755
--- a/spectro/inst.h
+++ b/spectro/inst.h
@@ -643,6 +643,10 @@ typedef enum {
void (*eventcallback)(void *cntx, inst_event_type event); \
void *event_cntx; /* Event callback function */ \
\
+ /* Virtual delete. Cleans up things done by new_inst(). */ \
+ inst_code (*vdel)( \
+ struct _inst *p); \
+ \
/* Establish communications at the indicated baud rate. */ \
/* (Serial parameters are ignored for USB instrument) */ \
/* Timout in to seconds, and return non-zero error code */ \
diff --git a/spectro/instappsup.c b/spectro/instappsup.c
index 0762bbe..d2ce7ff 100644..100755
--- a/spectro/instappsup.c
+++ b/spectro/instappsup.c
@@ -401,7 +401,7 @@ inst_code inst_handle_calibrate(
printf("\n");
/* If optional calib. and user wants to skip it */
/* Loop back to calibrate() with inst_calc_optional_flag still set */
- if ((calc & inst_calc_optional_flag) != 0 && ch == 's' || ch == 'S') {
+ if ((calc & inst_calc_optional_flag) != 0 && (ch == 's' || ch == 'S')) {
printf("Skipped\n");
goto oloop;
}
diff --git a/spectro/instappsup.h b/spectro/instappsup.h
index 8da4325..8da4325 100644..100755
--- a/spectro/instappsup.h
+++ b/spectro/instappsup.h
diff --git a/spectro/instlib.ksh b/spectro/instlib.ksh
index 88796f8..88796f8 100644..100755
--- a/spectro/instlib.ksh
+++ b/spectro/instlib.ksh
diff --git a/spectro/instlib.txt b/spectro/instlib.txt
index 661584d..661584d 100644..100755
--- a/spectro/instlib.txt
+++ b/spectro/instlib.txt
diff --git a/spectro/insttypeinst.h b/spectro/insttypeinst.h
index ad8047d..ad8047d 100644..100755
--- a/spectro/insttypeinst.h
+++ b/spectro/insttypeinst.h
diff --git a/spectro/insttypes.c b/spectro/insttypes.c
index 5a660a8..5a660a8 100644..100755
--- a/spectro/insttypes.c
+++ b/spectro/insttypes.c
diff --git a/spectro/insttypes.h b/spectro/insttypes.h
index ab80cd2..ab80cd2 100644..100755
--- a/spectro/insttypes.h
+++ b/spectro/insttypes.h
diff --git a/spectro/iusb.h b/spectro/iusb.h
index a254ec0..a254ec0 100644..100755
--- a/spectro/iusb.h
+++ b/spectro/iusb.h
diff --git a/spectro/kleink10.c b/spectro/kleink10.c
index 461cb28..9599972 100644..100755
--- a/spectro/kleink10.c
+++ b/spectro/kleink10.c
@@ -62,7 +62,7 @@
#undef HIGH_SPEED /* [und] Use high speed flicker measure for refresh rate etc. */
#define AUTO_AVERAGE /* [def] Automatically average more readings for low light */
-#define RETRY_RANGE_ERROR 3 /* [3] Retry range error readings 3 times */
+#define RETRY_RANGE_ERROR 4 /* [4] Retry range error readings 4 times */
#undef PLOT_REFRESH /* [und] Plot refresh rate measurement info */
#undef PLOT_UPDELAY /* [und] Plot update delay measurement info */
@@ -81,6 +81,7 @@ static inst_code k10_read_flicker_samples(kleink10 *p, double duration, double *
/* Decode a K10 error letter */
static int decodeK10err(char c) {
+//printf("~1 decoding error code 0x%x\n",c);
if (c == '0') {
return K10_OK;
} else if (c == 'B') {
@@ -125,28 +126,34 @@ extract_ec(char *s, int *nlength, int bread) {
if (*p == '>')
break;
}
- if (p < s)
+ if (p < s) {
+//printf("p %d < s %d ? %d\n", p, s, p < s);
return K10_BAD_RETVAL;
+ }
//printf("trailing is at %d '%s'\n",p - s, p);
/* Find the leading '<' */
for (f = p-1; f >= (p-MAXECHARS-1) && f >= s; f--) {
if (*f == '<')
break;
+ /* Turns out the error code may be non-text */
+#ifdef NEVER
if ((*f < '0' || *f > '9')
&& (*f < 'a' || *f > 'z')
&& (*f < 'A' || *f > 'Z'))
return K10_BAD_RETVAL;
+#endif /* NEVER */
}
if (f < s || f < (p-MAXECHARS-1) || (p-f) <= 1) {
-//printf("f < s ? %d, f < (p-MAXECHARS-1) ? %d, (p-f) <= 1 ? %d\n",
-//f < s, f < (p-10), (p-f) <= 1);
+//printf("f < s ? %d, f < (p-MAXECHARS-1) ? %d, (p-f) <= 1 ? %d\n", f < s, f < (p-10), (p-f) <= 1);
return K10_BAD_RETVAL;
}
//printf("leading is at %d '%s'\n",f - s, f);
- if (p-f-1 <= 0)
+ if (p-f-1 <= 0) {
+//printf("p-f-1 %d <= 0 ? %d\n", p-f-1, p-f-1 <= 0);
return K10_BAD_RETVAL;
+ }
strncpy(tt, f+1, p-f-1);
tt[p-f-1] = '\000';
@@ -155,7 +162,7 @@ extract_ec(char *s, int *nlength, int bread) {
/* Interpret the error character(s) */
/* It's not clear if more than one error can be returned. */
/* We are only looking at the first character - we should */
- /* really prioritize them id more than one can occur. */
+ /* really prioritize them if more than one can occur. */
for (p = tt; *p != '\000'; p++) {
rv = decodeK10err(*p);
break;
@@ -467,7 +474,15 @@ k10_init_inst(inst *pp) {
amutex_lock(p->lock);
/* Make sure the target lights are off */
- if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 1.0)) != inst_ok) {
+ if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 1.0)) != inst_ok
+ /* Strangely the L0/1 command mat return irrelevant error codes... */
+ && (ev & inst_imask) != K10_UNKNOWN
+ && (ev & inst_imask) != K10_BLACK_EXCESS
+ && (ev & inst_imask) != K10_BLACK_OVERDRIVE
+ && (ev & inst_imask) != K10_BLACK_ZERO
+ && (ev & inst_imask) != K10_OVER_HIGH_RANGE
+ && (ev & inst_imask) != K10_TOP_OVER_RANGE
+ && (ev & inst_imask) != K10_BOT_UNDER_RANGE) {
amutex_unlock(p->lock);
return ev;
}
@@ -510,14 +525,20 @@ k10_init_inst(inst *pp) {
if (p->log->verb) {
char *model = "Unknown";
switch (p->model) {
+ case k10_k1:
+ model = "K-1";
+ break;
+ case k10_k8:
+ model = "K-8";
+ break;
case k10_k10:
- model = "K10";
+ model = "K-10";
break;
case k10_k10a:
- model = "K10-A";
+ model = "K-10A";
break;
case k10_kv10a:
- model = "KV10-A";
+ model = "KV-10A";
break;
}
a1logv(p->log, 1, " Model: '%s'\n",model);
@@ -886,7 +907,7 @@ kleink10 *p) {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-static abort_flicker(kleink10 *p, int isnew, double *retbuf) {
+static void abort_flicker(kleink10 *p, int isnew, double *retbuf) {
char buf[MAX_MES_SIZE];
int bread;
@@ -976,7 +997,15 @@ int usefast /* If nz use fast rate is possible */
/* Make sure the target lights are off */
if (p->lights) {
int se;
- if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok) {
+ if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok
+ /* Strangely the L0/1 command mat return irrelevant error codes... */
+ && (ev & inst_imask) != K10_UNKNOWN
+ && (ev & inst_imask) != K10_BLACK_EXCESS
+ && (ev & inst_imask) != K10_BLACK_OVERDRIVE
+ && (ev & inst_imask) != K10_BLACK_ZERO
+ && (ev & inst_imask) != K10_OVER_HIGH_RANGE
+ && (ev & inst_imask) != K10_TOP_OVER_RANGE
+ && (ev & inst_imask) != K10_BOT_UNDER_RANGE) {
amutex_unlock(p->lock);
free(retbuf);
a1logd(p->log, 1, "k10_read_flicker: L0 failed\n");
@@ -1182,9 +1211,9 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
int user_trig = 0;
int bsize;
inst_code rv = inst_protocol_error;
- int range[3]; /* Range for RGB sensor values */
- int i, tries,ntav = 1; /* Number of readings to average */
- double v, vv, XYZ[3];
+ int range[3]; /* Range for RGB sensor values */
+ int i, tries, ntav = 1; /* Number of readings to average */
+ double v, vv;
if (!p->gotcoms)
return inst_no_coms;
@@ -1230,7 +1259,15 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
/* Make sure the target lights are off */
if (p->lights) {
- if ((rv = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 1.0)) != inst_ok) {
+ if ((rv = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 1.0)) != inst_ok
+ /* Strangely the L0/1 command mat return irrelevant error codes... */
+ && (rv & inst_imask) != K10_UNKNOWN
+ && (rv & inst_imask) != K10_BLACK_EXCESS
+ && (rv & inst_imask) != K10_BLACK_OVERDRIVE
+ && (rv & inst_imask) != K10_BLACK_ZERO
+ && (rv & inst_imask) != K10_OVER_HIGH_RANGE
+ && (rv & inst_imask) != K10_TOP_OVER_RANGE
+ && (rv & inst_imask) != K10_BOT_UNDER_RANGE) {
amutex_unlock(p->lock);
a1logd(p->log, 1, "k10_read_sample: L0 failed\n");
return rv;
@@ -1256,7 +1293,7 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
if (rv == inst_ok
|| ( (rv & inst_imask) != K10_TOP_OVER_RANGE
&& (rv & inst_imask) != K10_BOT_UNDER_RANGE))
- break;
+ break;
}
if (rv == inst_ok)
@@ -1273,7 +1310,6 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
if (val->XYZ[2] > v)
v = val->XYZ[2];
- ntav = 1;
#ifdef AUTO_AVERAGE
if (!IMODETST(p->mode, inst_mode_emis_nonadaptive)) {
/* Decide how many extra readings to average into result. */
@@ -1292,13 +1328,26 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
vv = 1.0 - (v - thr[2]) / (thr[3] - thr[2]);
vv = vv * vv * vv;
ntav = (int)(vv * (nav[2] - nav[3]) + nav[3] + 0.5);
- }
+ } /* else default 1 */
}
#endif
+ /* Measure extras up to ntav */
for (i = 1; i < ntav; i++) {
- if ((rv = k10_command(p, "N5\r", buf, MAX_MES_SIZE, &bsize, 15, ec_ec, 2.0)) != inst_ok)
+ double XYZ[3];
+
+ for (tries = 0; tries < RETRY_RANGE_ERROR; tries++) {
+ rv = k10_command(p, "N5\r", buf, MAX_MES_SIZE, &bsize, 15, ec_ec, 2.0);
+ if (rv == inst_ok
+ || ( (rv & inst_imask) != K10_TOP_OVER_RANGE
+ && (rv & inst_imask) != K10_BOT_UNDER_RANGE))
+ break;
+ }
+
+ if (rv != inst_ok) { // An error, or retry failed
break;
+ }
+
if ((rv = decodeN5(p, XYZ, range, buf, bsize)) != inst_ok)
break;
@@ -1321,10 +1370,6 @@ instClamping clamp) { /* NZ if clamp XYZ/Lab to be +ve */
amutex_unlock(p->lock);
- if ((rv = decodeN5(p, val->XYZ, range, buf, bsize)) != inst_ok) {
- return rv;
- }
-
/* Apply the calibration correction matrix */
icmMulBy3x3(val->XYZ, p->ccmat, val->XYZ);
@@ -2396,6 +2441,7 @@ k10_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
amutex_del(p->lock);
+ p->vdel(pp);
free(p);
}
}
@@ -2741,14 +2787,30 @@ k10_get_set_opt(inst *pp, inst_opt_type m, ...)
}
if (state == 1) { /* Turn on */
- if ((ev = k10_command(p, "L1\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok) {
+ if ((ev = k10_command(p, "L1\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok
+ /* Strangely the L0/1 command mat return irrelevant error codes... */
+ && (ev & inst_imask) != K10_UNKNOWN
+ && (ev & inst_imask) != K10_BLACK_EXCESS
+ && (ev & inst_imask) != K10_BLACK_OVERDRIVE
+ && (ev & inst_imask) != K10_BLACK_ZERO
+ && (ev & inst_imask) != K10_OVER_HIGH_RANGE
+ && (ev & inst_imask) != K10_TOP_OVER_RANGE
+ && (ev & inst_imask) != K10_BOT_UNDER_RANGE) {
amutex_unlock(p->lock);
a1logd(p->log, 1, "k10_get_set_opt: L1 failed\n");
return ev;
}
p->lights = 1;
} else if (state == 0) { /* Turn off */
- if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok) {
+ if ((ev = k10_command(p, "L0\r", buf, MAX_MES_SIZE, NULL, 2+3, ec_ec, 0.5)) != inst_ok
+ /* Strangely the L0/1 command mat return irrelevant error codes... */
+ && (ev & inst_imask) != K10_UNKNOWN
+ && (ev & inst_imask) != K10_BLACK_EXCESS
+ && (ev & inst_imask) != K10_BLACK_OVERDRIVE
+ && (ev & inst_imask) != K10_BLACK_ZERO
+ && (ev & inst_imask) != K10_OVER_HIGH_RANGE
+ && (ev & inst_imask) != K10_TOP_OVER_RANGE
+ && (ev & inst_imask) != K10_BOT_UNDER_RANGE) {
amutex_unlock(p->lock);
a1logd(p->log, 1, "k10_get_set_opt: L0 failed\n");
return ev;
diff --git a/spectro/kleink10.h b/spectro/kleink10.h
index 4dcc334..4dcc334 100644..100755
--- a/spectro/kleink10.h
+++ b/spectro/kleink10.h
diff --git a/spectro/linear.cal b/spectro/linear.cal
index 96cad93..9c88605 100644..100755
--- a/spectro/linear.cal
+++ b/spectro/linear.cal
@@ -2,7 +2,7 @@ CAL
DESCRIPTOR "Argyll Device Calibration Curves"
ORIGINATOR "Argyll synthcal"
-CREATED "Mon Sep 07 03:37:56 2015"
+CREATED "Mon Oct 26 01:10:48 2015"
DEVICE_CLASS "DISPLAY"
COLOR_REP "RGB"
diff --git a/spectro/linear.sp b/spectro/linear.sp
index 8851462..8851462 100644..100755
--- a/spectro/linear.sp
+++ b/spectro/linear.sp
diff --git a/spectro/madvrwin.c b/spectro/madvrwin.c
index e131e5e..e131e5e 100644..100755
--- a/spectro/madvrwin.c
+++ b/spectro/madvrwin.c
diff --git a/spectro/madvrwin.h b/spectro/madvrwin.h
index bbaf32e..bbaf32e 100644..100755
--- a/spectro/madvrwin.h
+++ b/spectro/madvrwin.h
diff --git a/spectro/mongoose.c b/spectro/mongoose.c
index 019101e..019101e 100644..100755
--- a/spectro/mongoose.c
+++ b/spectro/mongoose.c
diff --git a/spectro/mongoose.h b/spectro/mongoose.h
index 1ee0c47..1ee0c47 100644..100755
--- a/spectro/mongoose.h
+++ b/spectro/mongoose.h
diff --git a/spectro/munki.c b/spectro/munki.c
index 57f5ce8..df54cd9 100644..100755
--- a/spectro/munki.c
+++ b/spectro/munki.c
@@ -66,7 +66,7 @@ static inst_code munki_interp_code(munki *p, munki_code ec);
/* Establish communications with a Munki */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return MUNKI_COMS_FAIL on failure to establish communications */
static inst_code
munki_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
munki *p = (munki *) pp;
@@ -937,6 +937,7 @@ munki_del(inst *pp) {
del_munkiimp(p);
if (p->icom != NULL)
p->icom->del(p->icom);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/munki.h b/spectro/munki.h
index 01eda29..01eda29 100644..100755
--- a/spectro/munki.h
+++ b/spectro/munki.h
diff --git a/spectro/munki_imp.c b/spectro/munki_imp.c
index 6f49d0d..6f49d0d 100644..100755
--- a/spectro/munki_imp.c
+++ b/spectro/munki_imp.c
diff --git a/spectro/munki_imp.h b/spectro/munki_imp.h
index ea9451f..ea9451f 100644..100755
--- a/spectro/munki_imp.h
+++ b/spectro/munki_imp.h
diff --git a/spectro/oemarch.c b/spectro/oemarch.c
index a9bbda1..a9bbda1 100644..100755
--- a/spectro/oemarch.c
+++ b/spectro/oemarch.c
diff --git a/spectro/oemarch.h b/spectro/oemarch.h
index b0b1a65..b0b1a65 100644..100755
--- a/spectro/oemarch.h
+++ b/spectro/oemarch.h
diff --git a/spectro/oeminst.c b/spectro/oeminst.c
index bce7a67..bce7a67 100644..100755
--- a/spectro/oeminst.c
+++ b/spectro/oeminst.c
diff --git a/spectro/pollem.c b/spectro/pollem.c
index f7578c8..f7578c8 100644..100755
--- a/spectro/pollem.c
+++ b/spectro/pollem.c
diff --git a/spectro/pollem.h b/spectro/pollem.h
index f8a86ee..f8a86ee 100644..100755
--- a/spectro/pollem.h
+++ b/spectro/pollem.h
diff --git a/spectro/rspec.c b/spectro/rspec.c
index 49d725b..e0e0194 100644..100755
--- a/spectro/rspec.c
+++ b/spectro/rspec.c
@@ -43,6 +43,7 @@
#include "sa_config.h"
#include "numsup.h"
#endif /* !SALONEINSTLIB */
+#include "plot.h"
#include "xspect.h"
#include "insttypes.h"
#include "conv.h"
@@ -152,9 +153,6 @@ double rspec_raw2nm(rspec_inf *inf, double rix) {
if (inf->nwlcal == 0)
error("rspec_raw2nm: nwlcal == 0");
-// ~~~~9999 test fudge
-// rix += 15;
-
/* Compute polinomial */
for (wl = inf->wlcal[inf->nwlcal-1], k = inf->nwlcal-2; k >= 0; k--)
wl = wl * rix + inf->wlcal[k];
diff --git a/spectro/rspec.h b/spectro/rspec.h
index bc5d427..0cbee58 100644..100755
--- a/spectro/rspec.h
+++ b/spectro/rspec.h
@@ -33,12 +33,12 @@
/* - - - - - - - - - - - - - */
/* Collection of raw samples */
typedef enum {
- rspec_sensor, /* Includes shielded/temperaturee values */
+ rspec_sensor, /* Includes shielded/temperature values */
rspec_raw, /* Potential light values */
rspec_wav /* Valid wavelength values */
} rspec_type;
-/* The order the state is changed in is device workflow dependent */
+/* The order the state is changed in, is device workflow dependent */
typedef enum {
rspec_none = 0x0000, /* No processing */
rspec_shld = 0x0002, /* Shielded cell corrected */
@@ -136,7 +136,7 @@ struct _rspec_inf {
/* Completely clear an rspec_inf. */
void clear_rspec_inf(rspec_inf *inf);
-/* Completely free contesnt of rspec_inf. */
+/* Completely free contents of rspec_inf. */
void free_rspec_inf(rspec_inf *inf);
/* return the number of samples for the given spectral type */
diff --git a/spectro/smcube.c b/spectro/smcube.c
index 1618447..8a788ec 100644..100755
--- a/spectro/smcube.c
+++ b/spectro/smcube.c
@@ -140,6 +140,12 @@ static inst_code smcube_measure(smcube *p, double *XYZ);
static void cube_rgb2XYZ(double *xyz, double *irgb);
+int static smcube_save_calibration(smcube *p);
+int static smcube_touch_calibration(smcube *p);
+int static smcube_restore_calibration(smcube *p);
+
+/* ------------------------------------------------- */
+
/* Do a full command/response echange with the smcube */
/* (This level is not multi-thread safe) */
/* Return the smcube error code. */
@@ -849,6 +855,7 @@ smcube_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
amutex_del(p->lock);
+ p->vdel(pp);
free(p);
}
}
@@ -2009,7 +2016,7 @@ static void cube_rgb2XYZ(double *xyz, double *irgb) {
/* The cube doesn't have an easily accessible serial number :-( */
/* So if you have more than one, you'll be sharing the same calibration !! */
-int smcube_save_calibration(smcube *p) {
+int static smcube_save_calibration(smcube *p) {
int ev = SMCUBE_OK;
int i;
char fname[100]; /* Name */
@@ -2067,7 +2074,7 @@ int smcube_save_calibration(smcube *p) {
}
/* Restore the all modes calibration from the local system */
-int smcube_restore_calibration(smcube *p) {
+int static smcube_restore_calibration(smcube *p) {
int ev = SMCUBE_OK;
int i, j;
char fname[100]; /* Name */
@@ -2169,7 +2176,7 @@ int smcube_restore_calibration(smcube *p) {
return ev;
}
-int smcube_touch_calibration(smcube *p) {
+int static smcube_touch_calibration(smcube *p) {
int ev = SMCUBE_OK;
char fname[100]; /* Name */
int rv;
diff --git a/spectro/smcube.h b/spectro/smcube.h
index 7283635..7283635 100644..100755
--- a/spectro/smcube.h
+++ b/spectro/smcube.h
diff --git a/spectro/spec2cie.c b/spectro/spec2cie.c
index aa91ebb..322ab05 100644..100755
--- a/spectro/spec2cie.c
+++ b/spectro/spec2cie.c
@@ -389,7 +389,7 @@ main(int argc, char *argv[])
if (illum == icxIT_none)
illum = icxIT_D50;
- if (observ = icxOT_none)
+ if (observ == icxOT_none)
observ = icxOT_CIE_1931_2;
/* Figure out what sort of device it is */
diff --git a/spectro/specbos.c b/spectro/specbos.c
index e819c06..491fe97 100644..100755
--- a/spectro/specbos.c
+++ b/spectro/specbos.c
@@ -1434,6 +1434,7 @@ specbos_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
amutex_del(p->lock);
+ p->vdel(pp);
free(p);
}
}
diff --git a/spectro/specbos.h b/spectro/specbos.h
index e926c42..e926c42 100644..100755
--- a/spectro/specbos.h
+++ b/spectro/specbos.h
diff --git a/spectro/spotread.c b/spectro/spotread.c
index baf1c76..baf1c76 100644..100755
--- a/spectro/spotread.c
+++ b/spectro/spotread.c
diff --git a/spectro/spyd2.c b/spectro/spyd2.c
index b546f6b..6833e89 100644..100755
--- a/spectro/spyd2.c
+++ b/spectro/spyd2.c
@@ -642,12 +642,13 @@ spyd2_GetReading_ll(
int value;
int index;
int flag;
- int nords, retr;
+ int retr;
unsigned char buf1[8]; /* send bytes */
unsigned char buf2[9 * 8]; /* return bytes read */
int rvals[3][8]; /* Raw values */
int _maxtcnt = 0; /* Maximum transition count */
int _mintcnt = 0x7fffffff; /* Minumum transition count */
+ double maxfreq = 0.0; /* Maximum sensor frequency found */
int i, j, k;
a1logd(p->log, 3, "spyd2_GetReading_ll: clocks = %d, minfc = %d, maxfc = %d\n",*clocks,*minfclks,*maxfclks);
@@ -691,7 +692,7 @@ spyd2_GetReading_ll(
}
/* The Spyder comms seems especially flakey... */
- for (retr = 0, nords = 1; ; retr++, nords++) {
+ for (retr = 0; ; retr++) {
//int start = msec_time();
@@ -888,13 +889,14 @@ spyd2_GetReading_ll(
} else { /* We discard 0'th L2F transion to give transitions */
/* over the time period. */
if (sensv != NULL)
- sensv[k] = ((double)transcnt - 1.0) * (double)CLKRATE
- / ((double)nords * (double)intclks);
+ sensv[k] = ((double)transcnt - 1.0) * (double)CLKRATE / (double)intclks;
if (transcnt > _maxtcnt)
_maxtcnt = transcnt;
if (transcnt < _mintcnt)
_mintcnt = transcnt;
}
+ if (sensv != NULL && sensv[k] > maxfreq)
+ maxfreq = sensv[k];
if (p->log->debug >= 4 && sensv != NULL)
a1logd(p->log, 4, "%d: initial senv %f from transcnt %d and intclls %d\n",
k,sensv[k],transcnt,intclks);
@@ -967,6 +969,8 @@ spyd2_GetReading_ll(
if (transcnt < _mintcnt)
_mintcnt = transcnt;
}
+ if (sensv != NULL && (8.125 * sensv[k]) > maxfreq)
+ maxfreq = 8.125 * sensv[k];
if (p->log->debug >= 4 && sensv != NULL)
a1logd(p->log, 4, "%d: initial senv %f from transcnt %d and intclls %d\n",
k,sensv[k],transcnt,intclks);
@@ -978,6 +982,16 @@ spyd2_GetReading_ll(
if (mintcnt != NULL)
*mintcnt = _mintcnt;
+ if (p->log->debug >= 4 && sensv != NULL)
+ a1logd(p->log, 4, "Maximum sensor frequency = %f\n",maxfreq);
+
+ /* Problem is that the HW starts loosing count above a certain */
+ /* frequency, so we depend on one less bright sensor acting as a canary, */
+ /* so we can't make the threshold too low. */
+ if (maxfreq > 500000.0) {
+ return spyd2_interp_code((inst *)p, SPYD2_TOOBRIGHT);
+ }
+
return rv;
}
@@ -2843,7 +2857,7 @@ spyd4_load_cal(spyd2 *p) {
/* Establish communications with a SPYD2 */
/* If it's a serial port, use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return SPYD2_COMS_FAIL on failure to establish communications */
static inst_code
spyd2_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
spyd2 *p = (spyd2 *) pp;
@@ -2866,7 +2880,7 @@ spyd2_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
/* (and Spyder 2 hangs if a reset ep is done on MSWin.) */
/* The spyder 2 doesn't work well with the winusb driver either, */
/* it needs icomuf_resetep_before_read to work at all, and */
- /* gets retries anyway. So we use the libusb0 driver for it. */
+ /* gets retries anyway. So we use the libusb-win32 driver for it. */
#if defined(NT)
if (p->itype == instSpyder3) {
usbflags |= icomuf_resetep_before_read; /* The spyder USB is buggy ? */
@@ -3391,6 +3405,8 @@ spyd2_interp_error(inst *pp, int ec) {
return "Display device selection out of range";
/* User error */
+ case SPYD2_TOOBRIGHT:
+ return "Too bright to read accuractly";
case SPYD2_NO_REFRESH_DET:
return "Unable to detect & measure refresh rate";
@@ -3445,6 +3461,7 @@ spyd2_interp_code(inst *pp, int ec) {
case SPYD2_DISP_SEL_RANGE:
return inst_wrong_setup | ec;
+ case SPYD2_TOOBRIGHT:
case SPYD2_NO_REFRESH_DET:
return inst_misread | ec;
@@ -3461,6 +3478,7 @@ spyd2_del(inst *pp) {
inst_del_disptype_list(p->dtlist, p->ndtlist);
if (p->samples != NULL)
free(p->samples);
+ p->vdel(pp);
free(p);
}
diff --git a/spectro/spyd2.h b/spectro/spyd2.h
index 923234f..0588b9b 100644..100755
--- a/spectro/spyd2.h
+++ b/spectro/spyd2.h
@@ -56,6 +56,7 @@
#define SPYD2_TRIGTIMEOUT 0x04
#define SPYD2_OVERALLTIMEOUT 0x05
#define SPYD2_BAD_EE_CRC 0x06
+#define SPYD2_TOOBRIGHT 0x07
/* Internal software errors */
#define SPYD2_BAD_EE_ADDRESS 0x21
diff --git a/spectro/ss.c b/spectro/ss.c
index 90720ca..837e264 100644..100755
--- a/spectro/ss.c
+++ b/spectro/ss.c
@@ -131,7 +131,7 @@ static void check_calcount(ss *p, int atstart) {
/* Establish communications with a Spectrolino/Spectroscan */
/* Use the baud rate given, and timeout in to secs */
-/* Return DTP_COMS_FAIL on failure to establish communications */
+/* Return SS_COMS_FAIL on failure to establish communications */
static inst_code
ss_init_coms(inst *pp, baud_rate br, flow_control fc, double tout) {
ss *p = (ss *)pp;
@@ -2037,6 +2037,7 @@ ss_del(inst *pp) {
if (p->icom != NULL)
p->icom->del(p->icom);
+ p->vdel(pp);
free (p);
}
diff --git a/spectro/ss.h b/spectro/ss.h
index bff0846..bff0846 100644..100755
--- a/spectro/ss.h
+++ b/spectro/ss.h
diff --git a/spectro/ss_imp.c b/spectro/ss_imp.c
index 6f184b3..6f184b3 100644..100755
--- a/spectro/ss_imp.c
+++ b/spectro/ss_imp.c
diff --git a/spectro/ss_imp.h b/spectro/ss_imp.h
index c298e80..c298e80 100644..100755
--- a/spectro/ss_imp.h
+++ b/spectro/ss_imp.h
diff --git a/spectro/strange.cal b/spectro/strange.cal
index 406fba4..5f2e94d 100644..100755
--- a/spectro/strange.cal
+++ b/spectro/strange.cal
@@ -2,7 +2,7 @@ CAL
DESCRIPTOR "Argyll Device Calibration Curves"
ORIGINATOR "Argyll synthcal"
-CREATED "Mon Sep 07 03:37:56 2015"
+CREATED "Mon Oct 26 01:10:48 2015"
DEVICE_CLASS "DISPLAY"
COLOR_REP "RGB"
diff --git a/spectro/synthcal.c b/spectro/synthcal.c
index 75d18be..75d18be 100644..100755
--- a/spectro/synthcal.c
+++ b/spectro/synthcal.c
diff --git a/spectro/synthread.c b/spectro/synthread.c
index 3a23c31..3a23c31 100644..100755
--- a/spectro/synthread.c
+++ b/spectro/synthread.c
diff --git a/spectro/usbio.c b/spectro/usbio.c
index 668544a..9f8964a 100644..100755
--- a/spectro/usbio.c
+++ b/spectro/usbio.c
@@ -118,7 +118,7 @@ int rwsize, /* Bytes to read or write */
double tout /* Timeout in seconds */
) {
int rv = 0; /* Return value */
- int c, rwbytes; /* Data bytes read or written */
+ int rwbytes; /* Data bytes read or written */
long top; /* timeout in msec */
if (p->log->debug >= 8) {
@@ -412,7 +412,7 @@ double tout)
/* Until data is all written, we time out, or the user aborts */
for (top = ttop; top > 0 && len > 0;) {
- int c, rv;
+ int rv;
a1logd(p->log, 8, "icoms_usb_ser_write: attempting to write %d bytes to usb top = %d\n",len,top);
rv = icoms_usb_transaction(p, NULL, &wbytes, type, (unsigned char)ep, (unsigned char *)wbuf, len, top);
diff --git a/spectro/usbio.h b/spectro/usbio.h
index 578bd83..578bd83 100644..100755
--- a/spectro/usbio.h
+++ b/spectro/usbio.h
diff --git a/spectro/usbio_bsd.c b/spectro/usbio_bsd.c
index 0af13a1..0af13a1 100644..100755
--- a/spectro/usbio_bsd.c
+++ b/spectro/usbio_bsd.c
diff --git a/spectro/usbio_lx.c b/spectro/usbio_lx.c
index cb9ec59..cb9ec59 100644..100755
--- a/spectro/usbio_lx.c
+++ b/spectro/usbio_lx.c
diff --git a/spectro/usbio_nt.c b/spectro/usbio_nt.c
index 8daac0d..f5c3af8 100644..100755
--- a/spectro/usbio_nt.c
+++ b/spectro/usbio_nt.c
@@ -567,7 +567,7 @@ char **pnames /* List of process names to try and kill before opening */
/* -------------------------------------------------------------- */
-/* Our universal USB transfer function */
+/* Our universal USB transfer function, used for rd/wr. */
/* It appears that we may return a timeout with valid characters. */
static int icoms_usb_transaction(
icoms *p,
diff --git a/spectro/usbio_ox.c b/spectro/usbio_ox.c
index d3da59a..d3da59a 100644..100755
--- a/spectro/usbio_ox.c
+++ b/spectro/usbio_ox.c
diff --git a/spectro/vinflate.c b/spectro/vinflate.c
index 847fa28..847fa28 100644..100755
--- a/spectro/vinflate.c
+++ b/spectro/vinflate.c
diff --git a/spectro/webwin.c b/spectro/webwin.c
index e13981a..e13981a 100644..100755
--- a/spectro/webwin.c
+++ b/spectro/webwin.c
diff --git a/spectro/webwin.h b/spectro/webwin.h
index 1f4412a..1f4412a 100644..100755
--- a/spectro/webwin.h
+++ b/spectro/webwin.h
diff --git a/spectro/xdg_bds.c b/spectro/xdg_bds.c
index c1805ed..c1805ed 100644..100755
--- a/spectro/xdg_bds.c
+++ b/spectro/xdg_bds.c
diff --git a/spectro/xdg_bds.h b/spectro/xdg_bds.h
index 5c29790..5c29790 100644..100755
--- a/spectro/xdg_bds.h
+++ b/spectro/xdg_bds.h