Shop OBEX P1 Docs P2 Docs Learn Events
create a string with serial input data — Parallax Forums

create a string with serial input data

William50William50 Posts: 22
edited 2011-12-01 06:21 in Propeller 1
I have a logging device sending serial data into the serial port. The first eight bytes of the data is a string header. After the header is sent I am storing the data that follows on a memory card.

I want to create a file on the memory card using the object "fsrw" and name the file using the string header. Is there a way to assemble the first eight ASCII header bytes into a string?

Cheers,

William

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-11-28 21:47
    William50,

    Make the 9th byte a Zero, and use the address of the first byte as the string address pointer.

    ...or you could 'copy' the data bytes using bytemove into a scratch pad area and essentially do the same thing. make sure the last byte is zero, and point to the first byte as the string address.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-11-28 22:51
    Depending on the reliability of the serial connection I'd do some checks before using such a string as filename. FSRW is not limiting the filename and you can use weird names to create a file. But you are not able to read those files later on on a PC. So, I'd suggest to do at least a range check for ascii characters/numbers.
  • William50William50 Posts: 22
    edited 2011-11-30 16:57
    Thank you for the replies.

    So if I create a buffer for the filename string such as:

    byte filename[8]

    I point to the string by:

    @filename

    Do I have this correct?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-12-01 06:21
    In fact you need to create a buffer with 9 bytes because you have to set the byte after the last character of the filename to zero, which is the string-end character.

    Don't forget the extension ... FILENAME.EXT ... so the buffer should in the end be 13 bytes with the dot being fixed at position [ 8 ] - hope I remember this right ;o)
Sign In or Register to comment.