Index: trunk/psModules/src/camera/pmFPAConstruct.c
===================================================================
--- trunk/psModules/src/camera/pmFPAConstruct.c	(revision 15931)
+++ trunk/psModules/src/camera/pmFPAConstruct.c	(revision 15940)
@@ -66,15 +66,17 @@
 
     psList *values = psStringSplit(string, " ,;", true); // List of the parts
-
-    if (first) {
-        *first = psArrayAlloc(values->n);
-    }
-    if (second) {
-        *second = psArrayAlloc(values->n);
-    }
-    if (third) {
-        *third = psArrayAlloc(values->n);
-    }
-    int num = 0;
+    int num = values->n; // number of parsed content elements
+
+    // extend the arrays if they exist, create new ones if they don't
+    if (first && !*first) {
+        *first = psArrayAllocEmpty(values->n);
+    }
+    if (second && !*second) {
+        *second = psArrayAllocEmpty(values->n);
+    }
+    if (third && !*third) {
+        *third = psArrayAllocEmpty(values->n);
+    }
+
     psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
     psString value = NULL;               // "first:second:third" string
@@ -83,14 +85,13 @@
         switch (numArrays) {
           case 3:
-            psArraySet(*third, num, fst->data[2]);
+            psArrayAdd(*third, 8, fst->data[2]);
           case 2:
-            psArraySet(*second, num, fst->data[1]);
+            psArrayAdd(*second, 8, fst->data[1]);
           case 1:
-            psArraySet(*first, num, fst->data[0]);
+            psArrayAdd(*first, 8, fst->data[0]);
             break;
         default:
           psAbort("Should never get here.");
         }
-        num++;
         psFree(fst);
     }
@@ -395,10 +396,10 @@
 // Process a chip, using the cellName:cellType pair
 static bool processChip(const psMetadata *format, // Camera format
-                        const char *chipContents, // Contents of chip, cellName:cellType pairs
+                        const psMetadataItem *chipContents, // Contents of chip, cellName:cellType pairs (either in a string or a metadata)
                         pmFPA *fpa, // FPA of interest
                         pmChip *chip, // Chip of interest
                         pmFPALevel level, // Level for HDU to go
                         pmHDU *hdu      // HDU to add
-                        )
+    )
 {
     assert(format);
@@ -414,11 +415,37 @@
     psArray *cellNames = NULL;      // Cell names
     psArray *cellTypes = NULL;      // Cell types
-    if (parseContent(&cellNames, &cellTypes, NULL, chipContents) == 0) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
-                "Unable to parse chip contents (within %s in camera format) as cellName:cellType",
-                CHIP_TYPES);
-        psFree(cellNames);
-        psFree(cellTypes);
-        return false;
+    
+    int nParsed = 0;
+
+    switch (chipContents->type) {
+      case PS_DATA_STRING: {
+	  nParsed = parseContent(&cellNames, &cellTypes, NULL, chipContents->data.str);
+	  break;
+      }
+      case PS_DATA_METADATA: {
+	  psMetadataIterator *iter = psMetadataIteratorAlloc(chipContents->data.md, PS_LIST_HEAD, NULL); // Iterator
+	  psMetadataItem *item;           // Item from iteration
+	  while ((item = psMetadataGetAndIncrement(iter))) {
+	      if (item->type != PS_DATA_STRING) {
+		  psWarning ("Item %s in camera format chip table is not of type STR.", item->name);
+		  continue;
+	      }
+	      nParsed += parseContent(&cellNames, &cellTypes, NULL, item->data.str);
+	  }
+	  psFree (iter);
+	  break;
+      }
+      default:
+	psWarning ("Item %s in camera format chip table is not of type STR.", chipContents->name);
+	break;
+    }
+
+    if (nParsed == 0) {
+	psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+		"Unable to parse chip contents (within %s in camera format) as cellName:cellType",
+		CHIP_TYPES);
+	psFree(cellNames);
+	psFree(cellTypes);
+	return false;
     }
 
@@ -552,5 +579,5 @@
         pmChip *chip = fpa->chips->data[chipNum]; // Chip of interest
 
-        const char *chipContents = psMetadataLookupStr(NULL, chips, chipType); // Contents of chip
+        const psMetadataItem *chipContents = psMetadataLookup(chips, chipType); // Contents of chip
         psFree(chipType);
         if (!chipContents) {
@@ -775,19 +802,10 @@
     psMetadataItem *contentItem;        // Content, from iteration
     while ((contentItem = psMetadataGetAndIncrement(contentsIter))) {
-        if (contentItem->type != PS_DATA_STRING) {
-            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                    "Type for %s (%x) in %s METADATA in camera format is not STR",
-                    contentItem->name, contentItem->type, TABLE_OF_CONTENTS);
-            psFree(contentsIter);
-            return false;
-        }
-
-        const char *extname = contentItem->name; // Extension name
-        pmHDU *hdu = pmHDUAlloc(extname); // HDU for this extension
+        pmHDU *hdu = pmHDUAlloc(contentItem->name); // HDU for this extension
         // Casting to avoid "warning: passing arg 1 of `p_psMemIncrRefCounter' discards qualifiers from
         // pointer target type"
         hdu->format = psMemIncrRefCounter((const psPtr)format);
 
-        if (!processChip(format, contentItem->data.str, fpa, chip, PM_FPA_LEVEL_CELL, hdu)) {
+        if (!processChip(format, contentItem, fpa, chip, PM_FPA_LEVEL_CELL, hdu)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to process chip\n");
             psFree(hdu);
@@ -871,5 +889,5 @@
 
     // What's in the chip?
-    psString chipContents = psMetadataLookupStr(NULL, chips, chipType); // Contents of the chip
+    psMetadataItem *chipContents = psMetadataLookup(chips, chipType); // Contents of the chip
     if (!chipContents) {
         psError(PS_ERR_UNEXPECTED_NULL, false,
