Help with serial

I'm trying to process data sent from the PC using the serial connection, I would like to handle them as a string and use the - (dash) as a divider chain. The problem is that the data are read char.

Anyone know any way to convert char to String? and how to divide the chain?

someone can help out with this???

Maverik:
Anyone know any way to convert char to String?

I'm not sure exactly what you are wanting to do, but I do know that using the String class to do it is asking for trouble.

Read your data in one char at a time and add them to a buffer (a char array). When you get to the end of the message then go look at your array using something like strtok() with the dashes as the delimiter.

I have this code that works well.

          String a[3];
                   
          char str[] = "A-iD08-0on";
          char delims[] = "-";
          char *result = NULL;
          result = strtok( str, delims );
          
          for(int i=0; i<3; i++)
          {
            
            a[i]=result;
            result = strtok( NULL, delims );
            
            
          }
          Serial.println( a[0] );
          Serial.println( a[1] );
          Serial.println( a[2] );

but when I pass the data read from the serial communication gives me this error.

initializer fails to determine size of 'str'

but when I pass the data read from the serial communication gives me this error.

initializer fails to determine size of 'str'

That doesn't make a lot of sense to me, and the code presented cannot compile, much less run.
Please post all code.

void loop()
{
  if (Serial.available() > 0) //si hay coneccion
  {
    // lee el byte entrante:
    leo = Serial.read();
    if (leo==-1)
    {
      //no hay datos en la coneccion
    }
    else
    {
      if (-1 != leo) 
      {
        if ('A' == leo || 'a' == leo) 
        {
          Serial.println("Hello from Arduino!");
        }
        if ('Z' == leo || 'z' == leo) 
        {
          Serial.println("Helino!");
        }
        else
        {
          String a[3];

          char str[10] = leo; //datos a leer con el formato: A-iD07-0on
          char delims[] = "-";
          char *result = NULL;
          result = strtok( str, delims );
 
           for(int i=0; i<3; i++)
          {
            
            a[i]=result;
            result = strtok( NULL, delims );
            
            
          }
          Serial.println( a[0] );
          Serial.println( a[1] );
          Serial.println( a[2] );
        }
      }
    }
  }
}

OK, now ALL of the code?

//Defino Version del sistema
String VERSION = "0.0.1";

//Defino nombre de la placa
String NOMBRE = "HogArd";

//Defino tipo mensajes
String INFORMACION = "I";
String ACCION = "A";
String ERROR = "E";
String CONFIGURACION = "C";

//Defino tipo de pin digitales
int iD03 = 3;
String sD03 = "Digital 03";

int iD04 = 4;
String sD04 = "Digital 04";

int iD05 = 5;
String sD05 = "Digital 05";

int iD06 = 6;
String sD06 = "Digital 06";

int iD07 = 7;
String sD07 = "Digital 07";

int iD08 = 8;
String sD08 = "Digital 08";

int iD09 = 9;
String sD09 = "Digital 09";

int iD10 = 10;
String sD10 = "Digital 10";

int iD11 = 11;
String sD11 = "Digital 11";

int iD12 = 12;
String sD12 = "Digital 12";

int iD13 = 13;
String sD13 = "Digital 13";

//Defino tipo de pisn analogos
int iA00 = 0;
String sA00 = "Analogo 00";

int iA01 = 1;
String sA01 = "Analogo 01";

int iA02 = 2;
String sA02 = "Analogo 02";

int iA03 = 3;
String sA03 = "Analogo 03";

int iA04 = 4;
String sA04 = "Analogo 04";

int iA05 = 5;
String sA05 = "Analogo 05";
//Defino pins PWM

//Defino otras variables
String a[3];
int leo = 0;
char str[19] = "Hogard-A-iD05-00on";

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0) //si hay coneccion
  {
    // lee el byte entrante:
    leo = Serial.read();
    if (leo==-1)
    {
      //no hay datos en la coneccion
    }
    else
    {
      if (-1 != leo) 
      {
        //los datos no son nulos
        if ('v' == leo || 'V' == leo) 
        {
          Serial.println(VERSION);
        }
        if ('n' == leo || 'N' == leo) 
        {
          Serial.println(NOMBRE);
        }

        char delims[] = "-";
        char *result = NULL;
        result = strtok( str, delims );

        for(int i=0; i<4; i++)
        {

          a[i]=result;
          result = strtok( NULL, delims );


        }
        Serial.println( a[0] );
        Serial.println( a[1] );
        Serial.println( a[2] );
        Serial.println( a[3] );

        if (NOMBRE == a[0]) //si le hablo a esta placa veo que hago
        {
          Serial.println( "hola");
          /*
            if ('A' == a[1] || 'a' == a[1]) 
           {
           //estoy en el apartado de acciones
           }
           if ('I' == a[1] || 'i' == a[1]) 
           {
           //estoy en el apartado de informacion
           }
           if ('E' == a[1] || 'e' == a[1]) 
           {
           //estoy en el apartado de errores
           }
           if ('C' == a[1] || 'c' == a[1]) 
           {
           //estoy en el apartado de configuraciones
           }
           */
        }

        else
        {
          //no estoy hablandole a esta placa
        }
      }

    }
  }
  else
  {


  }
}

este es todo el codigo que tengo hasta ahora.

Todo el código?

sorry,
this is my code.