We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › wrong data arrives at the serial port
Page Index Toggle Pages: 1
wrong data arrives at the serial port (Read 617 times)
wrong data arrives at the serial port
Mar 26th, 2008, 2:40pm
 
hello
me also got some problems with the serial communication between ardunio and processing.
so i try to send some ints down to the arduino.
basically only 5 ints, 0 or 1.

ok, here is my sending function in processing:

***********

void communicator(){
 if(lineCounter == 5){
   lineCounter = 0;
 }
 for(int i = 0; i < anzahlVentile; i++){
   //println("i=" + i + ", lineCounter="+lineCounter);
   myPort.write(zeilenWeise[lineCounter][i]);
   println("gesendet wird: "+ zeilenWeise[lineCounter][i]);    
 }
}

*******
as you see, with the println("gesendet wird:...") i check what ints will be sent. and i see, that this are the correct ones. they are stored in a 2d array.


ok. then my reading functino in arduino:

*********
void serialReader(){

 Serial.println(Serial.available());
 while (Serial.available() < 5) {
   delay(10);
 }
     pins[0] = Serial.read();
     pins[1] = Serial.read();
     pins[2] = Serial.read();
     pins[3] = Serial.read();
     pins[4] = Serial.read();
   }

**********



so, it should wait, until the 5 bytes have arrived, and then go for it an put it in a new array called pins.


ok, whats happening, is, that some data will be arriving. but not in the correct order and not the right ones i think.





anyone got a possible solution for my problem?

setup:
mac osx 10.5.2 intel
processing 135
arduino 10
arudino diecimilla


thank you
n
Page Index Toggle Pages: 1