Array of string to send with TX int ?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Thanks Henrik,
    It seems that ArrayWrite can't access program mem directly, this code didn't work, probably same for EEprom . Looks like it only works for ram to ram functioning.

    Code:
    arraywrite  snd_array ,[str str2,0]   (Didn't work)
    
    
    asm                        ;test tables at top of program mem
                     
    str1   org 0xb100             
        db  "<name=IDLE_TIME,value=",0 
     
    str2   org 0xb200   
        db  "<name=LONG,value=",0 
     
    str3   org 0xb300    
        db  "<name=IP Address,value= 192.168.1.3>",0 
      
    endasm
    like you said, I would have to build string-array piece by piece and send when done or send piece by piece out TX.
    I understand that the time it takes to send 600 chars @ 115200 is the same no matter how its sent, but the machine instructions to send by TX should be much less than HSER or SER. The main loop of 10X per second (100 milli sec per loop) should allow for about 300,000 instructions each .1sec loop without overrunning timer interrupt. The use of interrupts keeps all that constant.
    I think....

    don

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


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi Don,
    It's not clear to me exactly what your trying to do. You say that ARRAYWRITE doesn't access porgram space but that's exactly what it does. It takes data stored in program space and moves it to and array in RAM. It can also copy data from RAM to the array using one of many modifiers, like STR.
    Code:
    String_1 VAR BYTE 128
    String_2 VAR BYTE 64
    Value VAR BYTE
     
    Value = 123
     
    ARRAYWRITE, String_2, [" and this is the second part of the string.",0]
    ARRAYWRITE, String_1, ["This is the first part,", STR String_2, " The variable value is: ", DEC Value, 0]
    The STR modifer writes the contents of String_2 in this case to String_1. It stops when it sees the 0 padded to the end of String_2. I don't think it actually writes that 0 in which case we're in trouble....

    However, since I don't fully understand your problem I'm not sure this helps at all. If you have enough RAM to store the full 600+ bytes string you could build the string with a single ARRAYWRITE statement, pad a zero at the end and then enable the TX interrupt to have it sent in the background.

    I'm sorry if I'm completely missing the point here....

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi Don,
    Following up on my previous post.
    Code:
    String_1    VAR BYTE 100
    String_2    VAR BYTE 32
    Value       VAR BYTE
     
    Value = 123
     
    HSEROUT["Program start",13,13]
     
    ArrayWrite String_1, ["This is the first part ",0]
    ArrayWrite String_2, ["and this is the second part.",0]
     
    'Now join the two strings back and add the ASCII representaion of Value at the end.
    ArrayWrite String_1, [STR String_1, Str String_2, " The value is: ", DEC Value,13,0]
     
    HSEROUT[STR String_1]
    Pause 2000
    
    END
    The above gives the followin output:
    Code:
    Program start
    This is the first part and this is the second part. The value is: 123
    This shows that you can "build" strings (arrays) of data from constant data (program space), other arrays (RAM) and ordinary variables (RAM). I'm pretty sure you won't be able to move data from EEPROM to an array like this so you need to load that "manually" (FOR-NEXT loop or whatever).

    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    OK,
    I see you did it but, I don't know how string_1 re-writes itself while reading itself .
    If it works, then it works ! That will be how I will build an assorted string to send on TX int.
    Like you did on other post, its simple to: turn on TXint, send 1 complete array up to say, 0 then turn off TX.

    1 point of differ, to my understanding, all those arrays srt_1 and 2 are in RAM mem.

    strings and numbers stored in program mem is done with pokecode or writecode or in asm with dw,db or de.
    Those items need to be retrieved with peekcode or readcode into PB 1 char or word at a time.


    Code:
    asm                           ;strings placed at top of program mem if there is room
    str1   org 0xb100           ;this has to be placed at the end of code
        db  "<name=IDLE_TIME,value=",0 
    str2   org 0xb200   
        db  "<name=LONG,value=",0 
    str3   org 0xb300    
       db  "<name=IP Address,value= 192.168.1.3>",0   
    endasm
    this code places at lable str1, location B200 hex , db (data byte) <nam......etc
    I think, these strings, or which ever ones you wanted, would need to be loaded, 1 char at a time into somearray[] then acted on with arraywrite to make final send like you have done.
    don

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


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi don,
    I wasn't sure rewriting String_1 like that was going to work but it does. I guess it's pretty much the same thing as doing
    Code:
    A VAR BYTE
    A = A + 1
    1 point of differ, to my understanding, all those arrays srt_1 and 2 are in RAM mem.
    Yes, the arrays String_1 and String_2 are strored in RAM but when you do
    Code:
    ArrayWrite String_1, ["This is a string"]
    The actual, literal string (This is a string) which is loaded into the array is stored in program memory (where else would it be) and loaded from there into the array. So you can do:
    Code:
    ArrayWrite String_1,["<name=IDLE_TIME,value=",0]
    HSEROUT String_1
    ArrayWrite String_1 ["<name=LONG,value=",0]
    HSEROUT String_1
    Or manipulate it any way you see fit.

    The drawback with ArrayWrite and HSEROUT when using literal strings is the IMHO hugh space each charcter occupies. Each byte/character added to an ArrayWrite statement eats away 6 bytes of program space while the @db approach apparently bitpacks two charcters in each byte meaning it only takes 1/12 of the space. Obviously the drawback with THAT is you can't use ArrayWrite to move it from flash to RAM.

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    back to string_1 and 2, still wondering,
    Name:  Capture4.JPG
Views: 877
Size:  41.8 KB

    if you switch the order, will string still be made correctly,
    the way you have it coded, it just has to leave itself alone and add to it,
    but if it is moved in place then what ?

    don

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Yes, to prog mem..........easier to program

    then, to create different callable strings to use in PB,

    LabelA:
    ARRAYWRITE string_1,[string_1, "<more string added to string 1 etc"]
    Return

    LabelB:
    ARRAYWRITE string_1,[string_1, "<more other string added to string 1 etc"]
    Return

    etc

    use gosub to build up string, check string legnth somehow so don't overflow
    Zero out string_1 when want to start a new one

    Takes a little mem but f2525 has 48k

    don
    Last edited by amgen; - 16th August 2011 at 15:42.

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


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi,
    No, you're right, moving them around seems to create havoc.
    But still, it does allow you you concatenate multiple arrays into one, you can have one "master array" which is the one you eventually are going to send out and one smaller "working array" to which you fetch strings from code space (stored with db or whatever) and one by one add them to the "master array" before finally sending it.

    That is if the message sent is going to be different each time. If all the literal strings are the same and it's only data that changes them of course you there's no use in messing around with all this.

    I'm still not sure what exaclty you're trying to do (except sending arrays over a serial line) so I'm not sure if all this even helps.

    /Henrik.

    EDIT: When concatenting String_1 don't forget the STR modifier! And always add a 0 to the end, that's how the STR modifier knows when to stop.
    Last edited by HenrikOlsson; - 16th August 2011 at 15:52.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Helps very much, this setup will allow a remote terminal, of some type to request selected information and how often to send it out. So string parts may change, and parts may stay the same. It's a flexable layout with communication in the backround and a timing base type template.

    Thanks
    don

Members who have read this thread : 0

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