Serial port Issues

hello there!
I have a weird serial port issue and I am trying to debug but i need some help:
I have an arduino sending some data to my imp with a sparkful arduino shield on pins 8,9 and on imp 57.
here is the arduino code and the imp code:

void WriteSerialPort(){ // Send all info to the imp Serial.print("SEND TO imp: "); String dataTosend = String(tempnowC) + "," + String(humiditynow) + "," + String(OLED_mode) + delimiter; Serial.println(dataTosend); impSerial.print(dataTosend); delay(100); }

And imp code receiving the serial port stuff:

`
function arduinoData() {
local result = arduino.read();
while(result >= 0) {
if (result == ‘|’) {
server.log("SERIAL PORT RCVD: " + buffer);
updateData(buffer);
buffer = “”;
} else {
buffer = buffer + result.tochar();
}

    result = hardware.uart12.read();
}
toggleRxLED();

}

function updateData(dataIn)
{
try {
local sp = split(dataIn, “,”);
// Assign variables
temperatureC = sp[0];
temperatureC = temperatureC.tofloat();
humidity = sp[1];
humidity = humidity.tofloat();
oled_mode = sp[2];
oled_mode = oled_mode.tointeger();
server.log("-> temperatureC: " + temperatureC);
server.log("-> humidity: " + humidity);
server.log("-> oled_mode: " + oled_mode);
}
catch (e){
server.log("Something went wrong: " + e);
}
}

arduino.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, arduinoData);
`

Most of the time it works fine, but there are many times where i receive twice the result or half the result like this:

`
SERIAL PORT RCVD: ,24.41,4|

2013-12-15 19:48:11 UTC-8: [Device] Something went wrong: the index ‘1’ does not exist

2013-12-15 19:48:11 UTC-8: [Device] SERIAL PORT RCVD: 23.88

2013-12-15 19:48:11 UTC-8: [Device] Something went wrong: the index ‘2’ does not exist

2013-12-15 19:48:16 UTC-8: [Device] SERIAL PORT RCVD: 23.81,25.19,4|
2013-12-15 19:49:26 UTC-8: [Device] SERIAL PORT RCVD: 23.88

2013-12-15 19:49:26 UTC-8: [Device] Something went wrong: the index ‘1’ does not exist

2013-12-15 19:49:26 UTC-8: [Device] SERIAL PORT RCVD: ,25.67,2|

2013-12-15 19:49:26 UTC-8: [Device] Something went wrong: the index ‘2’ does not exist

2013-12-15 19:49:42 UTC-8: [Device] Setting LED to: 1

2013-12-15 19:49:42 UTC-8: [Device] SERIAL PORT RCVD: 23.88,25.35

2013-12-15 19:49:42 UTC-8: [Device] Something went wrong: the index ‘2’ does not exist
`

Any ideas why that might be caused? I have tried different bauds, currently at 9600 but i went up to 19200 and still issues.
Any help will be greatly appreciated! thanks!

Does that log correspond to that version of your code? Because in the code I can’t see how “buffer” would ever contain the “|” character – but it appears several times in the log.

Peter

You said Imp pins 5 and 7 ?

This line:
result = hardware.uart12.read();

You must have meant you use pins 1 and 2?

@peter yes it is the correct code. i have no idea how it is there either…
@mlsein , yes you are correct… no idea why i put result = hardware.uart12.read();.
It should have been result = hardware.uart57.read();
Maybe this is the issue all along! Just replaced it and testing write now! Thanks for that, it will take some time to show up so i will let you know soon!

Just wanted to say this is a RESOLVED issue. @mlsein was right thanks for pointing this out!