Shop OBEX P1 Docs P2 Docs Learn Events
P2 FlexBASIC program — Parallax Forums

P2 FlexBASIC program

Did something change as to how:
mount "/host", _vfs_open_host()
mount "/sd", _vfs_open_sdcardx(17, 18, 19, 20)
should be used. I am getting all kinds of errors, did I miss something?

Ray

' solsta3.bas
'
'June 17, 2021
'

'dim rpi as class using "spin/SmartSerial.spin"

'rpi.start(0,1,0,115200)


mount "/host", _vfs_open_host()
mount "/sd", _vfs_open_sdcardx(17, 18, 19, 20)

do
    pinhi(57)
    pausems 500
    pinlo(57)
    pausems 500
loop

"/home/pi/src/flexprop/bin/flexspin" -2 -l --tabs=2 -D_BAUD=115200 -O1 -I "/home/pi/flexprop/include" "/home/pi/programs/flexprop/flexbasic/solsta3.bas"
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
Version 5.5.0 Compiled on: Jun 17 2021
/home/pi/flexprop/include/libc/unix/mount.c:83: error: unknown identifier strlen used in function call
/home/pi/flexprop/include/libc/unix/mount.c:83: error: Unknown symbol strlen
/home/pi/flexprop/include/libc/unix/mount.c:84: error: unknown identifier strncmp used in function call
/home/pi/flexprop/include/libc/unix/mount.c:84: error: Unknown symbol strncmp
/home/pi/flexprop/include/libc/unix/mount.c:26: error: unknown identifier strncpy used in function call
/home/pi/flexprop/include/libc/unix/mount.c:26: error: Unknown symbol strncpy
/home/pi/flexprop/include/libc/unix/mount.c:29: error: unknown identifier strncat used in function call
/home/pi/flexprop/include/libc/unix/mount.c:29: error: Unknown symbol strncat
/home/pi/flexprop/include/libc/unix/mount.c:37: error: unknown identifier strlen used in function call
/home/pi/flexprop/include/libc/unix/mount.c:37: error: Unknown symbol strlen
/home/pi/flexprop/include/libc/unix/mount.c:38: error: unknown identifier strncmp used in function call
/home/pi/flexprop/include/libc/unix/mount.c:38: error: Unknown symbol strncmp
/home/pi/flexprop/include/libc/unix/mount.c:48: error: unknown identifier strcpy used in function call
/home/pi/flexprop/include/libc/unix/mount.c:48: error: Unknown symbol strcpy
solsta3.bas
mount.c
errno.c
fs9p_vfs.c
|-fs9p_internal.cc
fatfs_vfs.c
|-ff.cc
strncmp.c
strrchr.c
malloc.c
sdmm.cc
stat.c
malloc.c
vfs.c
strcpy.c
memset.c
child process exited abnormally
Finished at Thu Jun 17 18:27:03 2021

