STR ArrayVar question


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    May 2011
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: STR ArrayVar question

    Hi Henrik, thanks for the welcome and the information.

    There are 8 bytes in the "string" sent as 8N1 so it's "Start 192 Stop" "Start 28 Stop"... (sorry for the clumsy formatting, I don't know how else to say it). So it's the last example you gave I think. From your example it seems that the first three bytes are "thrown away" and the array doesn't start to be filled until the the WAIT condition is met. In this case these initial values must be stored as well for the checksum calculation.

    I had a similiar related problem in that I wanted to use the STR ArrayVar to send a string to a "serial LCD" (as you show in your example). The array contains numbers, not characters. If I filled the array with characters ("A","B","C") it worked fine. If a number (192,28,36,etc.) was in the array it was not displayed on the LCD as a decimal value. I know that when sending a number by itself with HSEROUT I use the modifier DEC but this doesn't work with STR so I resorted to a FOR/NEXT loop to send the data.

    Thanks again.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: STR ArrayVar question

    Hi,
    That "clumsy formating" makes perfect sense so yes, it would be the last example. And yes, with WAIT or WAITSTR it does wait for the specified qualifier(s) and THEN start "saving". I guess, since you know what the qualifiers are, you should be able to add those bytes back in "manually" when you do the checksum?

    It's all just numbers, as you know a byte can hold a value between 0 and 255. If myVAR holds the value 65 and you do HSEROUT[myVAR] to a terminal (or your serial LCD) you'll get "A" because 65 is the ASCII code for "A". But if you want the numeric value 65 to be displayed PBP needs to send two bytes, namely 54 and 53 which are the ASCII codes for "6" and "5" and this is what the DEC modifier does. There's no way for the STR modifier to know if/when you want it to send "6", "5" instead of 65.

    If your had your values in an array you could, instead of a for-next loop simply done something like:
    Code:
    HSEROUT [#myArray[0], #myArray[1], #myArray[2]]
    Don't know which are the most effective, time- or codewise but it's an alternative. Ah, you get it.

    /Henrik.

  3. #3
    Join Date
    May 2011
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: STR ArrayVar question

    LOL - yes, I get it. I think from an "ease of use" I'll stick with the FOR/NEXT loop (less typing than all those array vars) .

    Thanks again for the help.

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