Community
cancel
Showing results for 
Search instead for 
Did you mean: 
KBlow1
Beginner
1,343 Views

Galileo 1.5.3 error

The string concatenation example will not compile under the 1.5.3 IDE. It gives an error message about not finding operator+

If you change the example code to use the concat function then all is fine but e.g.

string = string1 + string2

does not compile.

0 Kudos
5 Replies
clayton_H_Intel
Employee
94 Views

This is a known issue.

It seems like it should be easy to create a function that adds two strings together, but I don't think anyone has taken the time to do it yet.

I have not tested this, but I think this function should work.

String StringAdd(String string1, String string2) {

int len1 = string1.length();

int len2 = string2.length();

char char1[len1];// = string1;

char char2[len2];// = string2;

char ret[len1 + len2];

string1.toCharArray(char1, len1);

string2.toCharArray(char2, len2);

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

ret[i] = char1[i];

}

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

ret[i + len1] = char2[i];

}

String retval = ret;

return retval;

}

clayton_H_Intel
Employee
94 Views

There are some bugs in the above code. Attached is a sketch that successfully adds two strings.

String StringAdd(String string1, String string2) {

int len1 = string1.length();

int len2 = string2.length();

char char1[len1];

char char2[len2];

char ret[len1 + len2];

string1.toCharArray(char1, len1 + 1);

string2.toCharArray(char2, len2 + 1);

for(int i = 0; i <= len1 + 1 ; i++){

ret[i] = char1[i];

}

for(int i = 0; i <= len2 + 1; i++){

ret[i + len1] = char2[i];

}

String retval = ret;

return retval;

}

JesusE_Intel
Moderator
94 Views

Hi keithb,

Using chofrock function and modifying the IDE example (StringAdditionOperator) i was able to successfully compile and upload to my galileo. The serial monitor showed results as expected. I have attached the modified sketch.

Regards,

Intel_JEspinoza

KBlow1
Beginner
94 Views

As I pointed out in the original post the String.concat function works and I had already corrected the example using that. It seems much simpler than using the function posted above.

So this currently will not compile:

s3 = s1 + s2;

but this does:

s3 = s1;

s3.concat(s2);

and works fine.

Is there a bug tracking service for the galileo IDE? I would have checked to see if it was known but can't find it.

Matthew_R_Intel
Employee
94 Views

This string add operator problem was associated to Galileo firmware version 0x0000030e / 782. You can find the firmware version by using cat /sys/firmware/board_data/flash_version from the Galileo Linux command prompt.

This issues appears to have been corrected in Galileo firmware 0x01000000 / 1.0.0. Just grab the latest version of the IDE with the 1.0.0 FW build from /docs/DOC-22226 https://communities.intel.com/docs/DOC-22226 and update the Galileo Firmware (Ardinuo IDE -> "Help" -> "Firmware Update").

--Matt Royer

Reply