Index: firmware/FSC/src/FSC_eth_with_user_interface.c
===================================================================
--- firmware/FSC/src/FSC_eth_with_user_interface.c	(revision 10674)
+++ firmware/FSC/src/FSC_eth_with_user_interface.c	(revision 10677)
@@ -33,10 +33,11 @@
 
 // ATMEGA ADC global variables
-	U08 adc_values[VOLTAGE_CHANNELS]; // stores measured voltage in steps of 16mV
+	U08 adc_readings_until_mean=250;
+	U32 adc_values[VOLTAGE_CHANNELS]; // stores measured voltage in steps of 16mV
 	U08 adc_enables[VOLTAGE_CHANNELS/8];
 	U08 adc_channels_ready[VOLTAGE_CHANNELS/8];
 	U08 adc_readings_since_last_muxing = 0;
 	U08 adc_current_channel = 0;
-	U08 adc_current_reading = 0;
+	U16 adc_current_reading = 0;
 	bool adc_measured_all = false;
 	bool adc_values_printed = true;
@@ -45,8 +46,12 @@
 	bool once_told_you = true;
 	bool debug_mode = false;
+	
+// ETHERNET VARS
+U08 downloaded_bytes;
 
 //-----------------------------------------------------------------------------
 //   M A I N    ---   M A I N    ---   M A I N    ---   M A I N    ---  M A I N    
 //-----------------------------------------------------------------------------
