SERIN from a large string


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Red face SERIN from a large string

    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.....

    Code:
    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
    Padawan-78

  2. #2
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Default

    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....

    Code:
    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
    Padawan-78

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    NAH.

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

    Code:
    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?
    Last edited by mister_e; - 2nd May 2008 at 21:00.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Default

    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.
    Padawan-78

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Talking

    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
    Padawan-78

Similar Threads

  1. How about String Variables?
    By mytekcontrols in forum PBP Wish List
    Replies: 40
    Last Post: - 20th January 2015, 12:53
  2. String Seperation
    By Tobias in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th November 2007, 19:32
  3. serin string question
    By Sam in forum Serial
    Replies: 11
    Last Post: - 2nd December 2006, 21:29
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  5. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts