loading
 
Serial receive - order
Roland from South Africa  [97 posts]
3 years

Hi

Is there a simple way to set the receive order of variables?

Often, a device would send out a <cr> or <lf> that one uses as a marker, but in this case I have no control of the receive string format.

If I send out;
\01\02\03

and I have;  \[a]\[b]\[c]     as the receive variables

the received variables can be;
abc
123
231
231
312

How can I get an order without sorting the variables in a VB script?
The device I'm using sends a string format that I cannot modify, something like;
55 aa 01 00 01 00

What I would like to do is simply receive the sequence in the order that it come in
\[a]\[b]\[c]\[d]\[e]\[f]

where "a" will always receive the first character,  in a similar way to the console window.



 
Roland from South Africa  [97 posts] 3 years

Ok, I wrote a simple 'if' script to sort them.

It would have been nice if I could have used something like;

<85> <170> in the same way that one uses;
<lf>  <cr>

Ie the parenthesized figures, of choice, determine the string match

Regards
Roland
Steven Gentner from United States  [1371 posts] 3 years
Yes, that what

\255\0\[left_motor]\255\1\[right_motor]

in the serial module documentation is referring to. 255 is often used as a sync char which is what you were looking for. So in your case

\85\170

should do the trick.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index