Comments

  • There is a bug that MOUNT isn't compiling correctly if there is no OPEN in the program. Nobody noticed this before because in practice MOUNT isn't very useful unless you do an OPEN later.

  • Thanks Eric. I did not use an OPEN, because I wanted to get an idea of how much memory those two were going to use.

    My new project will be somewhat more complex and will probably be using a lot of memory. Talking about MOUNT, have you considered UNMOUNT? Not sure how that would benefit a larger program, but maybe with external ram, which could be used like a ram disk, you could copy in/out stuff that is needed.

    With this new project I will be trying out segmented coding, meaning, build a small code segment, see how much memory it uses, and then see if it can be made tighter, and so on.

    Ray

  • I am now having problems with:
    dim rpi as class using "spin/SmartSerial.spin"
    it is not finding it. When I put in the full path, then it is showing errors, similar to the MOUNT errors.

    Ray

  • The program below now compiles without errors.

    Any suggestions as to how to get telnet part to work. I have the WiFi accessory plugged in, and seems to be working properly, but I am still missing something.

    Ray

    ' solsta3.bas
    '
    'June 17, 2021
    '
    
    const HEAPSIZE = 8192
    
    dim telnet as class using "spin/SimpleSerial.spin2"
    telnet.startx(63, 62, 0, 115200)
    open SendRecvDevice(@telnet.tx,@telnet.rx) as #3
    
    dim rpi as class using "spin/SimpleSerial.spin2"
    rpi.startx(0,1,0,115200)
    open SendRecvDevice(@rpi.tx,@rpi.rx) as #2
    
    
    
    mount "/host", _vfs_open_host()
    mount "/sd", _vfs_open_sdcardx(17, 18, 19, 20)
    
    do
        pinhi(57)
        pausems 500
        pinlo(57)
        pausems 500
        print #3, "Anybody there!"
    loop
    
    
  • You have the serial comms setup in software, but I dont see anywhere where you are reading or writing to that device. Am I missing something?

  • I have, in the do loop, print #3, "Anybody there!". When I used putty to connect, I expected to see "Anybody there!".

    Ray

  • Trifocals, funky coloration and a tiny phone screen gets me everytime…

  • Since I implemented the SD, I was looking for some code as to how to use it. Does anybody have a small test code example that creates a file on the SD, prints something to the open file, and then prints out what is in the file.

    Ray

  • Yup. I’ll post it when I get home tonight.

  • JRoarkJRoark Posts: 1,215
    edited 2021-06-19 00:41

    @Rsadeika Here you go. MOUNTs, writes, reads, and closes. Slash-and-burn code, but you get the idea.

    OPTION EXPLICIT                                                 ' no implicitly dec'd vars
    CONST HEAPSIZE = 8192                                           ' lots of elbow room
    
        dim a$ as string
        dim i as ubyte
    
        mount ("/sd", _vfs_open_sdcard())                           ' mount the file system at /SD node
    
        ' write some stuff
        print "Writing stuff to file..."
        open "/sd/test.txt" for append as #3                        ' open for append
        for i = 1 to 10
            print #3, "THIS IS A TEST - LINE "; str$(i); chr$(13)   ' print some stuff
        next i
        close #3                                                    ' close the file
    
        'read it all back   
        print "Reading stuff from file..."
        open "/sd/test.txt" for input as #3                         ' open for input
        do
            a$ = input$(64, 3)                                      ' get 64 chars (or less if eof)
            print a$;                                               ' print them
        loop until len(a$) = 0                                      ' keep going until eof
    
        close #3                                                    ' close file for safety before exit
        print "Done."       
    

    Output:

    THIS IS A TEST - LINE 1
    THIS IS A TEST - LINE 2
    THIS IS A TEST - LINE 3
    THIS IS A TEST - LINE 4
    THIS IS A TEST - LINE 5
    THIS IS A TEST - LINE 6
    THIS IS A TEST - LINE 7
    THIS IS A TEST - LINE 8
    THIS IS A TEST - LINE 9
    THIS IS A TEST - LINE 10
    Done.
    

    EDIT: For clarity, there is no attempt at any error handling here. Use THROW/TRY/CATCH to deal with mischief thrown by MOUNT, OPEN, etc.
    Hope this helps.

  • Ray: I think your use of SimpleSerial on pins 63 and 62 is conflicting with the built in printing code (and the host file system code, which also uses those pins). I'd recommend commenting out all the "telnet" stuff and just using plain print to print to the PC's serial port.

  • Something is weird. I am using the P2 Edge Mini breakout board and the P2 microSD add-on board.

    If you plug the SD board into the mini board, it looks like the GND sockets line up with the V16,5V pins on the mini board. I wonder if somebody that has those boards could verify that for me.

    If, for some reason, the SD board got mislabeled, what would be the correct numbers to use with FlexBASIC startx().

    Thanks JRoark for the example code, to bad I cannot test it out, just yet.

    The reason I want to get the telnet part to work is, I want more than one way to access the P2 board program that is running.

    Ray

  • Is it possible you have the SD adapter plugged in upside down?

  • Well, something happened, now flexprop says, can't find P2. I think electronics does not like me, I corrupt to many chips. Maybe I should find a cheaper hobby, or cheaper chips.

    Ray

Sign In or Register to comment.