Index: /trunk/ippTools/src/chiptool.c
===================================================================
--- /trunk/ippTools/src/chiptool.c	(revision 6134)
+++ /trunk/ippTools/src/chiptool.c	(revision 6135)
@@ -4,5 +4,5 @@
 
 int main(int argc, char **argv) {
-    p2Config        config;
+    p2Config        config; 
 
     p2searchConfig(&config, argc, argv);
@@ -35,4 +35,54 @@
                 exit(EXIT_FAILURE);
             }
+            psArray *pendingFrames = p2searchPendingFrames(&config);
+            // XXX compare raw frames to pending frames and remove duplicate 
+            // frames from the raw set.  This may not be quiet right as it's
+            // possible (likely?) that a rawScienceExp is inserted into the
+            // database prior to /ALL/ of that exposure's Imfiles
+            if (pendingFrames) {
+                for (int i = 0; i < rawFrames->n; i++) {
+                    ppRawFrame *rawFrame = rawFrames->data[i];
+                    for (int j = 0; j < pendingFrames->n; j++) {
+                        p2PendingFrame *pendingFrame = pendingFrames->data[j];
+                        if (strcmp(rawFrame->exposure->exp_id,
+                                   pendingFrame->exposure->exp_id) == 0) {
+                            psArrayRemove(rawFrames, rawFrame);
+                            // dec the counter as the array just got shorter
+                            // and we don't want to skip elemnts
+                            i--;
+                            break;
+                        } 
+                    }
+                }
+
+                psFree(pendingFrames);
+            }
+
+            psArray *doneFrames = p2searchDoneFrames(&config);
+            if (doneFrames && (rawFrames->n > 0)) {
+                for (int i = 0; i < rawFrames->n; i++) {
+                    ppRawFrame *rawFrame = rawFrames->data[i];
+                    for (int j = 0; j < pendingFrames->n; j++) {
+                        p2DoneFrame *doneFrame = pendingFrames->data[j];
+                        if (strcmp(rawFrame->exposure->exp_id,
+                                   doneFrame->exposure->exp_id) == 0) {
+                            psArrayRemove(rawFrames, rawFrame);
+                            // dec the counter as the array just got shorter
+                            // and we don't want to skip elemnts
+                            i--;
+                            break;
+                        } 
+                    }
+                }
+
+                psFree(doneFrames);
+            }
+
+            if (!rawFrames->n > 0) {
+                psError(PS_ERR_UNKNOWN, false, "no unprocessed ppRawFrames found");
+                psFree(rawFrames);
+                exit(EXIT_FAILURE);
+            }
+
             bool status = p2insertPendingFrames(&config, rawFrames);
             if (!status) {
