Lookdown command the result not consistent


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    I forgot to mention -

    If you want to grab the data and don't want to sit around and wait to see if it is OK,
    you can use the following structure:


    Code:
     
    Parse01: Cmd=01 : ARRAYREAD Data_Array,20,Parse02,[WAIT("Status1?")] : GOTO Foundit
    Parse02: Cmd=02 : ARRAYREAD Data_Array,20,Parse03,[WAIT("Status2?")] : GOTO Foundit
    This is a small part of a command parser that I'm currently using. The data you want to test is placed in the array "Data_Array", it will look at the first 20 characters (of course you can change that), and if it finds "Status1?" it jumps to FOUNDIT: and Cmd contains the line where it was found (in this case, 1). If "Status1?" is not found in the string, it jumps to line 2, and checks for "Status1?"
    etc.
    Charles Linquist

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Quote Originally Posted by Charles Linquis View Post
    I forgot to mention -

    If you want to grab the data and don't want to sit around and wait to see if it is OK,
    you can use the following structure:


    Code:
     
    Parse01: Cmd=01 : ARRAYREAD Data_Array,20,Parse02,[WAIT("Status1?")] : GOTO Foundit
    Parse02: Cmd=02 : ARRAYREAD Data_Array,20,Parse03,[WAIT("Status2?")] : GOTO Foundit
    This is a small part of a command parser that I'm currently using. The data you want to test is placed in the array "Data_Array", it will look at the first 20 characters (of course you can change that), and if it finds "Status1?" it jumps to FOUNDIT: and Cmd contains the line where it was found (in this case, 1). If "Status1?" is not found in the string, it jumps to line 2, and checks for "Status1?"

    etc.

    I am sure it was supposed to be "Status2?", just to avoid any confusion here.
    And the previous example was indeed nice; smart.
    This second one is also nice (at least for me).
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    No.

    Suppose that you have an input routine where a computer sends you a bunch of commands to parse, and you have to decode those commands. In my case, I have 45 different commands that I have to respond to. Two of those commands are "Status1?" and "Status2?". My incoming packet (it actually is a pre-processed Ethernet packet) is loaded into Data_Array.

    Say the packet contains "Status2?"

    In the first line in the code example above, I look for "Status1?" in the first 20 characters. Since it doesn't exist, I don't get a match and I jump to line 2 and search for "Status2?" in Data_Array. If it finds "Status2?" (which it will), then I jump to Foundit, and CMD = 2. A SELECT CASE structure using CMD then goes and performs the right thing.

    Another tip for those of you who handle a lot of strings (or ARRAYS as they must sadly be called in PBP):
    It is often very convenient to make the first element of the array (element 0) the length of the array.
    Charles Linquist

  4. #4
    Join Date
    Feb 2009
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Quote Originally Posted by Charles Linquis View Post
    I forgot to mention -

    If you want to grab the data and don't want to sit around and wait to see if it is OK,
    you can use the following structure:


    Code:
     
    Parse01: Cmd=01 : ARRAYREAD Data_Array,20,Parse02,[WAIT("Status1?")] : GOTO Foundit
    Parse02: Cmd=02 : ARRAYREAD Data_Array,20,Parse03,[WAIT("Status2?")] : GOTO Foundit
    This is a small part of a command parser that I'm currently using. The data you want to test is placed in the array "Data_Array", it will look at the first 20 characters (of course you can change that), and if it finds "Status1?" it jumps to FOUNDIT: and Cmd contains the line where it was found (in this case, 1). If "Status1?" is not found in the string, it jumps to line 2, and checks for "Status1?"
    etc.
    Nice! Another way to check for the string.
    ARRAYREAD Data_Array,20,Parse02,[WAIT("Status1?")] : GOTO Foundit

    I will try it tomorrow during debugging. Will update to you the result.

    TQVM



  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Quote Originally Posted by Charles Linquis View Post
    This is a small part of a command parser that I'm currently using. The data you want to test is placed in the array "Data_Array", it will look at the first 20 characters (of course you can change that), and if it finds "Status1?" it jumps to FOUNDIT: and Cmd contains the line where it was found (in this case, 1). If "Status1?" is not found in the string, it jumps to line 2, and checks for "Status1?"
    etc.

    Charles, don't you have typo in the red?

    That is what I was saying.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Sorry, yes I did have a type. It looks for STATUS2? in the second line. My apologies.
    Charles Linquist

  7. #7
    Join Date
    Feb 2009
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Dear Charles,
    Today i try to debug the command code u suggest,

    1) serin2,PORTC.4,16390,1000,NotFound,[WAIT ("CB2E")] --- Result OK.....can detect the string.

    2) my code,

    GET_DATA:
    ' SERIN2 PORTC.4,16390,5000,NotFound,[wait ("C82F")]
    serin2 PORTC.4,16390,5000,notfound,[DATA_array]
    ARRAYREAD data_array,256,NOTFOUND,[wait ("C82F"),serstring1,serstring2]
    debug serstring1
    debug serstring2
    goto REV_DATA
    NotFound:
    debug "Not Found",10,13
    pause 1000
    goto RESET_

    Data stream:
    A5 5A C0C05E
    A5 5A 0E2E 21 00 00 00 00
    A5 5A 0E70 26 FE 00 00 00 00 FF
    A5 5A C870 26 FE 00 00 00 00
    A5 5A C82F
    A5 5A 0E2E 20 00 00 00 00
    A5 5B 0CC2 00
    A5 5A C2D2
    A5 5A 060F 00

    Result: i get "Not Found" but not the serstring1,serstring2 that i debug. I wonder why this happen to the command "Arrayread"?

    TQVM

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    I don't know exactly what you are trying to do, but the code below works.

    Code:
     
            CR CON 13
            LF CON 10
     
             Data_Array VAR BYTE [30]
             AfterString1 var byte [10]
             AfterString2 var byte[10]
             ArrayWrite AfterString1,[REP 0\10]  ; Zero out the strings
             ArrayWrite AfterString2,[REP 0\10]
     
     
     
     
     
          ArrayWrite  Data_Array,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S",0]
     
     
     
     
     
          Arrayread Data_Array,20,NotFound,[Wait ("CDE"),STR AfterString1 \6,STR AfterString2 \6]
     
          hserout [CR,LF,"AfterString1 ",STR AfterSTring1,CR,LF]
         hserout [CR,LF,"AfterString2 ",STR AfterSTring2,CR,LF]
          goto home
     
    notfound:
     
         hserout["Not Found"]      
     
    home:
     
       goto home
    Charles Linquist

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