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 & HelpSyntax Questions › Passing An Array...
Page Index Toggle Pages: 1
Passing An Array... (Read 375 times)
Passing An Array...
Apr 2nd, 2009, 8:50pm
 
Hi..!!

Can anyone help me please

i have made a motor speed control system using my HC11 as a school project, i also plotted my output response in excel and i got to say it was pretty good. i am now planning to have a processing applet which would plot the o/p response in "real-time"

Note: i have an array of 3 numbers that could go up to 1000dec each therefore, 2bytes each. my problem is not sending it out to processing but rather receiving it with processing. the string starts with a 0x0A(carr return) and then 6 bytes. anyone knows of a way that i can receive the 6 bytes plus 1sync byte and then separate them into 3 numbers(int).

i would appreciate any help i can get.. i have high hopes..

Thanks,
Swalehm
Re: Passing An Array...
Reply #1 - Apr 3rd, 2009, 3:56am
 
It should be quite easy:
Code:

byte[] data;
//recieve data here, I'm not an expert in that bit...

int a,b,c;

if(data[0]==0x0A) //check the data is starting right
{
//if data is most significant byte first:
a=(data[1]<<8)+data[2];
// else
a=data[1]+(data[2]<<8);

b=(data[3]<<8)+data[4]; //MSB first, change as above...
//etc..
}


Page Index Toggle Pages: 1