Common subdirectories: source.orig/.dep and source.new/.dep
Common subdirectories: source.orig/.svn and source.new/.svn
Common subdirectories: source.orig/Doxygen and source.new/Doxygen
Common subdirectories: source.orig/LcdEdit and source.new/LcdEdit
diff -u source.orig/adc.c source.new/adc.c
--- source.orig/adc.c	2011-09-26 20:31:01.000000000 +0200
+++ source.new/adc.c	2011-10-07 20:57:05.000000000 +0200
@@ -74,6 +74,7 @@
 static uint8_t ring_used=1; 
 static int32_t ring_sum [2] = {0,0};
 int16_t ring_average [2] = {0,0};
+int16_t override_adc_temp = 0;
 
 static void shift_ring(void) {
 	ring_pos = (ring_pos+1) % AVERAGE_LEN;
@@ -241,8 +242,17 @@
 		sleep_with_ADC=1;
 		break;
 	case 4: //step 4
-        dummy_adc = ADCW;
-	    sleep_with_ADC=1;
+	    if (override_adc_temp>0)
+	    {
+	        update_ring(TEMP_RING_TYPE,override_adc_temp);
+	        state_ADC=5;
+                shift_ring();
+	    }
+	        else
+            {
+                dummy_adc = ADCW;
+                sleep_with_ADC=1;
+            }
 	    break;
 	case 5: //step 5
         {
diff -u source.orig/adc.h source.new/adc.h
--- source.orig/adc.h	2011-09-26 20:31:01.000000000 +0200
+++ source.new/adc.h	2011-10-07 20:18:20.000000000 +0200
@@ -84,5 +84,5 @@
 extern int16_t ring_difference[];
 extern int16_t ring_buf_temp_avgs [AVGS_BUFFER_LEN];
 extern uint8_t ring_buf_temp_avgs_pos;
-
+extern int16_t override_adc_temp;
 
Common subdirectories: source.orig/bootloader and source.new/bootloader
diff -u source.orig/changes.txt source.new/changes.txt
--- source.orig/changes.txt	2011-09-26 20:31:01.000000000 +0200
+++ source.new/changes.txt	2011-10-07 19:54:07.000000000 +0200
@@ -1,5 +1,10 @@
 version 1.00BETA will be released soon
 
+SVN revision XXX
+   - print free memoroy in debug line
+   - com.c improvment of CLI parser
+   - serial bus mode
+
 SVN revision 103
     - motor stop threshold for calibration / runtime can be different
 
diff -u source.orig/com.c source.new/com.c
--- source.orig/com.c	2011-09-26 20:31:01.000000000 +0200
+++ source.new/com.c	2011-10-07 20:58:17.000000000 +0200
@@ -62,6 +62,8 @@
 static uint8_t rx_buff_in=0;
 static uint8_t rx_buff_out=0;
 
+static uint8_t active_bus_id = 0xff;
+
 /*!
  *******************************************************************************
  *  \brief transmit bytes
@@ -69,12 +71,17 @@
  *  \note
  ******************************************************************************/
 void COM_putchar(char c) {
-	cli();
-	if ((tx_buff_in+1)%TX_BUFF_SIZE!=tx_buff_out) {
+        if (config_raw[0x27] == active_bus_id)
+        {
+            if (c=='\n') COM_putchar('\r');
+            
+            cli();
+	    if ((tx_buff_in+1)%TX_BUFF_SIZE!=tx_buff_out) {
 		tx_buff[tx_buff_in++]=c;
 		tx_buff_in%=TX_BUFF_SIZE;
-	}
-	sei();
+            }
+            sei();
+        }
 }
 
 /*!
@@ -251,6 +258,24 @@
 	COM_flush();
 }
 
+/*!
+ *******************************************************************************
+ *  \brief get free memory (debug)
+ *
+ *  \note http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1270998685
+ ******************************************************************************/
+int free_mem() {
+    uint8_t *heapptr;
+    uint8_t *stackptr;
+        
+    stackptr = (uint8_t *)malloc(4);   // use stackptr temporarily
+    heapptr = stackptr;		    // save value of heap pointer
+    free(stackptr);			  // free up the memory again (sets stackptr to 0)
+    stackptr =  (uint8_t *)(SP);	 // save value of stack pointer
+                        
+    return (int)stackptr - (int) heapptr;
+}
+
 
 /*!
  *******************************************************************************
@@ -301,45 +326,16 @@
 	if (mode_window()) {
 		print_s_p(PSTR(" W"));
 	}
+#if DEBUG_MEMORY
+    print_s_p(PSTR(" M: "));
+    print_decXXXX(free_mem());
+#endif
 	COM_putchar('\n');
 	COM_flush();
 }
 
-/*! 
-    \note dirty trick with shared array for \ref COM_hex_parse and \ref COM_commad_parse
-    code size optimalization
-*/
-static uint8_t com_hex[3];
- 
+static        uint8_t com_hex[3];
 
-/*!
- *******************************************************************************
- *  \brief parse hex number (helper function)
- *
- *	\note hex numbers use ONLY lowcase chars, upcase is reserved for commands
- *	
- ******************************************************************************/
-static char COM_hex_parse (uint8_t n) {
-	uint8_t i;
-	for (i=0;i<n;i++) {
-    	uint8_t c = COM_getchar()-'0';
-    	if ( c>9 ) {  // chars < '0' overload var c
-			if ((c>=('a'-'0')) && (c<=('f'-'0'))) {
-    			c-= (('a'-'0')-10);
-			} else return c+'0';
-		}
-    	if (i&1) {
-    	   com_hex[i>>1]+=c;
-        } else {
-    	   com_hex[i>>1]=(uint8_t)c<<4;
-        }
-    }
-	{
-		char c;
-    	if ((c=COM_getchar())!='\n') return c;
-	}
-	return '\0';
-}
 
 /*!
  *******************************************************************************
@@ -375,103 +371,153 @@
  *  \note   Hhhmmss\n - set, hour hh, minute mm, second ss; HEX values!!!
  *  \note   Axx\n - set wanted temperature [unit 0.5C]
  *  \note   Mxx\n - set mode to 0=manu 1=auto
+ *  \note   Ixx\n - activate bus ID 01..1f 0xff=single mode
+ *  \note   Oxxxx\n - set messured temperature , >0000 = disable messurement
  *	
  ******************************************************************************/
+static        uint8_t com_hex[3];
 void COM_commad_parse (void) {
-	char c;
-	while (COM_requests) {
-        switch(c=COM_getchar()) {
-		case 'V':
-			if (COM_getchar()=='\n') print_version();
-			c='\0';
-			break;
-		case 'D':
-			if (COM_getchar()=='\n') COM_print_debug(-1);
-			c='\0';
-			break;
-		case 'T':
+
+        uint8_t com_hex_len = 0;
+
+        while (COM_requests)
+        {
+            // Read command
+            char command = COM_getchar();
+            // Command?
+            if ( (command>='A') && (command<='Z') )
+            {
+                // Read 6 hex characters
+                for (uint8_t i=0;i<6;i++)
+                {
+                    uint8_t c = COM_getchar();
+                    if (c=='\n') break;
+                    
+                    c=c-'0';
+                    if ( c>9 )
+                    {  // chars < '0' overload var c
+			if ((c>=('a'-'0')) && (c<=('f'-'0')))
+			{
+    			    c-= (('a'-'0')-10);
+                        } else c=0;
+                    }
+
+                    if (i&1)
+                    {
+                        com_hex[i>>1]+=c;
+                    }
+                        else
+                    {
+                        com_hex[i>>1]=(uint8_t)c<<4;
+                    }
+                    
+                    com_hex_len = i+1;
+                }
+                
+                if ( (command=='I') || (config_raw[0x27] == active_bus_id ) )
+                switch(command)
+                {
+                    // V print version information
+                    case 'V':
+                        print_version();
+                        break;
+                    // D - print status line
+                    case 'D':
+                        COM_print_debug(-1);
+                        break;
+                    // Taa - print watched variable aa (return 2 or 4 hex numbers) see to \ref watch.c
+                    case 'T':
+                        if (com_hex_len!=2) { break; }
+                        print_idx(command);
+  			print_hexXXXX(watch(com_hex[0]));
+                        break;
+                    //Gaa - get configuration byte with hex address aa see to \ref eeprom.h 0xff address returns EEPROM layout version
+                    case 'G':
+                        if (com_hex_len!=2) { break; }
+                    //Saadd - set configuration byte aa to value dd (hex)
+                    case 'S':
+                        if ( (command=='S') && (com_hex_len!=4) ) { break; }
+                        print_idx(command);
+			if (com_hex[0]<CONFIG_RAW_SIZE)
+			{
+			        if (command=='S')
+			        {
+       					config_raw[com_hex[0]]=(uint8_t)(com_hex[1]);
+       					eeprom_config_save(com_hex[0]);
+                                }
+                                print_hexXX(config_raw[com_hex[0]]);
+                        }
+  			  else
+                        {
+                                print_hexXX(EE_LAYOUT);
+                        }
+                        break;
+                    // Rab - get timer for day a slot b, return cddd=(timermode c time ddd) (hex)
+                    case 'R':
+                        if (com_hex_len!=2) { break; }
+                    // Wabcddd - set timer  for day a slot b timermode c time ddd (hex)
+                    case 'W':
+                        if ( (command=='W') && (com_hex_len!=6) ) { break; }
+                        print_idx(command);
+			if (command=='W')
 			{
-				if (COM_hex_parse(1*2)!='\0') { break; }
-                print_idx(c);
-  				print_hexXXXX(watch(com_hex[0]));
-			}
-			break;
-		case 'G':
-		case 'S':
-			if (c=='G') {
-				if (COM_hex_parse(1*2)!='\0') { break; }
-			} else {
-				if (COM_hex_parse(2*2)!='\0') { break; }
-  				if (com_hex[0]<CONFIG_RAW_SIZE) {
-  					config_raw[com_hex[0]]=(uint8_t)(com_hex[1]);
-  					eeprom_config_save(com_hex[0]);
-  				}
-			}
-            print_idx(c);
-			if (com_hex[0]==0xff) {
-			     print_hexXX(EE_LAYOUT);
-            } else {
-			     print_hexXX(config_raw[com_hex[0]]);
-			}
-			break;
-		case 'R':
-		case 'W':
-			if (c=='R') {
-				if (COM_hex_parse(1*2)!='\0') { break; }
-			} else {
-				if (COM_hex_parse(3*2)!='\0') { break; }
   				RTC_DowTimerSet(com_hex[0]>>4, com_hex[0]&0xf, (((uint16_t) (com_hex[1])&0xf)<<8)+(uint16_t)(com_hex[2]), (com_hex[1])>>4);
 				CTL_update_temp_auto();
 			}
-            print_idx(c);
-			print_hexXXXX(eeprom_timers_read_raw(
-                timers_get_raw_index((com_hex[0]>>4),(com_hex[0]&0xf))));
-			break;
-		case 'Y':
-			if (COM_hex_parse(3*2)!='\0') { break; }
+			print_hexXXXX(eeprom_timers_read_raw(timers_get_raw_index((com_hex[0]>>4),(com_hex[0]&0xf))));
+                        break;
+                    // B1324 - reboot, 1324 is password (fixed at this moment)
+                    case 'B':
+			if ((com_hex_len==4) && (com_hex[0]==0x13) && (com_hex[1]==0x24))
+			{
+			    cli();
+                            wdt_enable(WDTO_15MS); //wd on,15ms
+                            while(1); //loop till reset
+                        }
+                        break;
+                    // Yyymmdd - set, year yy, month mm, day dd; HEX values!!!
+                    case 'Y':
+                        if (com_hex_len!=6) { break; }
 			RTC_SetDate(com_hex[2],com_hex[1],com_hex[0]);
 			COM_print_debug(-1);
-			c='\0';
-			break;
-		case 'H':
-			if (COM_hex_parse(3*2)!='\0') { break; }
+                        break;
+                    // Hhhmmss - set, hour hh, minute mm, second ss; HEX values!!!
+                    case 'H':
+                        if (com_hex_len!=6) { break; }
 			RTC_SetHour(com_hex[0]);
 			RTC_SetMinute(com_hex[1]);
 			RTC_SetSecond(com_hex[2]);
 			COM_print_debug(-1);
-			c='\0';
-			break;
-		case 'B':
-			{
-				if (COM_hex_parse(2*2)!='\0') { break; }
-  				if ((com_hex[0]==0x13) && (com_hex[1]==0x24)) {
-                      cli();
-                      wdt_enable(WDTO_15MS); //wd on,15ms
-                      while(1); //loop till reset
-    			}
-			}
-			break;
-        case 'M':
-            if (COM_hex_parse(1*2)!='\0') { break; }
-            CTL_change_mode(com_hex[0]==1);
-            // COM_print_debug(-1);
-            break;
-        case 'A':
-            if (COM_hex_parse(1*2)!='\0') { break; }
-            if (com_hex[0]<TEMP_MIN-1) { break; }
-            if (com_hex[0]>TEMP_MAX+1) { break; }
-            CTL_set_temp(com_hex[0]);
-            COM_print_debug(-1);
-            break;
-		//case '\n':
-		//case '\0':
-		default:
-			c='\0';
-			break;
-		}
-		if (c!='\0') COM_putchar('\n');
-		COM_flush();
-	}
+                        break;
+                    // Axx - set wanted temperature [unit 0.5C]
+                    case 'A':
+                        if (com_hex_len!=2) { break; }
+                        if (com_hex[0]<TEMP_MIN-1) { break; }
+                        if (com_hex[0]>TEMP_MAX+1) { break; }
+                        CTL_set_temp(com_hex[0]);
+                        COM_print_debug(-1);
+                        break;
+                    // Mxx - set mode to 0=manu 1=auto
+                    case 'M':
+                        if (com_hex_len!=2) { break; }
+                        CTL_change_mode(com_hex[0]==1);
+                        break;
+                    // Ixx - activate bus ID 01..1f 0xff=single mode
+                    case 'I':
+                        if (com_hex_len!=2) { break; }
+                        active_bus_id = com_hex[0];
+                        break;
+                    // Oxxxx\n - set messured temperature , >0000 = disable messurement
+                    case 'O':
+                        if (com_hex_len!=4) { break; }
+                        override_adc_temp=(com_hex[0] >> 4)*1000 + (com_hex[0] & 0x0f) * 100 + (com_hex[1] >> 4)*10 + (com_hex[1] & 0x0f);
+                        break;
+                    
+                }
+                COM_flush();
+                COM_putchar('\n');
+            }
+        }
 }
 
 #if DEBUG_PRINT_MOTOR
diff -u source.orig/debug.h source.new/debug.h
--- source.orig/debug.h	2011-09-26 20:31:01.000000000 +0200
+++ source.new/debug.h	2011-10-07 21:11:49.399627964 +0200
@@ -50,3 +50,4 @@
 #define DEBUG_PRINT_MEASURE 0
 #define DEBUG_PRINT_I_SUM 1
 #define DEBUG_IGNORE_MONT_CONTACT 0
+#define DEBUG_MEMORY 1
Common subdirectories: source.orig/obj and source.new/obj
