Shop OBEX P1 Docs P2 Docs Learn Events
Troubles convert a long into string for C3 + SD-Card (write string to file (sdcard) — Parallax Forums

Troubles convert a long into string for C3 + SD-Card (write string to file (sdcard)

nomadnomad Posts: 276
edited 2013-01-27 03:24 in Propeller 1
hi,
i am working with the C3-board and the SD-Card
please have a look to my oldThread " Troubles with PropC3 and SD-Card"

i am working with c3-quadV2-SD-01.spin (its adapted from ggg558877)
and with dave_fsrw.spin (from Dave Hein)

in the moment the code works with static strings
a) in the DAT Section or
b) str := "4"

all stuff ok
but i would work with my DummyDatas (aka GPS-Datas) as

Long latfloat := 47.51332

in the "dave_fsrw.spin" - drive
i can do with

sdcard.pputs(@str) or
sdcard.pwrite(@str,8)

but i have big troubles to convert the latfloat to a stringBuffer which is correct
for pputs or pwrite ?
in the c3-quadV2-SD-01.spin you find some experiments
result : not printable chars ?
have somebody a way to solve this problem ?

attachments:
- c3-quadV2-SD-01.spin
- dave_fsrw.spin


thanks for help and hints
regards nomad

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-01-26 04:57
    ' this is wrong: gpsstring := FS.FloatToString(latfloat)
        ' term.str(@gpsstring)
    
    Here gpsstring already holds the address of the converted string. In order to print it a simple term.str(gpsstring) is sufficient. Note that pputs and pwrite also just take an address value (e.g. result of FloatToString) so @ isn't required.
    CON
      _clkmode = XTAL1|PLL16X
      _xinfreq = 5_000_000
    
    OBJ
      serial: "FullDuplexSerial"
        fstr: "FloatString"
    
    VAR
      long  latfloat
    
    PUB null
    
      serial.start(31, 30, %0000, 115200)
      waitcnt(clkfreq*3 + cnt)
      serial.tx(0)
    
      latfloat := 47.51332
      serial.str(fstr.FloatToString(latfloat))
      serial.tx(13)
      
    DAT
    
  • nomadnomad Posts: 276
    edited 2013-01-26 21:28
    hi kroneko
    thank you for your help :-)
    today i make with your snippets some experiments
    and make then a reply
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-01-27 03:24
    hi kuroneko
    many thanks for your code.
    its running with

    - 1 write dummyDatas (lat,lon,alti) into gps1.txt of the SD-Card
    - 2 read dummyDatas in 1 line to PST

    --- code
    - WRITE
    sdcard.pputs(fstr.FloatToString(latfloat))
    sdcard.pputs(" ")
    sdcard.pputs(fstr.FloatToString(lonfloat))
    sdcard.pputs(" ")
    sdcard.pputs(fstr.FloatToString(GPSaltitude))

    - READ to PST
    bytefill(@sbuf, 0, BUF_SIZE) ' clear buffer
    readln(@sbuf, 80) ' read line from file
    term.str(@sbuf)

    as attachment a screenshot as
    - test-kuroneko-2701.jpg

    thanks for your help :-))

    regards
    nomad
    1024 x 536 - 72K
Sign In or Register to comment.