Ciao,allora ho iniziato a "smanettare" il codice seguendo i vari consigli ,allego il nuovo codice.
Il problema/errore ," tagliando e cucendo ",si trova nel comando ?h ,dove ho scritto :
//Serial.print (value); < ----- riga problema
Forse perchè ho impostato la variabile value tipo byte ??
//
// Gestione Parametri Seriale Funzione RTC
//
void RTC_Seriale () {
// Wait for incoming data on serial port
if (Serial.available() > 0) {
// Read the incoming character
char incoming_char = Serial.read();
// End of line?
if(incoming_char == '
) {
if (serial_buffer[0] == '?') {
switch (serial_buffer[1]) {
// ------------------------------------------------------------------------------
//
// Elenco Comandi Utilizzati : [ ?? ] Richiesta Trasmissione TxRx
// " : [ ?V ] Read Versione Firmware
// " : [ ?P ] Read Giorno / Data / Ora
// " : [ ?R ] Write Giorno / Data / Ora
// " : [ ?H ] Write Fasce Orarie On / Off Relè
//_______________________________________________________________________________
//
// " : [ ?h ] Read Fasce Orarie On / Off Relè
// " : [ ?r ] Read Variabili Ora Legale / Solare
// " : [ ?w ] Write Variabili Ora Legale / Solare
//
// ------------------------------------------------------------------------------
//
// Inizio Comandi Utilizzati
//
//
// Comando [ ?? ]
//
case '?': {
Serial.println("Trasmissione OK");
break;
}
//
// Comando [ ?V ]
//
case 'V': {
Serial.println(VERSION);
break;
}
//
// Comando [ ?P ]
//
case 'P': {
DateTime now = RTC.now();
char time_string[20];
sprintf(time_string, "Giorno [ %01d ] Data [ %02d/%02d/%d ] Ora [ %02d:%02d:%02d ]",
now.dayOfTheWeek(),
now.day(), now.month(), now.year(),
now.hour(), now.minute(), now.second());
Serial.println(time_string);
break;
}
//
// Comando [ ?R ]
//
case 'R': {
String time_string = String(serial_buffer);
int day = time_string.substring(2, 4).toInt();
int month = time_string.substring(4, 6).toInt();
int year = time_string.substring(6, 10).toInt();
int hour = time_string.substring(10, 12).toInt();
int minute = time_string.substring(12, 14).toInt();
int second = time_string.substring(14, 16).toInt();
RTC.adjust(DateTime(year, month, day, hour, minute, second));
Serial.println("RTC Rifasato");
break;
}
//
// Comando [ ?H ]
//
case 'H': {
String time_string = String(serial_buffer);
int hour_on = time_string.substring(2, 4).toInt();
int minute_on = time_string.substring(4, 6).toInt();
int hour_off = time_string.substring(6, 8).toInt();
int minute_off = time_string.substring(8, 10).toInt();
address = 5;
value = hour_on ;
EEPROM.write(address, value);
address = 6;
value = minute_on ;
EEPROM.write(address, value);
address = 7;
value = hour_off ;
EEPROM.write(address, value);
address = 8;
value = minute_off ;
EEPROM.write(address, value);
Serial.println("Impostata Selezione Oraria");
break;
}
//
// Comando [ ?h ]
//
case 'h': {
address = 5;
value = EEPROM.read(address);
Serial.print ("Ora di Start On : ");
//Serial.print (value); < ----- riga problema
Serial.println (" ");
address = 6;
value = EEPROM.read(address);
Serial.print ("Minuti di Start On : ");
//Serial.print (value); < ----- riga problema
Serial.println (" ");
address = 7;
value = EEPROM.read(address);
Serial.print ("Ora di Stop Off : ");
//Serial.print (value); < ----- riga problema
Serial.println (" ");
address = 8;
value = EEPROM.read(address);
Serial.print ("Minuti di Stop Off : ");
//Serial.print (value); < ----- riga problema
Serial.println (" ");
Serial.println("Parametri Selezione Fasce On / Off impostati");
break;
}
//
// Comando [ ?r ]
//
case 'r': {
for (int address = 0; address <= 4; address++) {
value = EEPROM.read(address);
Serial.print(F("Step\t = \t"));
Serial.print( char('a'+address) );
Serial.print(F("\t ; \t Valore \t = \t"));
Serial.println(value, DEC);
delay(100);
if (address == 4) {
address = 0;
Serial.println();
break;
}
}
break;
}
//
// Comando [ ?w ]
//
case 'w': {
String time_string = String(serial_buffer);
int attendiS31 = time_string.substring(2, 3).toInt();
int attendiSdom = time_string.substring(3, 4).toInt();
int attendiL31 = time_string.substring(4, 5).toInt();
int attendiLdom = time_string.substring(5, 6).toInt();
int read_write = time_string.substring(6, 7).toInt();
address = 0;
value = attendiS31 ;
EEPROM.write(address, value);
address = 1;
value = attendiSdom ;
EEPROM.write(address, value);
address = 2;
value = attendiL31 ;
EEPROM.write(address, value);
address = 3;
value = attendiSdom ;
EEPROM.write(address, value);
address = 4;
value = read_write ;
EEPROM.write(address, value);
Serial.println("Variabili L/S Rifasate");
break;
}
}
}
//
// Fine Comandi Utilizzati
//
// Reset the buffer
buffer_position = 0;
memset(serial_buffer, 0x00, BUFFER_SIZE);
}
// Carriage return, do nothing
else if(incoming_char == '\r');
// Normal character
else {
// Buffer full, we need to reset it
if(buffer_position == BUFFER_SIZE - 1) buffer_position = 0;
// Store the character in the buffer and move the index
serial_buffer[buffer_position] = incoming_char;
buffer_position++;
}
}
}