+/*
 int main(void)
 {
@@ -58,9 +63,5 @@
 		received_bytes = get_S0_RX_RSR();
 		
-		usart_write_U16_hex(get_S0_TX_FSR()); usart_write_char('\t'); usart_write_char('|');
-		usart_write_U16_hex(get_S0_TX_RD()); usart_write_char('\t'); usart_write_char('|');
-		usart_write_U16_hex(get_S0_TX_WR()); usart_write_char('\t'); usart_write_char('|');
-		usart_write_U16_hex(get_S0_RX_RSR()); usart_write_char('\t'); usart_write_char('|');
-		usart_write_U16_hex(get_S0_RX_RD()); usart_write_char('\t'); usart_write_char('|');
+		
 		
 	
@@ -115,5 +116,5 @@
 	
 } // end of main()	
-
+*/
 int main(void)
 {
@@ -141,4 +142,5 @@
 	static U08 welcome[]="welcome to:\n FSC command interface 0.1 \n build: ??.05.2010\n";
 	usart_write_str(welcome);
+	/*
 	print_help();
 	print_adc_enable_status(true);
@@ -149,9 +151,10 @@
 	usart_write_U32(sec , 7);
 	usart_write_str((pU08)" sec.\n");
-
+*/
 //MAIN LOOP
 while (1)
 {
-	if (w5100_caretaker())
+	// checks if socket is okay and resets in case of problem the W5100 
+	if (w5100_caretaker())  
 	{
 	// something is not okay with the ethernet ... 
@@ -159,8 +162,17 @@
 	}
 	
+	// this if should check every 25ms if we have any data on the W5100
 	if ( (milisec % W5100_INPUT_CHECK_TIME == 0) && (w5100_ready) )
 	{
 		if (get_S0_RX_RSR() != 0) { // we have something to read
-			really_downloaded_bytes = w5100_get_RX(ETH_READ_BUFFER_SIZE, true);
+			downloaded_bytes = w5100_get_RX(ETH_READ_BUFFER_SIZE, true);
+			usart_write_str((pU08)"got ethernet stream - no. of. bytes:");
+			usart_write_U08(downloaded_bytes,3);
+			usart_write_char('\n');
+			for (U08 i=0; i<downloaded_bytes; i++){
+				usart_write_U08_hex(eth_read_buffer[i]);
+				usart_write_char(' ');
+			}
+			usart_write_char('\n');
 		}
 	}
@@ -170,7 +182,7 @@
 		if(adc_print_endless){
 			usart_write_str((pU08)"V|");
-			usart_write_float((float)local_ms/1000 , 1,4);
+			usart_write_U32(sec ,8);
 			print_adc_nicely(false,true);
-			for ( U08 i=0; i<V_BITMAP; ++i ) {
+			for ( U08 i=0; i<(VOLTAGE_CHANNELS/8); ++i ) {
 				adc_channels_ready[i]=0;
 			}
@@ -185,7 +197,7 @@
 		if(ad7719_print_endless){
 			usart_write_str((pU08)"R|");
-			usart_write_float((float)local_ms/1000 , 1,4);
+			usart_write_U32(sec ,8);
 			print_ad7719_nicely(false,true);
-			for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+			for ( U08 i=0; i<(RESISTANCE_CHANNELS/8); ++i ) {
 				ad7719_channels_ready[i]=0;
 			}
@@ -224,5 +236,6 @@
 	if ( UCSRA & (1<<DOR) ){
 		usart_write_str((pU08)"PC sending to fast!\n");
-		usart_last_char = UDR;
+		//usart_last_char = UDR;
+		UDR;
 		// flush TX_buffer and write warning message in
 		// maybe even switch off every measurement. ?
Index: firmware/FSC/src/FSC_test.c
===================================================================
--- firmware/FSC/src/FSC_test.c	(revision 10674)
+++ firmware/FSC/src/FSC_test.c	(revision 10677)
@@ -11,4 +11,5 @@
 #include "parser.h"
 #include "interpol.h"
+#include "timer.h"
 #include "w5100_spi_interface.h"
 #include <avr/interrupt.h>
@@ -29,5 +30,5 @@
 	bool verbose;
 	bool heartbeat_enable;
-
+/*
 // USART global variables
 	U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
@@ -39,12 +40,12 @@
 // USART FLAGS
 	bool usart_tx_buffer_overflow = false;	// true if usart_tx_buffer was full.
-	
+	*/
 // TIMER global variable
 	volatile U32 local_ms = 0;
 
 // AD7719 global variables
-	U32 ad7719_values[TEMP_CHANNELS];
-	U08 ad7719_enables[CHANNEL_BITMAP];
-	U08 ad7719_channels_ready[CHANNEL_BITMAP];
+	U32 ad7719_values[RESISTANCE_CHANNELS];
+	U08 ad7719_enables[RESISTANCE_CHANNELS/8];
+	U08 ad7719_channels_ready[RESISTANCE_CHANNELS/8];
 	U08 ad7719_readings_since_last_muxing = 0;
 	U08 ad7719_current_channel = 0;
@@ -53,7 +54,7 @@
 	
 // ATMEGA ADC global variables
-	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS]; // stores measured voltage in steps of 16mV
-	U08 adc_enables[V_BITMAP + I_BITMAP + H_BITMAP];
-	U08 adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP];
+	U08 adc_values[VOLTAGE_CHANNELS]; // stores measured voltage in steps of 16mV
+	U08 adc_enables[VOLTAGE_CHANNELS/8];
+	U08 adc_channels_ready[VOLTAGE_CHANNELS/8];
 	U08 adc_readings_since_last_muxing = 0;
 	U08 adc_current_channel = 0;
@@ -356,5 +357,5 @@
 */
 
-
+/*
 
 ISR (TIMER2_COMP_vect)
@@ -366,2 +367,3 @@
 
 
+*/
Index: firmware/FSC/src/application.c
===================================================================
--- firmware/FSC/src/application.c	(revision 10674)
+++ firmware/FSC/src/application.c	(revision 10677)
@@ -139,7 +139,7 @@
 U08	increase_adc (U08 channel){
 U08 effective_channel;
-	for ( U08 increase = 1 ; increase <= V_CHANNELS + I_CHANNELS + H_CHANNELS; increase++)
-	{
-		effective_channel = (channel + increase) % (V_CHANNELS + I_CHANNELS + H_CHANNELS);
+	for ( U08 increase = 1 ; increase <= VOLTAGE_CHANNELS; increase++)
+	{
+		effective_channel = (channel + increase) % (VOLTAGE_CHANNELS);
 		if (adc_enables[effective_channel/8] & (1<<effective_channel%8))
 			return effective_channel;
@@ -150,7 +150,7 @@
 U08	increase_ad7719 (U08 channel){
 U08 effective_channel;
-	for ( U08 increase = 1 ; increase <= TEMP_CHANNELS; increase++)
-	{
-		effective_channel = (channel + increase) % (TEMP_CHANNELS);
+	for ( U08 increase = 1 ; increase <= RESISTANCE_CHANNELS; increase++)
+	{
+		effective_channel = (channel + increase) % (RESISTANCE_CHANNELS);
 		if (ad7719_enables[effective_channel/8] & (1<<effective_channel%8))
 			return effective_channel;
@@ -161,5 +161,5 @@
 void check_if_measured_all() {
 	adc_measured_all = true;
-	for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
+	for ( U08 i=0; i<(VOLTAGE_CHANNELS/8); ++i ) {
 		if ((adc_enables[i] ^ adc_channels_ready[i]) != 0x00) {
 			adc_measured_all = false;
@@ -168,5 +168,5 @@
 	}
 	ad7719_measured_all = true;
-	for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+	for ( U08 i=0; i<(RESISTANCE_CHANNELS/8); ++i ) {
 		if ((ad7719_enables[i] ^ ad7719_channels_ready[i]) != 0x00) {
 			ad7719_measured_all = false;
@@ -177,2 +177,25 @@
 
 }
+
+
+bool check_if_adc_measurement_done(){
+	adc_measured_all = true;
+	for ( U08 i=0; i<VOLTAGE_CHANNELS/8; ++i ) {
+		if ((adc_enables[i] ^ adc_channels_ready[i]) != 0x00) {
+			adc_measured_all = false;
+			break;
+		}
+	}
+	return adc_measured_all;
+}
+
+bool check_if_ad7719_measurement_done(){
+	ad7719_measured_all = true;
+	for ( U08 i=0; i<RESISTANCE_CHANNELS/8; ++i ) {
+		if ((ad7719_enables[i] ^ ad7719_channels_ready[i]) != 0x00) {
+			ad7719_measured_all = false;
+			break;
+		}
+	}
+	return ad7719_measured_all;
+}
Index: firmware/FSC/src/application.h
===================================================================
--- firmware/FSC/src/application.h	(revision 10674)
+++ firmware/FSC/src/application.h	(revision 10677)
@@ -63,10 +63,10 @@
 
 // ATMEGA ADC global variables
-	extern U08 adc_values[]; // stores measured voltage in steps of 16mV
+	extern U32 adc_values[]; // stores measured voltage in steps of 16mV
 	extern U08 adc_enables[];
 	extern U08 adc_channels_ready[];
 	extern U08 adc_readings_since_last_muxing;
 	extern U08 adc_current_channel;
-	extern U08 adc_current_reading;
+	extern U16 adc_current_reading;
 	extern bool adc_measured_all;
 	extern bool adc_values_printed;
@@ -95,4 +95,7 @@
 void check_what_measurement_was_finished() ;
 void check_if_measured_all() ;
+
+bool check_if_adc_measurement_done();
+bool check_if_ad7719_measurement_done();
 // end of function definition:
 //-----------------------------------------------------------------------------
Index: firmware/FSC/src/output.c
===================================================================
--- firmware/FSC/src/output.c	(revision 10674)
+++ firmware/FSC/src/output.c	(revision 10677)
@@ -6,10 +6,10 @@
 void print_status() {
 	usart_write_str((pU08)"adc status:\n");
-	for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i) {
+	for (U08 i=0; i< VOLTAGE_CHANNELS/8;++i) {
 		usart_write_U08_bin(adc_enables[i]);	
 		usart_write_char(' ');
 	}
 	usart_write_char('\n');
-	for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i){
+	for (U08 i=0; i< VOLTAGE_CHANNELS/8;++i){
 		usart_write_U08_bin(adc_channels_ready[i]);
 		usart_write_char(' ');
@@ -18,10 +18,10 @@
 
 	usart_write_str((pU08)"ad7719 status:\n");
-	for (U08 i=0; i< CHANNEL_BITMAP;++i) {
+	for (U08 i=0; i< RESISTANCE_CHANNELS/8;++i) {
 		usart_write_U08_bin(ad7719_enables[i]);
 		usart_write_char(' ');
 	}
 	usart_write_char('\n');
-	for (U08 i=0; i< CHANNEL_BITMAP;++i){
+	for (U08 i=0; i< RESISTANCE_CHANNELS/8;++i){
 		usart_write_U08_bin(ad7719_channels_ready[i]);
 		usart_write_char(' ');
@@ -57,5 +57,5 @@
 	usart_write_str((pU08)"\n printing voltages in mV:\n");
 	// output:	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
-	for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
+	for (U08 i=0; i< VOLTAGE_CHANNELS;++i) {
 		if (i%8 == 0) usart_write_char('\n');
 		adc_output(i, adc_values[i]);
@@ -72,5 +72,5 @@
 	usart_write_str((pU08)"\n printing measured resistance in kohms:\n");
 
-	for (U08 i=0; i< TEMP_CHANNELS;++i) {
+	for (U08 i=0; i< RESISTANCE_CHANNELS;++i) {
 		if (i%8 == 0) usart_write_char('\n');
 
Index: firmware/FSC/src/parser.c
===================================================================
--- firmware/FSC/src/parser.c	(revision 10674)
+++ firmware/FSC/src/parser.c	(revision 10677)
@@ -33,5 +33,5 @@
 		case 'G': 			// GET the Temperature channels, which are enabled
 			once_told_you = false;
-			for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+			for ( U08 i=0; i<RESISTANCE_CHANNELS/8; ++i ) {
 				ad7719_channels_ready[i]=0;
 			}
@@ -40,5 +40,5 @@
 		case 'g':			// GET the voltage/current/humidity channels, which are enabled
 			once_told_you = false;
-			for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
+			for ( U08 i=0; i<VOLTAGE_CHANNELS/8; ++i ) {
 				adc_channels_ready[i]=0;
 			}
@@ -84,5 +84,5 @@
 // to be discarded, because something went wrong, and the bytemade no sense...
 // the end of a commmand, and so the 'real parser' may do his work.
-
+/*
 void incoming_byte_parser() {
 	static bool receiving_command = false;
@@ -105,5 +105,6 @@
 	
 }
-
+*/
+/*
 
 // this is the recent MSR parser
@@ -124,8 +125,7 @@
 	usart_write_str(usart_rx_buffer);
 	usart_write_char('\n');
-	//usart_write_str((pU08)"\n received number of bytes:");
-	//usart_write_U08(usart_rx_buffer_index,3);
-
-	if (usart_rx_buffer_index >0) {
+	
+
+	if (usart_received_chars >0) {
 		switch (usart_rx_buffer[0]) {
 			case 'E': 		// user wants to enable/disable something
@@ -135,5 +135,5 @@
 			case 'd':
 			
-				if (usart_rx_buffer_index>=1) {  // let's see what.
+				if (usart_received_chars>=1) {  // let's see what.
 					if ( 	usart_rx_buffer[1] != 'r'  &&
 							usart_rx_buffer[1] != 'v'  &&
@@ -141,5 +141,5 @@
 							usart_rx_buffer[1] != 'p' )
 						{
-							print_invalid_enable_statement();
+							//print_invalid_enable_statement();
 							break;
 						}
@@ -147,13 +147,13 @@
 				
 				input_number = 0;
-				if (usart_rx_buffer_index >2) {  // lets check the first digit
+				if (usart_received_chars >2) {  // lets check the first digit
 					if ( usart_rx_buffer[2] >= '0' && usart_rx_buffer[2] <= '9' ) {
 						input_number = usart_rx_buffer[2] - '0';
 					} else {
-						print_invalid_enable_statement();
+						//print_invalid_enable_statement();
 						break;
 					}
 				}
-				if (usart_rx_buffer_index >3) {  // lets check the 2nd digit
+				if (usart_received_chars >3) {  // lets check the 2nd digit
 					if ( usart_rx_buffer[3] >= '0' && usart_rx_buffer[3] <= '9' ) {
 						input_number = 10*input_number + usart_rx_buffer[3] - '0';
@@ -164,5 +164,5 @@
 					}
 				}
-				if (usart_rx_buffer_index>2) {
+				if (usart_received_chars>2) {
 					usart_write_str((pU08)"\n I will switch ");
 					if (enable) 
@@ -226,5 +226,5 @@
 					
 					
-				}// end of if usart_rx_buffer_index>2  --> this should not be necessary at all
+				}// end of if usart_received_chars>2  --> this should not be necessary at all
 				break;
 				
@@ -241,5 +241,5 @@
 			case 'G': 			// GET the Temperature channels, which are enabled
 				ad7719_values_printed = false;
-				for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+				for ( U08 i=0; i<RESISTANCE_CHANNELS/8; ++i ) {
 					ad7719_channels_ready[i]=0;
 				}
@@ -247,5 +247,5 @@
 			case 'g':			// GET the voltage/current/humidity channels, which are enabled
 				adc_values_printed = false;
-				for ( U08 i=0; i<V_BITMAP; ++i ) {
+				for ( U08 i=0; i<VOLTAGE_CHANNELS/8; ++i ) {
 					adc_channels_ready[i]=0;
 				}
@@ -301,6 +301,7 @@
 	for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
 		usart_rx_buffer[i] = 0;
-	usart_rx_buffer_index = 0;	
+	usart_received_chars = 0;	
 	usart_rx_ready = false;
 }	// END of MSR_parser();
 
+*/
Index: firmware/FSC/src/spi_master.c
===================================================================
--- firmware/FSC/src/spi_master.c	(revision 10674)
+++ firmware/FSC/src/spi_master.c	(revision 10677)
@@ -53,5 +53,5 @@
 	
 	// Lets try with the fastest!
-	spi_clock_index = 0;  // Set Clockindex for lowest clock speed (F_CPU / 128)
+	spi_clock_index = 4;   // this is reasonable for W5100 because of slow level shifters on the FSC.
 
   spi_dord = 0;					// Data Order MSB first dord = 0  --> good for all devices
@@ -188,4 +188,5 @@
   for (n = 0; n < bytes; n++)
   {
+  PORTB |= 1<< PB3;
   // Check for active slave select level
   if (SPI_DEVICE_ACTIVE_HIGH[device])
@@ -206,7 +207,7 @@
   }
 
-  
+  PORTB &= ~(1<< PB3);
     spi_read_buffer[n] = spi_transfer_byte(spi_write_buffer[n]);
-  
+  PORTB |= 1<< PB3;
 
   // Check for inactive slave select level
@@ -227,5 +228,5 @@
 		}
   }
-  
+   PORTB &= ~(1<< PB3);
   }
 }
@@ -240,7 +241,10 @@
 
   // Wait for transfer completed
+  PORTB |= 1<<PB3;
   while (!(SPSR & (1 << SPIF)))
   {
-  }
+  PORTB ^= 1<<PB3;
+  }
+  PORTB &= ~(1<<PB3);
 
   // Return result of transfer
@@ -282,2 +286,26 @@
 }
 //-----------------------------------------------------------------------------
+
+
+//-----------------------------------------------------------------------------
+
+void spi_transfer_w5100(U08 bytes)
+{
+
+	U08 n;
+	// Transfer requested bytes
+	SPCR |= 1<<MSTR; // make sure we are still SPI MASTER ... sometimes this bit is cleared by something ... dkw?
+	for (n = 0; n < bytes; n++)
+	{
+		PORTB &= ~(1<< PB4);  // SS low
+
+		SPDR = spi_write_buffer[n];
+		while (!(SPSR & (1 << SPIF)))
+		spi_read_buffer[n] = SPDR	;
+
+		PORTB |= (1<< PB4);  // SS HIGH 
+	}
+
+
+}
+//-----------------------------------------------------------------------------
Index: firmware/FSC/src/spi_master.h
===================================================================
--- firmware/FSC/src/spi_master.h	(revision 10674)
+++ firmware/FSC/src/spi_master.h	(revision 10677)
@@ -26,4 +26,5 @@
 void spi_init(void);
 void spi_transfer(U08 bytes, U08 device);
+void spi_transfer_w5100(U08 bytes);
 U08 spi_transfer_byte(U08 data);
 void spi_set_clock_index(U08 clock_index);
Index: firmware/FSC/src/w5100_spi_interface.c
===================================================================
--- firmware/FSC/src/w5100_spi_interface.c	(revision 10674)
+++ firmware/FSC/src/w5100_spi_interface.c	(revision 10677)
@@ -24,4 +24,5 @@
 	if (socket_status == SR_SOCK_ESTABLISHED) {
 		w5100_ready = true;
+		
 		// everything is fine... 
 		return 0;
@@ -63,5 +64,5 @@
 spi_write_buffer[3]=data;
 
-spi_transfer(4, 0); 
+spi_transfer_w5100(4); 
 // spi_read_buffer should contain 0x00 0x01 0x02 and 0x03 ... nice check!
 }
@@ -74,5 +75,5 @@
 spi_write_buffer[3]=0x00;
 
-spi_transfer(4, 0); 
+spi_transfer_w5100(4); 
 return spi_read_buffer[3]; 
 // spi_read_buffer should contain 0x00 0x01 0x02 and data ... nice check!
@@ -117,21 +118,12 @@
 	w5100_write ( S0_PORT0, 0x13 ); 	// Port 5000 -> 0x1388 
 	w5100_write ( S0_PORT1, 0x88 ); 
-	usart_write_str((pU08)"Issuing Socket open command. NOW\n");
 	w5100_write ( S0_CR, CR_OPEN );		// issue Socket open command
 	while (sock0_status != SR_SOCK_INIT) {
 		sock0_status = w5100_read(S0_SR); // request socket 0 status
-		usart_write_str((pU08)"Socket 0 status is:");
-		usart_write_U08_hex(sock0_status);
-		usart_write_char('\n');
-	}
-
-	usart_write_str((pU08)"Issuing Socket LISTEN command. NOW\n");
+	}
+
 	w5100_write ( S0_CR, CR_LISTEN );		// issue Socket listen command
-	
 	while (sock0_status != SR_SOCK_LISTEN) {
 		sock0_status = w5100_read(S0_SR); // request socket 0 status
-		usart_write_str((pU08)"Socket 0 status is:");
-		usart_write_U08_hex(sock0_status);
-		usart_write_char('\n');
 	}
 	return sock0_status;
Index: firmware/FSC/src/w5100_spi_interface.h
===================================================================
--- firmware/FSC/src/w5100_spi_interface.h	(revision 10674)
+++ firmware/FSC/src/w5100_spi_interface.h	(revision 10677)
@@ -11,5 +11,5 @@
 
 #define ETH_READ_BUFFER_SIZE 32
-#define ETH_WRITE_BUFFER_SIZE 16
+#define ETH_WRITE_BUFFER_SIZE 32
 extern volatile U08 eth_read_buffer[ETH_READ_BUFFER_SIZE];
 extern volatile U08 eth_write_buffer[ETH_WRITE_BUFFER_SIZE];
