HSERIN string starting index ?


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default HSERIN string starting index ?

    Hello everyone .. Gotta mind confusing question about a very favorite command HSERIN ..
    Let's say I'm capturing bytes on USART and I have an INDEX variable called x and these x variables are within an 100 array size ..

    Is there a possible way to set an index in the command starting with a specific number ? such as ?

    hserin 60000,main,[str x[5]\90]

    I need to do this because I need the data in x[0],x[1],x[2],x[3],x[4] variables ..
    What I'm actually asking is if this command syntax is true and fine for purpose ?

    Thansk in advance ..
    Last edited by gunayburak; - 30th June 2016 at 17:35.
    - Ipsa scientia potestas est -

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

    Default Re: HSERIN string starting index ?

    if the array offset is always a constant value ,
    declare another var with that offset to use as a pointer using the EXT modifier

    eg
    x var byte[100]
    y var byte EXT

    asm
    y = x+5
    endasm

    hserin 60000,main,[str y\90]
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: HSERIN string starting index ?

    I am not familiar with this EXT statement .. What does it do exactly ? Can you please explain ?
    - Ipsa scientia potestas est -

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,316

    Default Re: HSERIN string starting index ?

    Is there a possible way to set an index in the command starting with a specific number ? such as ?
    hserin 60000,main,[str x[5]\90]
    That would be my first test as well, I know it compiles and since [5] is just an offset I would asume it works but since you're asking you've must have tested it and found that it didn't, so I'm curious, what did it do?

    I am not familiar with this EXT statement .. What does it do exactly ? Can you please explain ?
    http://www.picbasic.co.uk/forum/showthread.php?t=3891

    /Henrik.

  5. #5
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: HSERIN string starting index ?

    Hello Henrik I really can't figure out if it is working or not , so I can't say a certain thing about that because sometimes it seems working as it should and sometimes it doesn't .. I'm really not sure , that's why it a complex situation .. I need to observe and make other tests even need to modify my code to understand if it is properly working(I'm speaking for my code and by the way I could have tested it with a simple simulation code yet I haven't done so far because of being busy with a very long code my mind is like a trash )
    - Ipsa scientia potestas est -

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,316

    Default Re: HSERIN string starting index ?

    Tried the following code:
    Code:
    i       VAR BYTE
    Array   VAR BYTE[128]
    
    PAUSE 3000
    
    Main:
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 0, don't use '0'", 13]
      HSERIN[STR Array\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 12, don't use '0'", 13]
      HSERIN[STR Array[12]\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 3, don't use '0'", 13]
      HSERIN[STR Array[3]\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 21, don't use '0'", 13]
      HSERIN[STR Array[21]\6]
      GOSUB Echo
      
      Goto Main
    
    Echo:
    For i = 0 to 31
        HSEROUT[Array[i], " "]
    NEXT
    HSEROUT[13,13]
    RETURN
    
    ClearArray:
        For i = 0 to 31
            Array[i] = "0"
        NEXT
    RETURN
    And, sending the string "123456" it gives the following results:
    Code:
    Send 6 bytes, these should end up starting at index 0, don't use '0'
    1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 12, don't use '0'
    0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 3, don't use '0'
    0 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 21, don't use '0'
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 0
    Seems to work exactly as expected. One thing you need to watch out for is to not write outside of the array since that will corrupt the variable(s) being stored there - but that's not specific to this method.

    /Henrik.

  7. #7
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103

    Default Re: HSERIN string starting index ?

    Wouww .. Thanks for the great effort , now it has opened up both my mind and the way to the future ideas ... Really Henrik , you're my hero after Darrel ...
    - Ipsa scientia potestas est -

Similar Threads

  1. Hserin parsing string...again?
    By kevlar129bp in forum Serial
    Replies: 21
    Last Post: - 9th July 2012, 17:35
  2. HSERIN for variable length string
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th February 2010, 06:58
  3. How to index Port variable
    By jpadin1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th February 2010, 11:36
  4. How to convert a HSERIN string to a hex value?
    By ShortBus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd October 2009, 05:41
  5. parsing string from hserin
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2009, 19:42

Posting Permissions

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