Menu

hsergetstring

wn
2017-12-10
2017-12-11
  • wn

    wn - 2017-12-10

    Is there a buffer size limitation on the hsersgetstring? Is there a way around it?

    thanks.

     
  • mmotte

    mmotte - 2017-12-10

    Yes, Look in Help under variables string and you will find the default length.

    10 bytes for chips with less than 16 bytes of RAM.
    20 bytes for chips with 16 to 367 bytes of RAM.
    40 bytes for devices with more RAM than 367 bytes.
    I have not tried this but you may be able to

    Also read:
    To change the default string size handled internally by the Great Cow BASIC compiler you add increase/decrease the default string size

    'To define the default string size as the follows constant.
    #define STRINGSIZE 24
    

    Defining a length for the string is the best way to limit memory usage. It is good practice if you need a string of a certain size to set the length of a strings, since the default length for a string variable changes depending on the amount of memory in the microcontroller (see above).

    To set the length of a string, see the example below:

    'Create buffer variables to store received messages as 16 bytes long
    Dim OutBuffer As String * 16
    

    In this case the buffer is HSerString.

    Remember two things:
    1) HSerString(0) contains the length.
    2) 13, 0x0D, Carriage return terminates the entry, hsersgetstring can wait forever for this end

    BR
    Mike

     
    • wn

      wn - 2017-12-11

      Thanks! Excellent info.

       

Log in to post a comment.