You're right, sorry
Code:
char buffer[1000]; //buffer for serial data recive from PC
bool scenario1 = false;
char line[17];
int scen_min = 0;
int scen_max = 18;
void setup()
{
/*--get module gsm wake up-----*/
pinMode(FONA_KEY, OUTPUT);
digitalWrite(FONA_KEY, PIN_ON); //
delay(200); //POUR REVEILLER LE GSM FAUT FAIRE UN HIGH DE 200MS SUR LE PIN FONA_KEY
digitalWrite(FONA_KEY, PIN_OFF); //
/*-------CONFIG SERIAL PORT FOR GSM-------*/
fonaSerial->begin(4800);
/*-------CONFIG SERIAL PORT FOR GPS-------*/
Serial4.begin(4800);
/*-------CONFIG SERIAL PORT FOR PC--------*/
Serial2.begin(9600);
Serial.begin(9600);
}/* FIN setup */
void loop()
{
while (Serial2.available () > 0)
{
ReadDataPC (Serial2.read ());
}
if (scenario1)
{
scenario1 = false;
Serial2.println("SCENOK");
//Serial.println("SCENOK");
}
while (Serial4.available () > 0) {
ReadTimeGPS(Serial4.read ()); //mise a jour des heures minutes et secondes temps reel gps
}
}
void DataPC()
{
Serial.println(buffer[0]);
switch (buffer[0]) // premier case de data recu determine dans quelle cas de config on se trouve
{
case '0': //reception des trame configuration
configuration();
break;
case '1': // cas ou l'operateur n'a pas recu le premier sms on renvoye a nouveau
Send_msg(_message);
break;
case '2': // cas ou le congig gsm a echué on refait une tentative
config_gsm ();
break;
case '3': // cas ou le congig gps a echué on refait une tentative
config_gps ();
break;
case '4': // cas ou le congig gps a echué on refait une tentative
config_servo ();
break;
case '5': // reception scenario1
scenario1 = true;
scenario();
break;
case '6': //reception scenario2
scenario2 = true;
break;
case '7': // reception scenario3
scenario3 = true;
break;
case '8': // start
Serial2.println( "STARTOK");
startOK = true;
Serial.println( "STARTOK");
start_enrg = true;
break;
case '9': // stop
Serial2.println( "STOP");
Serial.println( "STOP");
startOK = false;
compteur10 = 0;
break;
case 'A': // SI LE PC REPOND PRESENT IL PEUX ENVOYER LES ENREGISTREMENTS
send_enrg = true;
Serial.println("RECU A");
break;
}
}
void configuration()
{
config_servo();
config_gps();
config_gsm();
Serial2.println( "GSM_OK");
Serial2.println("MSG_SEND");
Serial2.println("SERVO_OK");
}
void scenario ()
{
line[16];
for (int y = scen_min; y < scen_max; y++)
{
if(buffer[y] != ' ')
{
line[y] = buffer[y];
}
}
/*for(int y = scen_min; y < scen_max; y++)
{
TIME += line[y];
}
Serial.print(TIME);*/
Serial.print(line);
/*Serial2.println("SCENOK");
Serial.println("SCENOK");*/
}
void config_gps ()
{
Serial2.println("GPS_OK");
Serial.println("GPS_OK");
}
void config_gsm ()
{
if (!fona.begin(*fonaSerial))
{
Serial2.println( "GSM_FAIL");
Serial.println( "GSM_FAIL");
}
else
{
Serial2.println( "GSM_OK");
Serial.println( "GSM_OK");
Send_msg( _message );
}
}
void config_servo ()
{
XreSmdr = buffer[46];
Serial.println(buffer);
for (int x = indexservo_min; x < indexservo_max; x++)
{
if (buffer[x] == '1')
{
Serial.print( "modex_resmdr= " + XreSmdr + buffer[x]); //FAUT RAMPLCER SERIAL PRINT PAR LA COMMANDE SEND SUR BUS CAN
}
}
}
void Send_msg(char * message )
{
char nu_telefone[14];
for (int i = 1; i < 15; i++)
{
if (buffer[i] != ' ')
{
nu_telefone[i - 1] = buffer[i];
}
}
fona.sendSMS(nu_telefone, message);
Serial2.println("MSG_SEND");
Serial.println("MSG_SEND");
}
What's the next step to make the the teensy read the lines on the loop?