Help with :CAT optical Reader

From: Sean 'Captain Napalm' Conner <spc_at_conman.org>
Date: Wed Jul 14 16:45:59 2004

It was thus said that the Great Philip Pemberton once stated:
>
> In message <009b01c469a9$fe295e50$30406b43_at_66067007>
> "Keys" <jrkeys_at_concentric.net> wrote:
>
> > I guy told me that the :C optical reader was great for scanning books into
> > your computer, so I got one out of the warehouse and loaded the software
> > that came with it.
> The CueCat (aka :C) is a barcode scanner, not a text scanner. You can scan
> barcodes with it and it dumps the data (in an encoded format) into the
> keyboard buffer.
>
> > Now the problem is I can not get to the company website
> > to get the code to use the software?
> DigitalConvergence went bankrupt a few years ago. The servers that :CRQ used
> to look up barcodes are dead anyway.

  I write some C code (included below---it's quite short) to decode the
Cuecat datastream (tested and works, at least under Linux). I got the thing
(free from RatShack), played around with it for oh, a day or so (that's when
I wrote the software) and then never did anything with the thing afterwards.

  -spc (oh wait ... hold old is the cuecat now?)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>

/*******************************************************************/

char *cuecat_convert(char *dest,size_t size,const char *src)
{
  int t[4];
  unsigned long value;
  char *sdest;
  int i;
  char *p;
  static const char *const convtable = "abcdefghijklmnopqrstuvwxyz"
                                       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                       "0123456789+-";
                                       /*"0123456789,/";*/

  assert(dest != NULL);
  assert(size > 0);
  assert(src != NULL);
  
  sdest = dest;
  
  while((size > 3) && (*src != '.') && (*src != '\0')) /* oops */
  {
    memset(t,0,sizeof(t));
    for (i = 0 ; (*src != '.') && (i < 4) ; i++ , src++)
    {
      p = strchr(convtable,*src);
      if (p == NULL) break;
      t[i] = p - convtable;
      assert(t[i] >= 0);
      assert(t[i] <= 63);
    }
    
    value = (t[0] << 18) | (t[1] << 12) | (t[2] << 6) | (t[3]);
    value ^= 0x00434343ul;
    dest[0] = (value >> 16) & 0x000000FFul;
    dest[1] = (value >> 8) & 0x000000FFul;
    dest[2] = (value) & 0x000000FFul;
    dest[3] = '\0';
    dest += 3;
    size -= 3;
  }
  
  *dest = '\0';
  return(sdest);
}

/***************************************************************/

char *cleanup(char *src)
{
  char *ssrc = src;
  
  assert(src != NULL);
  
  for ( ; *src ; src++)
  {
    if ((*src < 32) || (*src > 126))
      *src = '.';
  }
  return(ssrc);
}

/***************************************************************/

int main(int argc,char *argv[])
{
  char *id;
  char *type;
  char *code;
  char buffer[BUFSIZ];
  char cid [BUFSIZ];
  char ctype [BUFSIZ];
  char ccode [BUFSIZ];
  
  while(fgets(buffer,BUFSIZ,stdin))
  {
    id = strchr(buffer,'.'); if (id == NULL) continue; else id++;
    type = strchr(id, '.'); if (type == NULL) continue; else type++;
    code = strchr(type, '.'); if (code == NULL) continue; else code++;
    
    cleanup(cuecat_convert(cid,BUFSIZ,id));
    cleanup(cuecat_convert(ctype,BUFSIZ,type));
    cleanup(cuecat_convert(ccode,BUFSIZ,code));
    
    printf("ID: %s TYPE: %s CODE: %s\n",cid,ctype,ccode);
  }
  return(0);
}

/*******************************************************************/
Received on Wed Jul 14 2004 - 16:45:59 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:36:51 BST