loading
 
Socket Client data to Variable
Steve Woodrough from United States  [47 posts]
9 year
STeven,
I'm successfully getting TCP data sent to me from a radar device. Data looks like this and updates at 1 Hz:

00265: CD005000000000<cr>  

Now what I want to do is take the "005" field and assign that to a variable named: SPEED that will be displayed on the video.

I'm sure this is easy, I'm just not sure how.  
Thank You
Steve  
  
Steven Gentner from United States  [1446 posts] 9 year
Steve,

Its a bit tricky since you want to extract out the middle field. There was a way to do this but to simplify things we added a new way to read in a string of a certain length. If you download the latest version you can use

[line]: CD\3[speed][other]<cr>

to parse that string. The \3 indicates how many chars to read into the variable 'speed'. Note while you don't need the 'line' and 'other' those are just used to read in data that can change just to ensure that a complete line is read in otherwise the data may become confused.

v2.78.0 has this update.

If you have an older version and CANNOT upgrade that would be

[line]: CD\[d1]\[d2]\[d3][other]<cr>

and then you'd have to create the string from the d variables ... which you DON't need to do with the latest version using the first sequence above.

STeven.


Steve Woodrough from United States  [47 posts] 9 year
STeven,
I downloaded the upgrade and trying to interpret and appply your guidance above.  Attached is my work file thus far.    
On a separate note I will look into port forwarding my cameras for your review.  
Thanks,
Steve
program.robo
Steven Gentner from United States  [1446 posts] 9 year
Ok, did you try adding the receive sequence mentioned above to the Socket Client module? I don't see that in your attached robofile. Obviously since I don't have the device I can't test it.

STeven.
Steve Woodrough from United States  [47 posts] 9 year
OK, got it, we're in business with that portion.  I just did not know where to put the commands.   My only other request on this matter is a way to make the data persist until it changes.  Right now the [SPEED] data flashes up for ~100 msec until the next update a second later.  Otherwise it works.  I'd love to know what the syntax is saying, etc. but that can wait for another day.  Next thing is to get you access to my camera data later tonight.  
Thanks  Steve  
Steven Gentner from United States  [1446 posts] 9 year
Try removing the Set Speed = "" in the second line of the pipeline. :-)

Or at least select the "set once" checkbox.

STeven.
Steve Woodrough from United States  [47 posts] 9 year
Getting rid of set speed fixed it.  I'm thinking, and there in lies the problem, that I had to "declare" the variable.  
Steven Gentner from United States  [1446 posts] 9 year
Normally that's a good thing! The reason the "set once" checkbox is there is for initialization. Otherwise, RR is a 'declared when used' system unlike programming languages. :-)

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