You might be having trouble with the "escape" byte used to preface certain values. If it is used it will add an extra byte to the stream. See all the teps and the octavetech document that get referenced on this list about every 3 months...
MS Joey Wilson wrote: > Hello all, > > I am trying to read data directly from the serial port, using Matlab and > the Basestation tinyos program. When I use the "java > net.tinyos.tools.Listen" program, it appears that all my packet data is > being received by the basestation correctly. However, I would like to > read the data directly into matlab. I am attempting to use the > following matlab code to read 10 packets. > > ******************************************************** > s = serial('/dev/ttyUSB0','BaudRate',115200); > fopen(s); > counter = 0; > while(counter<10) > if (s.BytesAvailable > PACKETSIZE) > packet = fread(s,PACKETSIZE) > counter = counter+1; > end > end > ********************************************************* > > Now, the problem that I am having is that the alignment of each packet > coming in can be different. For example, if I know the 3rd byte is the > node ID, I try to read the 3rd byte. This shifts around though, so I > can't parse the data consistently. I think it is happening whenever a > packet is corrupted/dropped over the radio. Does the basestation > program do something to compensate for corrupted packets that I am not > taking into account in my matlab code? > > Is there a better way to read the serial data directly into matlab > without having these parsing issues? Any help is appreciated. Thanks. > > -Joey > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help _______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help