voici l'erreur et je ne comprend pas :
Compilation error: the value of 'initialization' is not usable in a constant expression
et voici le code associé
#define txPin 1
#define rxPin 0
const byte NUL = 0x00;
const byte STX = 0x02; // début du texte
const byte ETX = 0x03; // fin du texte
const byte EOT = 0x04; // fin de la transmission
const byte ENQ = 0x05; // enquiry
const byte ACK = 0x06; // Acknowledge
const byte NAK = 0x15; // Negative Acknowledge
byte RESPONSE = 0;
//===========================================================//
// //
// //
// Horloge //
// //
// //
//===========================================================//
const unsigned long TSec = 1000;
unsigned long Num_ms, Num_sec, Num_min;
unsigned long Num_heur, Num_jour, Temps_ms;
void setup() {
Serial.begin(1200, SERIAL_7E1);
}
void loop() {
int etat_protocol = 0;
int initialization = 0;
int configuration = 1;
switch (etat_protocol) {
case initialization :
// ************************************** //
// Etape 1 // initialization
// ************************************** //
Serial.write(ENQ);
delay(150);
while (Serial.available() > 0) {
RESPONSE = Serial.read();
}
if (RESPONSE == ACK) {
// ------------------- //
// Envoie de STX //
// ------------------- //
Serial.write(STX);
// ------------------- //
// Affichage OK //
// ------------------- //
Serial.write("@K"); // Envoie "K" pour le paramètre Initialization
// ------------------- //
// Affichage version //
// ------------------- //
Serial.write("01000"); // Indique la version
// ------------------- //
// Affichage date //
// ------------------- //
Serial.write("20230607"); // Si date besoin de mettre à jour remplacer sous la forme suivante "20230607" tout collé
// ------------------- //
// Affichage heure //
// ------------------- //
Temps_ms = millis();
Num_sec = (Temps_ms / TSec) % 60; // Calcul seconde
Num_min = (Temps_ms / (TSec * 60)) % 60; // Calcul minute
Num_heur = (Temps_ms / (TSec * 3600)) % 60; // Calcul heure
Num_jour = (Temps_ms / (TSec * 86400)); // 3600 * 24 = 86400
Serial.print(Num_jour); // Écrit le jour
Serial.print(Num_heur); // Écrit l'heure
Serial.print(Num_min); // Écrit les minutes
Serial.print(Num_sec); // Écrit les secondes
// ------------------- //
// FIN DE TRAME //
// ------------------- //
Serial.write(ETX);
}
break;
case configuration:
// ************************************** //
// Etape 2 // configuration
// ************************************** //
Serial.write(ENQ);
delay(150);
while (Serial.available() > 0) {
RESPONSE = Serial.read();
}
if (RESPONSE == ACK) {
Serial.write(STX); // Envoie STX
Serial.write("@C"); // Envoie le "C" pour le paramètre configuration
Serial.write(ETX);
Serial.write(NUL);
}
break;
}
}