Index: vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp
===================================================================
--- vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp	(revision 389)
+++ vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp	(revision 390)
@@ -44,4 +44,5 @@
     SML_present = false;
     commandSocketFD = -1;
+    srand ( time(NULL) );
 }
 
@@ -274,21 +275,12 @@
             LOG("Cognitive Engine:: Processing parameters....\n");
 
-            Parameter *solutionSet;
-            
-            //solutionSet = GetSolution(o,cp);
-
             // TODO need to actually do something with the observables here
            
             LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
             char numParametersChar[10];
-            char solutionValue[50];
             sprintf(numParametersChar, "%i", radioInfo->numParameters);
             SendMessage(commandSocketFD, numParametersChar);
             for(size_t i = 0; i < radioInfo->numParameters; i++) {
-                //SendMessage(commandSocketFD, solutionSet[i].name.c_str());
 		SendMessage(commandSocketFD, "test");
-                //memset(solutionValue, 0, 50);
-                //sprintf(solutionValue, "%f", solutionSet[i].value);
-                //SendMessage(commandSocketFD, solutionValue);
 		SendMessage(commandSocketFD, "00");
             }
@@ -649,30 +641,15 @@
     /* Put together the CBR search array */
 
-    char *searchNames[radioInfo->numUtilities + 1];
-    float searchVals[radioInfo->numUtilities + 1];
-    int searchOps[radioInfo->numUtilities + 1];
+    char *searchNames[1];
+    float searchVals[1];
+    int searchOps[1];
     uint32_t numberColumns = radioInfo->numUtilities +
         			radioInfo->numParameters +
         			radioInfo->numObservables + 1;
 
-    for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-        searchNames[i] = (char*)uList[i].name.c_str();
-        
-        if(strcmp(uList[i].goal.c_str(), "max") == 0) {
-            searchOps[i] = GT;
-        } else if(strcmp(uList[i].goal.c_str(), "min") == 0) {
-            searchOps[i] = LT;
-        }
-   
-	/* Set search target to utility target */
-	/* This may be bad if no target is set */ 
-        searchVals[i] = uList[i].target;
-    }
-   
-
     /* Make sure we do not return any entries for the current channel */
-    searchNames[radioInfo->numUtilities+1] = "channel";
-    searchOps[radioInfo->numUtilities+1] = NE;
-    searchVals[radioInfo->numUtilities+1] = currentParameters[0].value; 
+    searchNames[0] = "channel";
+    searchOps[0] = NE;
+    searchVals[0] = currentParameters[0].value; 
  
     float returnValues[numberColumns];
@@ -680,5 +657,5 @@
     /* Execute CBR search and put output into returnValues */
     uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals,
-            radioInfo->numUtilities, returnValues);
+            1, returnValues);
 
     if(rc == 0){
@@ -688,14 +665,11 @@
         LOG("Cognitive Engine:: Previous similar environment found\n");
 
+  	/* generate random channel */
+	returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 
+        
         if(returnValues[numberColumns-1] < 0) {
-        
-            returnValues[2] = returnValues[2] - 15;
-            returnValues[3] = returnValues[3] - 2;
         
         } else {
        
-            returnValues[2] = returnValues[2] + 15;
-            returnValues[3] = returnValues[3] + 2;
-        
         }
     } else if(rc == 31337) {
@@ -703,15 +677,6 @@
         LOG("Cognitive Engine:: No previous similar environment found.\n");
      
-	/* In the DSA case, the default is to select a random channel */
- 
-  	/* initialize random seed: */
-  	srand ( time(NULL) );
-
   	/* generate random channel */
-	//returnValues[CHANNEL] = rand() % currentParameters[0].max + currentParameters[0].min; 
-	returnValues[CHANNEL] = rand() % 5; 
-       
-	printf("One: %i Two: %i\n",(int)currentParameters[0].max,(int)currentParameters[0].min);
- 
+	returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 
     } else {
         LOG("Cognitive Engine:: Search return an invalid value.\n");
Index: vtcross/trunk/src/cognitive_engines/DSA_CE/cbr.c
===================================================================
--- vtcross/trunk/src/cognitive_engines/DSA_CE/cbr.c	(revision 389)
+++ vtcross/trunk/src/cognitive_engines/DSA_CE/cbr.c	(revision 390)
@@ -202,5 +202,4 @@
     unsigned int i;
     char str_buffer[64];
-    printf("number of ops %d:\n", _n);
     for (i=0; i<_n; i++) {
         // ensure valid ops value
@@ -221,5 +220,5 @@
     }
 
-    //printf("search command: %s\n", _cbr->command);
+    printf("search command: %s\n", _cbr->command);
 
     rc = ExecuteSearchCommand(_cbr, _retvals);
Index: vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples/dsa.py
===================================================================
--- vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples/dsa.py	(revision 389)
+++ vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples/dsa.py	(revision 390)
@@ -47,5 +47,20 @@
     	def send_pkt(self, payload='', eof=False):
         	return self.txpath.send_pkt(payload, eof)
-	
+
+	def get_real_channel(channel):
+
+		real_channel = 1;
+
+		if channel == 1:
+			real_channel = 1
+		if channel == 2:
+			real_channel = 7
+		if channel == 3:
+			real_channel = 8
+		if channel == 4:
+			real_channel = 14
+
+		return real_channel
+
 	def get_freq(hop_freq,probe_level,absent_time):
 
@@ -55,9 +70,9 @@
 			channel = 1
 		if hop_freq == 462712500:
-			channel = 7
+			channel = 2
 		if hop_freq == 467562500:
-			channel = 8
+			channel = 3
 		if hop_freq == 467712500:
-			channel = 14
+			channel = 4
 
 		p = Parameter(1)
@@ -72,6 +87,8 @@
 
 		p = GetOptimalParameters(o,1,currentParameters,1);
-		print p[0].name, p[0].value
-	
+		print p[0].value
+		
+		channel = get_real_channel(int(p[0].value))
+
 		if channel < 8:
 			hop_freq = float(1e6 * (462.5625+(channel-1)*0.025))#setting the centre freq frequency for sending packets
@@ -153,5 +170,5 @@
                       	help="use file for packet contents")
     	
-    	transmit_path.add_options(parser_tx, expert_grp_tx)
+        transmit_path.add_options(parser_tx, expert_grp_tx)
 
     	for mod in mods.values():
@@ -228,5 +245,9 @@
     	ch_energy = tb.rxpath.probe.level() #setting initial value
 	hop_freq = options_tx.tx_freq #  = options_rx.rx_freq...same for tx and rx side
-   	while running:
+   	
+
+	# Scan all channels first for inital data
+
+	while running:
 
 		################################################sync mode####################################
