Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 20552)
+++ trunk/psModules/src/config/pmConfig.c	(revision 20639)
@@ -1081,6 +1081,6 @@
 // camera.  If we are discovering the camera (config->camera == NULL), then we also load the
 // recipe files for the camera.
-psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *formatName, pmConfig *config,
-                                           const psMetadata *header, bool readRecipes)
+psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 
+					   pmConfig *config, const psMetadata *header, bool readRecipes)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -1089,5 +1089,5 @@
     bool status = false;                // error status
     psMetadata *format = NULL;          // The winning format
-    psString name = NULL;               // Name of the winning format
+    psString testFormatName = NULL;         // Name of the winning format
 
     // If we don't know what sort of camera we have, we try all that we know
@@ -1118,8 +1118,8 @@
             assert(camerasItem->type == PS_DATA_METADATA); // It should be because we've read it in or deleted
             psMetadata *testCamera = camerasItem->data.md; // Camera to test against what we've got:
-            if (formatFromHeader(&status, &format, &name, testCamera, header, camerasItem->name)) {
+            if (formatFromHeader(&status, &format, &testFormatName, testCamera, header, camerasItem->name)) {
                 config->camera = psMemIncrRefCounter(testCamera);
                 config->cameraName = psStringCopy(camerasItem->name);
-                config->formatName = name;
+                config->formatName = testFormatName;
                 config->format = format;
                 if (camera) {
@@ -1127,5 +1127,8 @@
                 }
                 if (formatName) {
-                    *formatName = psMemIncrRefCounter(name);    // view on value saved on config
+                    *formatName = psMemIncrRefCounter(testFormatName);    // view on value saved on config
+                }
+                if (cameraName) {
+                    *cameraName = psMemIncrRefCounter(config->cameraName);    // view on value saved on config
                 }
             } else {
@@ -1166,5 +1169,5 @@
 
     psMetadata *testCamera = NULL;
-    char *testName = NULL;
+    char *testCameraName = NULL;
 
     psMetadata *cameras = psMetadataLookupMetadata (NULL, config->system, "CAMERAS");
@@ -1173,50 +1176,50 @@
     // try the FPA metaCamera
     if (!found) {
-        testName = NULL;
-        psStringAppend (&testName, "_%s-FPA", baseName);
-
-        testCamera = psMetadataLookupMetadata (NULL, cameras, testName);
-        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testName);
+        testCameraName = NULL;
+        psStringAppend (&testCameraName, "_%s-FPA", baseName);
+
+        testCamera = psMetadataLookupMetadata (NULL, cameras, testCameraName);
+        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testCameraName);
 
         bool status;
-        found = formatFromHeader(&status, &format, &name, testCamera, header, testName);
-        if (!found) psFree (testName);
+        found = formatFromHeader(&status, &format, &testFormatName, testCamera, header, testCameraName);
+        if (!found) psFree (testCameraName);
     }
 
     // try the CHIP metaCamera
     if (!found) {
-        testName = NULL;
-        psStringAppend (&testName, "_%s-CHIP", baseName);
-
-        testCamera = psMetadataLookupMetadata (NULL, cameras, testName);
-        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testName);
+        testCameraName = NULL;
+        psStringAppend (&testCameraName, "_%s-CHIP", baseName);
+
+        testCamera = psMetadataLookupMetadata (NULL, cameras, testCameraName);
+        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testCameraName);
 
         bool status;
-        found = formatFromHeader(&status, &format, &name, testCamera, header, testName);
-        if (!found) psFree (testName);
+        found = formatFromHeader(&status, &format, &testFormatName, testCamera, header, testCameraName);
+        if (!found) psFree (testCameraName);
     }
 
     // try the SKYCELL metaCamera
     if (!found) {
-        testName = NULL;
-        psStringAppend (&testName, "_%s-SKYCELL", baseName);
-
-        testCamera = psMetadataLookupMetadata (NULL, cameras, testName);
-        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testName);
+        testCameraName = NULL;
+        psStringAppend (&testCameraName, "_%s-SKYCELL", baseName);
+
+        testCamera = psMetadataLookupMetadata (NULL, cameras, testCameraName);
+        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testCameraName);
 
         bool status;
-        found = formatFromHeader(&status, &format, &name, testCamera, header, testName);
-        if (!found) psFree (testName);
+        found = formatFromHeader(&status, &format, &testFormatName, testCamera, header, testCameraName);
+        if (!found) psFree (testCameraName);
     }
 
     // try the base name
     if (!found) {
-        testName = psMemIncrRefCounter (baseName);
-
-        testCamera = psMetadataLookupMetadata (NULL, cameras, testName);
-        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testName);
+        testCameraName = psMemIncrRefCounter (baseName);
+
+        testCamera = psMetadataLookupMetadata (NULL, cameras, testCameraName);
+        psAssert (testCamera, "missing %s in CAMERAS in complete metadata", testCameraName);
 
         bool status;
-        found = formatFromHeader(&status, &format, &name, testCamera, header, testName);
+        found = formatFromHeader(&status, &format, &testFormatName, testCamera, header, testCameraName);
     }
 
@@ -1228,12 +1231,16 @@
     }
 
-    psFree (name); // winning format name (for metaCamera) returned by formatFromHeader
-
     psFree (baseName);
     if (formatName) {
-        *formatName = testName;
+        *formatName = testFormatName;
     } else {
-        psFree (testName);
-    }
+        psFree (testFormatName);
+    }
+    if (cameraName) {
+        *cameraName = testCameraName;
+    } else {
+        psFree (testCameraName);
+    }
+
     if (camera) {
         *camera = psMemIncrRefCounter(testCamera);
