Hserin with Array


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2012
    Location
    South Carolina, USA
    Posts
    18

    Default Hserin with Array

    I am taking in data with Hserin and want to start keeping the data after I see "OK" and then stop after I get "HTTP". Is there any way to make the variable "hits" a array with unknown length. I know how to make it a large fixed array ( str test8/144) but does not seem to work between two waits. Can someone tell me if this is possible


    Code:
    dummy VAR BYTE
    Hits VAR BYTE
    test8 VAR BYTE[144]
    
    Main:
     HSERIN[WAIT ("OK"), Hits, WAIT ("HTTP"), DUMMY]
     HSEROUT [hex Hits,13]           ' Debug
     GoTo Main

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,607

    Default Re: Hserin with Array

    Is there any way to make the variable "hits" a array with unknown length
    no the array must be a predefined size, although you can stop filling it when an optional character is encountered



    hserin [WAIT ("OK"),STR Hits\n{\c}]
    Receive string of n characters
    optionally ended in character
    if c was to be 58 the var hits would fill until full or a : (chr58) is encountered

    anything more would require your own routine

  3. #3
    Join Date
    Feb 2012
    Location
    South Carolina, USA
    Posts
    18

    Default Re: Hserin with Array

    Thanks Richard,

    I went ahead and set the array a little larger than I needed.

    Code:
    dummy VAR BYTE
    Hits VAR BYTE
    test8 VAR BYTE[44]
    ESP1 VAR BYTE[2]
    ESP2 VAR BYTE[2]
    
    Main: 
    HSERIN[WAIT ("GET"), str test8\44]      ', WAIT ("GET") and load data
    hserout [str test8\44, 13, 13]
    arrayread test8, 43, mAIN,[wait ("ESP1="), STR esp1\2]
    arrayread test8, 43, mAIN,[wait ("ESP2="), STR esp2\2]
    hserout ["ESP1=", STR esp1\2, 13]
    hserout ["ESP2=", STR esp2\2, 13]
    
    GoTo Main

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,253

    Default Re: Hserin with Array

    Byte banging. :-)

    I'd test using only one byte instead of array. I'd Hserin wait for start character, process byte (could be moving into 256 byte array, increment bytes found counter), Hserin byte, goto process byte until receive end character, process array, start over.

    Start-end can be anything you won't usually receive #$%&*+<>~|√πΔ€^{}/\!™℅[]?().

    Hserin one byte multiple times might be more efficient than always receiving a large array, or it might not.

    Robert
    Last edited by Demon; - 11th December 2014 at 18:58.

  5. #5
    Join Date
    Feb 2012
    Location
    South Carolina, USA
    Posts
    18

    Default Re: Hserin with Array

    Robert,

    I started off in that direction but ended up confused in the loop trying to pull out parts of the array (GET /?ESP1=R1&ESP2=R2&ESPx=%25 HTTP/1.1) and separate the parts for ESP1 and ESP2 vars. I will definitely revisit it before moving to far forward.

    John

Similar Threads

  1. Hserin Array Question
    By Hylan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th May 2012, 02:39
  2. Copying Array to Array
    By vamtbrider in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th April 2010, 01:12
  3. Bit/Byte array for Hserin/Hserout
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st September 2006, 23:07
  4. Custom array of ports using array?
    By blainecf in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 18th June 2006, 01:43
  5. Word array behaving like byte array.... wierd
    By forgie in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd August 2005, 15:43

Posting Permissions

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