Shop OBEX P1 Docs P2 Docs Learn Events
getstr in FullDuplexSerialPlus — Parallax Forums

getstr in FullDuplexSerialPlus

J^3J^3 Posts: 121
edited 2010-10-22 22:12 in Propeller 1
Good Evening,

I am confused about the use of getstr in FullDuplexSerialPlus.

From looking at the comment in the method it appears that getstr will get a string that terminates with a 0 and store it at the memory address of stringpntr. But how would you read in the bytes of a particular string. Am I totally off track?

Any help would be appreciated. Thanks.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-10-22 21:54
    It gets (receives via the "PUB rx : rxbyte" function) bytes from an external serial data source until it encounters a cr (13).
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-22 21:56
    getstr gets a string that's terminated by a carriage return character (13) and stores it in the byte array that starts at the address given as a parameter. A zero byte is substituted for the carriage return because that's the convention for a terminating byte for a character string. Each character string you want to store has to be defined as a byte array large enough to hold the string plus the terminating zero byte. There's not much available built into Spin to manipulate the stored string. You can move it with BYTEMOVE. You can determine its effective length with STRSIZE and you can compare it for equality to another string with STRCOMP. You can also define string constants with STRING. In all cases, the string is represented by its starting address.

    There are objects in the Object Exchange for doing more complex manipulation of strings using subroutines. Look at "String Library" and "Strings Library". Also look at "Numbers".
  • J^3J^3 Posts: 121
    edited 2010-10-22 22:12
    Thank you,

    I will check out those objects.
Sign In or Register to comment.