[argyllcms] My DTP-22 speaks a different dialect

  • From: Nigel Rowe <argy@xxxxxxxxxxxxx>
  • To: argyllcms@xxxxxxxxxxxxx
  • Date: Fri, 21 Dec 2007 19:20:53 +1100

Greetings all.

I have a DTP-22 that is labeled on top as

X-RiteColor(r)
Digital Swatchbook

and on the underside as

Model  DTP22

When I tried to use it with spotread I got

$ spotread -v -c2 -s
Connecting to the instrument ..
  Instrument Type:       DTP22
  Serial Number:          ****
  OEM Serial #:            000
  Cal Plaque Serial #:    ****
  BOOT version:           5B15-H
  Software version:       6905
Init instrument success !

Spot read needs a calibration before continuing
Click the instrument on its reflective white reference Serial no. ****,
 or hit Esc, ^C or Q to abort:
Calibration complete

Place instrument on spot to be measured,
and hit [A-Z] to read white and setup FWA compensation (keyed to letter)
[a-z] to read and make FWA compensated reading from keyed reference
'r' to take previous reading as the reference
Hit ESC, ^C or Q to exit, instrument switch or any other key to take a 
reading:


Got fatal error 'Communication protocol breakdown' (No error)

Hmmmm.... a fatal no error????

Further investigation showed the code expected the read data in the form
(line breaks added for clarity).

 X 12.34 Y 23.45 Z 34.56
 S 45.67
 S 56.78
etc.

While mine produced data in the form

 X 12.34 Y 23.45 Z 34.56
SPECTRAL DATA
w 400.0 S 45.67
w 410.0 S 56.78
etc.

Assuming (yes, I know) the presence of line "SPECTRAL DATA" is 
sufficient to distinguish between the dialects, I offer the attached 
patch.  It should cope with both dialects.  I have no way of testing 
both, but it works for me.  (Also fixes a typo in spotread.c)


-- 
    Nigel Rowe
    argy \N{COMMERCIAL AT} fisheggs \N{FULL STOP} name
--- ./spectro/dtp22.c.orig      2007-10-20 11:54:01.000000000 +1000
+++ ./spectro/dtp22.c   2007-12-21 19:02:16.000000000 +1100
@@ -517,13 +517,22 @@
 
        if (p->mode & inst_mode_spectral) {
                int j;
-       
+               char *spec_fmt = "Unknown dialect";
+
                /* Reset tp to point to start of spectral */
                tp = buf + strlen(buf) + 1;
 
+               /* Different dialects spoken by DTP-22 */
+               if (strcmp(tp, "SPECTRAL DATA") == 0 ) {
+                       tp += strlen(tp) + 1;
+                       spec_fmt = " w %*lf S %lf ";
+               } else {
+                       spec_fmt = " S %lf ";
+               }
+
                /* Read the spectral value */
                for (j = 0; j < 31; j++) {
-                       if (sscanf(tp, " S %lf ", &val->sp.spec[j]) != 1)
+                       if (sscanf(tp, spec_fmt, &val->sp.spec[j]) != 1)
                                return inst_protocol_error;
                        tp += strlen(tp) + 1;
                }
--- ./spectro/spotread.c.orig   2007-10-20 11:54:02.000000000 +1000
+++ ./spectro/spotread.c        2007-12-21 19:15:07.000000000 +1100
@@ -1116,7 +1116,7 @@
                                sp2cief[fidx]->sconvert(sp2cief[fidx], &tsp, 
NULL, &tsp);
                        }
 
-                       printf("Spectrum from %f yp %f nm in %d steps\n",
+                       printf("Spectrum from %f to %f nm in %d steps\n",
                                tsp.spec_wl_short, tsp.spec_wl_long, 
tsp.spec_n);
 
                        for (j = 0; j < tsp.spec_n; j++)

Other related posts: