PDA

View Full Version : SERIN from a large string



earltyso
- 2nd May 2008, 20:43
Hello again,

I have a nifty project where I am taking in a data string from a "black box" we'll call it for now, and I only want one peice of data from the string.
I have attached a few samples of the string.... from my hyperterminal I figured out that the black box is sending out data at 9600 8N1 around 10x a second.

DEPTH 250.0 Ft SPEED 0.0 F/mTENSION 0 Lb

Here is the deal, All I want to store from this data (into a variable) is the depth...250.
That's it, I only need the first 3 sigfigs, I don't need speed or tension.

Here is how I think I will handle this.....



D0 var word
SERIN PORTA.?, N9600, ["DEPTH", D0]


Depth will be my qualifier, I am not sure if the depth is being sent from the blackbox as one word, or a byte per digit (character)???
How can I not take in the rest of the data until the qualifier is met again?
Am I on the right track?

thanks for any help

earltyso
- 2nd May 2008, 21:24
OK,
looks like I need to use the more powerful SERIN2 command,
I have not had a chance to try it yet, but I am moving more towards something like this....



SERIN2 PORTA.?,84,[SKIP 5,DEC5 B0]


I need up to 5 decimal places for my depth as my tools can go 20,000+ feet underground

mister_e
- 2nd May 2008, 21:57
NAH.

SERIN would work, SERIN2 too and so DEBUGIN a well.


SERIN2 ..... [wait ("DEPTH "), DEC3 WordVariable, SKIP 1, DEC1 ByteVariable]

Or use an array and remove the dot... there's some danger here... what the string looks like when you receive 20,000.0 Feet?

About now?

earltyso
- 2nd May 2008, 22:20
You placed a space after depth, is this necessary?
As are spaces in a string considered characters?
if so....
What if the space between depth and the MSF changes depending on depth?
Also, I think there may be some space between DEPTH and the left screen on my hypterminal....this space changed depending on when I disconnected and reconnected the terminal to the black box.

mister_e
- 2nd May 2008, 22:24
You could still wait for "DEPTH" and receive an array of x character... then you just need to parse your character one by one. If one in the list is not a decimal number, you just remove it.

And yes, space is a character, i've never tried with space before DEC, in theory it has to work, but for sure, the decimal point will cause some problem using DEC modifier.

earltyso
- 2nd May 2008, 23:23
Steve,
You were totally right!
I was using 84, instead of 16468, after my pin,
that's what was hanging up my program.
Now everything is working great!

thanks a 10^100,000