invalid conversion from char to char*

I am having a problem passing a character to a function. It gives the invalid conversion from char to char* error. I am using the code from the parallax gps arduino tutorial at: http://www.arduino.cc/playground/Tutorials/GPS

This is the code:

void loop() {
  byteGPS=Serial1.read();         // Read a byte of the serial port
  if (byteGPS == -1) {           // See if the port is empty yet
     delay(100); 
  } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
     Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
          for(int j=8; j<14; j++){
          LED.LED_PrintString(linea[j], 0x00, 0x1d, 0x00, 0x02, 0, 0x00, 0x00, 0x01, 0x02);  //print time value
          }
        }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             
       }                 
     }
   }
  
  delay(1000);  
}

this is the function i am passing it to:

void OLED320::LED_PrintString(char* str, char xa, char xb, char ya, char yb, char font, char color1, char color2, char width_, char height_) 
{
      delay(10);
      int i = 0;
        Serial.print(0x53,BYTE);           //print string cmd
        Serial.print(xa,BYTE);            //xa coord
        Serial.print(xb,BYTE);            //xb coord
        Serial.print(ya,BYTE);            //y1 coord
        Serial.print(yb,BYTE);            //y2 coord
        Serial.print(font,BYTE);            //font
        Serial.print(color1,BYTE);      //color
        Serial.print(color2,BYTE);      //color
        Serial.print(width_,BYTE);      //width
        Serial.print(height_,BYTE);     //height

        while(str[i]!='\0')
        {  
                Serial.print(str[i],BYTE);
                i++;
        }
        Serial.print(0x00,BYTE);         //Terminator
}

I am confused because I was able to pass the character arrays to this function using the LB_GPS library functions for example:

void loop() {
  GPS.getRaw(100);

  GPS.GPSStringExplode(GPS.inBuffer,',');
 
  LED.LED_PrintString(GPS.arguments[1], 0x00, 0x1d, 0x00, 0x02, 0, 0x00, 0x00, 0x01, 0x02);  //print time value
}

I tried using:
LED.LED_PrintString((char*)linea[j], 0x00, 0x1d, 0x00, 0x02, 0, 0x00, 0x00, 0x01, 0x02);

and it would compile but it would not display the data. Thanks!

mjared,

The first argument of LED_PrintString is supposed to be a pointer to a character. You are passing in 'linea[j]', which is a single char. If you pass in '&linea[j]', it will compile, but I suspect it may not do what you expect, since it will print linea from the 9th character to the end, then from the 10th character to the end, etc.

Regards,

-Mike

Is there a way to clip the linea[j] like i thought the for loop was doing?

and it prints the correct amount of characters when printing to the serial monitor.

for(int j=8; j<14; j++){
           Serial.print(linea[j]);
           }
           Serial.println(" ");
           for(int j=17; j<26; j++){
           Serial.print(linea[j]);
           }
           Serial.print(" ");
           for(int j=27; j<28; j++){
           Serial.print(linea[j]);
           }
           Serial.println(" ");
           for(int j=29; j<39; j++){
           Serial.print(linea[j]);
           }
           Serial.print(" ");
           for(int j=40; j<41; j++){
           Serial.print(linea[j]);
           }

It works when printing to the serial monitor because you are passing a single character to the print routine, so it only prints a single character.

If you want to print characters 8 - 14 with LED_PrintString, you could do this:

char temp_str[8];
strncpy(temp_str,&(linea[8]),7);
temp_str[7] = '\0';
LED.LED_PrintString(temp_str, 0x00, 0x1d, 0x00, 0x02, 0, 0x00, 0x00, 0x01, 0x02);  //print time value

Note that you don't use a loop, so you will only get one line of output.

Regards,

-Mike