02-18-2010 01:23 AM
I am trying to read serial buffer using Basic Serial Read and Write example....I am able to communicate properly...As I am sending data continuously I am not able to do one to one data matching at labview....
My situation is : In a one loop I am sending 4 bytes in tendom like....Addr, data1,data2 and checksum....as I am transfering different addresses for differnt variable...address is predefined so I can use that at labview to compare and store the variable...each address define each variable...
my problem is that....I receive 80 to 100 bytes per 500mS(wait before read) in the buffer....now how to point out the 4 consequetive bytes having addr,data1,data2and check so that I compare the addr and store the data in the variable pointing that address......
I have tried string to byte array converter and then given to byte array....but unable to point out this sequence of 4 bytes......
As I am receiving 80 to 100 byted per 500mS that means 20 to 25 variables may be coming in that span.......
I hope I explained the question properly...
Waiting for reply.....
02-18-2010 03:09 AM
since the four data i.e "Addr, data1,data2 and checksum" are known to you and the same thing you are reciving from the device (or what ever it could be) with some additional data (80 to 100) why dont you perform a serach option? something like this? Give a shot and let me know this is a piece of code from one of my proj..
02-18-2010 05:45 AM
I will try your code....
"since the four data i.e "Addr, data1,data2 and checksum" are known to you " for this only addr is known rest three depends on data.....
Take a example....
I have 4 varaibles....
Variable1- addr1,data1,data2 and "chek=addr+data1+data2"....likewise variable2,variable3 and variable4 all having different address and different data and so diff. check...
Now If I can search addr in the buffer then I need to take next 3 bytes as a data1,data2 and check...and then comparing check value by adding data to address..if found correct I can assign that value to that variable....likewise I can accept 4 variables....
this sequence should be continuous as I am sending data continuously.......