Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic: How to use PropBasic in SimpleIDE !!! - Page 2 — Parallax Forums

PropBasic: How to use PropBasic in SimpleIDE !!!

24

Comments

  • BeanBean Posts: 8,129
    edited 2013-08-16 19:32
    I am just installing it now too...

    I have used it before, so I don't expect any real problems. Just a few minor glitches that need fixed.

    Bean
  • David BetzDavid Betz Posts: 14,511
    edited 2013-08-16 19:34
    Bean wrote: »
    I am just installing it now too...

    I have used it before, so I don't expect any real problems. Just a few minor glitches that need fixed.

    Bean
    I can probably build a Linux version too if that would be helpful.
  • BeanBean Posts: 8,129
    edited 2013-08-16 19:37
    Yes, that would be most helpful.
    Better to keep the number of people involved to a minimum.

    Thanks again.

    Bean
  • jmgjmg Posts: 15,144
    edited 2013-08-16 20:37
    Bean wrote: »
    I am just installing it now too...

    I have used it before, so I don't expect any real problems. Just a few minor glitches that need fixed.

    Bean

    Lazarus has a Convert Delphi Project line on the Project Wizard, if that helps.
  • RoadsterRoadster Posts: 209
    edited 2013-08-17 04:20
    I will try installing the free Lazarus that I found on my linux and mac and will report back to you if I'm successful or not.
    http://www.lazarus.freepascal.org
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-17 04:36
    Below is a simple PropBasic program that displays a message to to SimpleIDE terminal.

    Ray
    '''''''''''''''''''
    ' test2.pbas
    '
    ' Uses the SimpleIDE terminal to display message.
    '
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Device settings
    ''''''''''''''''''''
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    '''''''''''''''''''
    ' Constants
    '''''''''''''''''''
    Baud CON "T115200"
    
    '''''''''''''''''''
    ' I/O Pins
    '''''''''''''''''''
    TX PIN 30 HIGH
    
    '''''''''''''''''''
    ' Subroutine / Function Declarations
    '''''''''''''''''''
    TX_BYTE SUB 2
    waitMS  SUB 1
    
    PROGRAM Start
    
    Start:
    ' Wait for terminal screen.
      waitMS 300
    
    Main:
      SEROUT TX, Baud, "Hello, PropBasic World"
      SEROUT TX, Baud, 13  'CR
      SEROUT TX, Baud, 10  'LF
    
    END
    
    '''''''''''''''''''
    ' Subroutine / Function Code
    '''''''''''''''''''
    SUB TX_BYTE
      SEROUT __param1, Baud, __param2
      ENDSUB
    
    ' Wait milliseconds, 1000 = 1 second
    ' waitMS 1000
    SUB waitMS
      PAUSE __param1
      ENDSUB
    
  • David BetzDavid Betz Posts: 14,511
    edited 2013-08-17 06:01
    Roadster wrote: »
    I will try installing the free Lazarus that I found on my linux and mac and will report back to you if I'm successful or not.
    http://www.lazarus.freepascal.org
    If you'd prefer to make the Mac and Linux versions for Bean that's fine with me. Let me know so we don't duplicate efforts.
  • RoadsterRoadster Posts: 209
    edited 2013-08-17 06:46
    Well I got Lazarus working on Linux, But my Mac needs an older version of xcode version 2.3 - 3.x, 4.0 is not supported and I'm not an Apple developer, I will ask my Apple developer buddy of mine at work about this Monday.
  • David BetzDavid Betz Posts: 14,511
    edited 2013-08-17 06:59
    Sounds like everyone is going to be helping Bean port to Mac and LInux.
  • dgatelydgately Posts: 1,621
    edited 2013-08-17 08:24
    Roadster wrote: »
    Well I got Lazarus working on Linux, But my Mac needs an older version of xcode version 2.3 - 3.x, 4.0 is not supported and I'm not an Apple developer, I will ask my Apple developer buddy of mine at work about this Monday.

    This Lazarus works on recent versions f Mac OS X & XCode: http://wiki.freepascal.org/Installing_Lazarus_on_MacOS_X

    As Bean had requested, maybe just one person should attempt the port. (I'm staying out and will help test once there's an executable :-)


    dgately
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-17 09:16
    I thought I would do another example PropBasic program, added a couple of TASKs, and now the program is run in LMM mode.

    Ray
    '''''''''''''''''''
    ' test2.pbas
    '
    ' Uses the SimpleIDE terminal to display message.
    '
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Device settings
    ''''''''''''''''''''
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    
    '''''''''''''''''''
    ' Constants
    '''''''''''''''''''
    Baud CON "T115200"
    
    '''''''''''''''''''
    ' I/O Pins
    '''''''''''''''''''
    TX PIN 30 HIGH
    
    LED1 PIN 26 OUTPUT
    LED2 PIN 27 OUTPUT
    '''''''''''''''''''
    ' Subroutine / Function / Task Declarations
    '''''''''''''''''''
    TX_BYTE SUB 2
    waitMS  SUB 1
    
    ledNF1 TASK 
    ledNF2 TASK
    
    ' Start the program in LMM mode
    PROGRAM Start LMM
    
    Start:
    ' Wait for terminal screen.
      waitMS 300
    
    ' Start the TASKs
      COGSTART ledNF1
      COGSTART ledNF2
    
    Main:
      SEROUT TX, Baud, "Hello, PropBasic World"
      SEROUT TX, Baud, 13  'CR
      SEROUT TX, Baud, 10  'LF
    
    END
    
    '''''''''''''''''''
    ' Subroutine / Function Code
    '''''''''''''''''''
    SUB TX_BYTE
      SEROUT __param1, Baud, __param2
      ENDSUB
    
    ' Wait milliseconds, 1000 = 1 second
    ' waitMS 1000
    ' This does not work when called from a TASK.
    SUB waitMS
      PAUSE __param1
      ENDSUB
    
    ' This TASK Starts flashing an LED (P26) in its own cog.
    TASK ledNF1
    
      DO
        HIGH LED1
        PAUSE 500
        LOW LED1
        PAUSE 500    
      LOOP
      ENDTASK
    
    ' This TASK Starts flashing an LED (P27) in its own cog.
    TASK ledNF2
    
      DO
        HIGH LED2
        PAUSE 800
        LOW LED2
        PAUSE 800    
      LOOP
      ENDTASK
    
    
  • JonnyMacJonnyMac Posts: 8,924
    edited 2013-08-17 09:45
    I don't know if it had to do with XP, but I had a path problem in my Properties dialog. It's fixed and PropBASIC is now working on my system.

    I haven't used PropBASIC in a long time and just stumbled on a folder full of PropBASIC programs I wrote a few years ago. As I had a QuickStart with HID board on my desk, I ran my IR input demo and it worked.
    ' ======================================================================
    '
    '   File...... sircs_rx_v4.pbas
    '   Purpose...
    '   Author.... Jon McPhalen
    '   E-mail.... jon@jonmcphalen.com
    '   Started...
    '   Updated... 17 AUG 2013 { edited for QS HID }
    '
    ' ======================================================================
    
    
    ' ----------------------------------------------------------------------
    ' Program Description
    ' ----------------------------------------------------------------------
    '
    
    ' ----------------------------------------------------------------------
    ' Device Settings
    ' ----------------------------------------------------------------------
    
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    
    ' ----------------------------------------------------------------------
    ' Constants
    ' ----------------------------------------------------------------------
    
    POS_DETECT      CON     64
    NEG_DETECT      CON     96
    FREE_RUN        CON     248
    
    
    ' timing in cnt ticks @ 80MHz
    
    MS_044          CON     3_520_000               ' 44ms
    
    BIT_S           CON     172_800                 ' 90% of 2.4ms
    BIT_1           CON      86_400                 ' 90% of 1.2ms
    BIT_0           CON      43_200                 ' 90% of 0.6ms
    
    
    Baud            CON     "T115200"
    
    HOME            CON     1
    BKSP            CON     8
    TAB             CON     9
    LF              CON     10
    CLREOL          CON     11
    CLRDN           CON     12
    CR              CON     13
    CLS             CON     16
    
    
    ' ----------------------------------------------------------------------
    ' I/O Pins
    ' ----------------------------------------------------------------------
    
    TX              PIN     30      HIGH            ' set to idle
    
    IR              PIN     8       INPUT           ' for QS HID Board
    
    LEDs            PIN     16..23  LOW
    DVD             PIN     23      LOW
    
    
    ' ----------------------------------------------------------------------
    ' Shared (hub) Variables (Byte, Word, Long)
    ' ----------------------------------------------------------------------
    
    
    ' ----------------------------------------------------------------------
    ' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
    ' ----------------------------------------------------------------------
    
    
    ' ----------------------------------------------------------------------
    ' TASK Definitions
    ' ----------------------------------------------------------------------
    
    
    ' ----------------------------------------------------------------------
    ' Cog Variables (Long only)
    ' ----------------------------------------------------------------------
    
    keyIn           VAR     Long
    keyBits         VAR     Long
    
    idx             VAR     Long
    bitChar         VAR     Long
    
    
    ' ----------------------------------------------------------------------
    ' SUB/FUNC Definitions
    ' ----------------------------------------------------------------------
    
    GET_SIRCS       FUNC    0                       ' SIRCS + bit count
    
    TX_STR          SUB     1
    TX_BYTE         SUB     1
    
    DELAY_MS        SUB     1                       ' shell for PAUSE
    DELAY_US        SUB     1                       ' shell for PAUSEUS
    
    
    ' ======================================================================
      PROGRAM Start
    ' ======================================================================
    
    Start:
      DELAY_MS 500                                  ' allow terminal to open
      TX_BYTE CLS
    
      TX_STR  "SIRCS Demo"
      TX_BYTE CR
      TX_BYTE CR
    
    
    Main:
      keyIn = GET_SIRCS                             ' get code
      keyBits = __param2                            ' get bit count
    
      IF keyBits = 12 THEN
        TX_STR  "12"
        keyIn = keyIn << 20                         ' align to MSB
      ELSEIF keyBits = 20 THEN
        TX_STR  "20"
        keyIn = keyIn << 12
      ELSE
        TX_STR  "??"
      ENDIF
      TX_BYTE CR
    
      FOR idx = 1 TO keyBits
        \ rol keyIn, #1                             ' rotate bit31 to bit0
        bitChar = keyIn & 1                         ' get a bit
        bitChar = bitChar + "0"                     ' convert to ASCII
        TX_BYTE bitChar
      NEXT
      TX_BYTE CR
      TX_BYTE CR
    
      DELAY_MS 250
      GOTO Main
    
    
    ' ----------------------------------------------------------------------
    ' SUB/FUNC Code
    ' ----------------------------------------------------------------------
    
    ' Use: variable = GET_SIRCS
    ' -- waits for and returns SIRCS code and bit count
    ' -- PropBASIC adaptation of my Spin/PASM object in Jan 2010 Nuts & Volts
    ' -- Do not compile with LMM mode
    
    FUNC GET_SIRCS
    
      irCode        VAR     __param2
      irBits        VAR     __param3
    
      COUNTERA NEG_DETECT, IR, 0, 1                 ' set for pulse timing
      COUNTERB FREE_RUN, 0, 0, 1                    ' set for frame timing
    
      ASM
    
    waitstart       waitpeq IR, IR                  ' wait for high
                    mov     phsa, #0                ' start bit timer
                    waitpne IR, IR                  ' wait for low
                    mov     phsb, #0                ' start frame timer
                    waitpeq IR, IR                  ' wait for high
                    mov     __temp1, phsa           ' capture phsa
                    cmp     __temp1, BIT_S  wc, wz  ' valid start bit?
            if_b    jmp     #waitstart              ' try again if no
    
                    mov     irCode, #0
                    mov     irBits, #0              ' reset bit count
    
    checkframe      mov     __temp1, phsb           ' capture phsb
                    cmp     __temp1, MS_044 wc, wz  ' check frame timer
            if_ae   jmp     #irdone                 ' abort @44ms
    
    waitbit         test    IR, ina         wz      ' look for new bit
            if_nz   jmp     #checkframe             ' check for end if no bit
    
    measurebit      mov     phsa, #0                ' resstart bit timer
                    waitpeq IR, IR                  ' wait for high (end of bit)
                    cmp     BIT_1, phsa     wc      ' ir bit --> C
                    rcr     irCode, #1              ' C --> irwork.31
    
                    add     irBits, #1              ' inc bit count
                    cmp     irBits, #20     wc      ' at max?
            if_b    jmp     #checkframe             ' keep scanning if no
    
    irdone          mov     __temp1, #32
                    sub     __temp1, irBits
                    shr     irCode, __temp1         ' right align ir code
    
      ENDASM
    
      RETURN irCode, irBits
      ENDFUNC
    
    ' ----------------------------------------------------------------------
    
    ' Use: TX_STR pntr
    
    SUB TX_STR
    
      strAddr       VAR     __param2
      strChar       VAR     __param3
    
      strAddr = __param1
      DO
        RDBYTE strAddr, strChar
        IF strChar = 0 THEN EXIT
        TX_BYTE strChar
        INC strAddr
      LOOP
      ENDSUB
    
    ' ----------------------------------------------------------------------
    
    ' Use: TX_BYTE char
    ' -- shell for SEROUT
    
    SUB TX_BYTE
      SEROUT TX, Baud, __param1
      ENDSUB
    
    ' ----------------------------------------------------------------------
    
    ' Use: DELAY_MS milliseconds
    
    SUB DELAY_MS
      PAUSE __param1
      ENDSUB
    
    ' ----------------------------------------------------------------------
    
    ' Use: DELAY_MS microseconds
    
    SUB DELAY_US
      PAUSEUS __param1
      ENDSUB
    
    
    ' ----------------------------------------------------------------------
    ' TASK Code
    ' ----------------------------------------------------------------------
    


    From a personal standpoint, I like PropBASIC much better in SimpleIDE than I did in BST.
    1024 x 640 - 83K
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-17 14:00
    So, I thought I might try some terminal I/O. Of course I ran into a problem trying to create the subroutines for SERIN and SEROUT. For the SERIN, I would eventually like to see it work with a string input. But all in good time ...

    Ray
    '''''''''''''''''''
    ' test2.pbas
    '
    ' Uses the SimpleIDE terminal to display message.
    '
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Device settings
    ''''''''''''''''''''
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    
    '''''''''''''''''''
    ' Constants
    '''''''''''''''''''
    Baud CON "T115200"
    
    '''''''''''''''''''
    ' I/O Pins
    '''''''''''''''''''
    TX PIN 30 HIGH
    'RX PIN 31 LOW
    
    LED1 PIN 26 OUTPUT
    LED2 PIN 27 OUTPUT
    
    '''''''''''''''''''
    ' Variables
    '''''''''''''''''''
    inbyte VAR LONG
    cog1 VAR LONG
    cog2 VAR LONG
    
    '''''''''''''''''''
    ' Subroutine / Function / Task Declarations
    '''''''''''''''''''
    TX_BYTE SUB 2
    'RX_BYTE FUNC 1
    waitMS  SUB 1
    
    ledNF1 TASK 
    ledNF2 TASK
    
    ' Start the program in LMM mode
    PROGRAM Start LMM 
    
    Start:
    ' Wait for terminal screen.
      waitMS 300
    
    ' Start the TASKs
      COGSTART ledNF1,cog1
      COGSTART ledNF2,cog2
    
    Main:
      SEROUT TX, Baud, "Hello, PropBasic World\r\n"
    '  SEROUT TX, Baud, 13  'CR is now \r
    '  SEROUT TX, Baud, 10  'LF is now \n
      DO
        TX_BYTE TX, "#"
        SERIN 31,T115200,inbyte
        IF inbyte = "a" THEN
          SEROUT TX, Baud, "You pressed 'a'\r\n"
        ELSEIF inbyte = "q" THEN
          EXIT
        ELSE
          SEROUT TX, Baud, "Invalid Command!\r\n"
        ENDIF
      LOOP
    
      SEROUT TX, Baud, "Program Stopped!\r\n"
      COGSTOP cog1 ' Stop the ledNF1 TASK
      COGSTOP cog2 ' Stop the ledNF2 TASK
    END
    
    '''''''''''''''''''
    ' Subroutine / Function Code
    '''''''''''''''''''
    SUB TX_BYTE
      SEROUT __param1, Baud, __param2
      ENDSUB
    
    ' Wait milliseconds, 1000 = 1 second
    ' waitMS 1000
    ' This does not work when called from a TASK.
    SUB waitMS
      PAUSE __param1
      ENDSUB
    
    'FUNC RX_BYTE
    '  __param2 = param1
    '  SERIN __param2,Baud,__param1
    '  ENDFUNC
    
    ' This TASK Starts flashing an LED (P26) in its own cog.
    TASK ledNF1
    
      DO
        HIGH LED1
        PAUSE 500
        LOW LED1
        PAUSE 500    
      LOOP
      ENDTASK
    
    ' This TASK Starts flashing an LED (P27) in its own cog.
    TASK ledNF2
    
      DO
        HIGH LED2
        PAUSE 800
        LOW LED2
        PAUSE 800    
      LOOP
      ENDTASK
    
    
  • JonnyMacJonnyMac Posts: 8,924
    edited 2013-08-17 16:06
    I found the attached library in my PropBASIC folder -- it may be helpful.
  • BeanBean Posts: 8,129
    edited 2013-08-17 20:00
    I got the source code to compile with Lazarus and David Betz has cross compiled it on the Mac.
    Here is the Mac version PropBasic 1.40 that he sent me.

    NOTE: This file will NOT work with BST. Sorry, BradC is not supporting BST anymore.

    Bean

    P.S. The Linux version is in the works.
  • dgatelydgately Posts: 1,621
    edited 2013-08-18 01:41
    Bean wrote: »
    I got the source code to compile with Lazarus and David Betz has cross compiled it on the Mac.
    Here is the Mac version PropBasic 1.40 that he sent me.

    Bean

    P.S. The Linux version is in the works.

    I'm not able to get this version to successfully build a .pbas source that built successfully with version 1.14 of PropBasic. Tried to build first within SimpleIDE and that failed, so tried to build from the command line. Here's are the errors and the output from the successful build:
    [B]Failed build:[/B]
    
    $ /opt/parallax/bin/PropBasic-1 chaser.pbas
    
     ERROR 23  COULD NOT READ SOURCE FILE  "/Users/altergator/Downloads\chaser.pbas" ; 
     ERROR 18  NO "PROGRAM" COMMAND USED ; 
    
    
    [U]PropBasic Version 00.01.40[/U] Aug 17, 2013
    Finished Compile. 0 Lines Read, 0 Lines Generated,  0 Warnings, 2 Errors.
    
    [B]Successful build:[/B]
    
    $ /opt/parallax/bin/PropBasic-bst.osx chaser.pbas /B
    
    [U]PropBasic Version 00.01.14[/U] July 26, 2011
    Modified by Brad Campbell. Do not bother author about non-compiler related bugs, they are my fault (proptools@fnarfbargle.com)
    Finished Compile. 119 Lines Read, 119 Lines Generated,  0 Warnings, 0 Errors.
    

    Looks like the path that gets created ("/Users/altergator/Downloads\chaser.pbas") is broken for Mac OS X as the "\" file delimiter would need to be a "/". This caused ERROR 23. ERROR 18 may just be residual from the first error.

    dgately
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-18 04:41
    I was looking at the build status, and I noticed that PropBasic version that is shown is 1.31, I thought I saw Bean mention something about 1.40, is there a couple of different versions being used? The other thing that I noticed is that 'Brads Spin Tool Compiler' is being used, I thought that there was a PropBasic compiler that was supposed to be used instead? The other thing that occurred was, when I used serial.lib, provided by JonnyMac, at compile time there were a bunch of errors associated with that file, has PropBasic changed that much that the subrountines/functions in that file are no longer valid? Just a few things that came up while I am experimenting with PropBasic for SimpleIDE.

    Ray
    Project Directory: E:/PropBasic/temp/

    propbasic.bat -b -L C:/Program Files (x86)/SimpleIDE/bin/../propeller-gcc/spin/ test1.pbas.c
    Building test1.pbas.c
    PropBasic Version 00.01.31 Apr 22, 2013
    Finished Compile. 21 Lines Read, 43 Lines Generated, 0 Warnings, 0 Errors.
    Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
    Compiled for i386 Win32 at 08:17:48 on 2009/07/20Loading Object test1.pbas

    Program size is 152 longs
    Compiled 70 Lines of Code in 0.009 Seconds
  • BeanBean Posts: 8,129
    edited 2013-08-18 05:55
    dgately, the latest version that works with BST is 1.14. I cannot make a new version without BradC and he is not support BST anymore.

    These current builds are for SimpleIDE.

    I up'd the version number for the Mac build to 1.40, but it is the same as 1.31 for Windows.
    I'll get everything on the same version once everything is straightened out with the builds.

    Bean
  • RoadsterRoadster Posts: 209
    edited 2013-08-18 07:28
    I got Lazarus working on my Mac last night, I see David Betz has compiled it on the Mac for you, let me know if you still need any help with Mac or Linux

    Karl
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-18 07:54
    I wanted to see if I could hide a lot of subroutines/functions under the hood, sort of speak. When I ran a compile I get the following stuff as shown below. In the build status it is showing a lot of errors, but it seems like the program did run, I am not sure what is going on now, is this still a coordination problem between PropBasic and SimpleIDE?

    Ray

    Project Directory: E:/PropBasic/sertest/

    propbasic.bat -b -L C:/Program Files (x86)/SimpleIDE/bin/../propeller-gcc/spin/ sertest.c
    Building sertest.c
    PropBasic Version 00.01.31 Apr 22, 2013
    Finished Compile. 55 Lines Read, 58 Lines Generated, 0 Warnings, 0 Errors.
    Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
    Compiled for i386 Win32 at 08:17:48 on 2009/07/20Loading Object sertest

    sertest(28,19) Error : Expected unique symbol name or #
    mov __temp2,__param1 ' PAUSE __param1
    __________________^
    sertest(29,19) Error : Expected unique symbol name or #
    mins __temp2,#1 WC
    __________________^
    sertest(30,19) Error : Expected unique symbol name or #
    mov __temp1,_1mSec
    __________________^
    sertest(31,19) Error : Expected unique symbol name or #
    add __temp1,cnt
    __________________^
    sertest(33,5) Error : Expected unique symbol name or #
    IF_NC waitcnt __temp1,_1mSec
    ____^
    Compiled 80 Lines of Code in 0 Seconds
    propeller-load.exe -Dreset=dtr -r sertest.binary -p COM10
    Propeller Version 1 on COM10
    Loading sertest.binary to hub memory

    216 bytes sent

    Verifying RAM ...
    OK

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' sertest.pbas
    '
    '
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    LOAD "terminal.pbas"
    
    
    PROGRAM Start
    
    
    Start:
    
      waitMS 300
      SEROUT TX, Baud, "Hello, PropBasic World\r\n"
    
    
    END
    
    

    terminal.pbas
    ' SimpleIDE terminal
    
    Baud CON "T115200"
    
    TX PIN 30 HIGH
    
    waitMS  SUB 1
    
    SUB waitMS
      PAUSE __param1
      ENDSUB
    
  • JonnyMacJonnyMac Posts: 8,924
    edited 2013-08-18 08:59
    I have working libraries that do that -- there is a directive, '{CODE}, that you seem to be missing. The attached program uses two libraries -- divided into logical components (delays and serial io) -- and does work as expected. You need to check "Echo On" in the terminal.
  • dgatelydgately Posts: 1,621
    edited 2013-08-18 12:35
    Bean wrote: »
    dgately, the latest version that works with BST is 1.14. I cannot make a new version without BradC and he is not support BST anymore.

    These current builds are for SimpleIDE.

    Of course! I knew that... I was just stating that I'm not able to use the built-for-Mac OS X version 1.40, while I was able to use the OLD 1.14 version that I found on Brad's website, with SimpleIDE. And, the problem appears to possibly require a simple fix. Looks like PropBasic is munging a file path that includes a Windows-style "\" in front of the .pbas filename. Fixing that could open this up for use on Mac OS X & Linux.

    Maybe Dave Betz can check-out this issue and mod the code a bit for Mac OS X and Linux...


    Thanks,
    dgately
  • BeanBean Posts: 8,129
    edited 2013-08-18 13:12
    dgately,
    Okay, next build I'll change the path strings from "\" to "/" to be more universal.
    Hopefully that will fix the issue you're having.

    Bean
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-19 05:43
    Hopefully at some point the SimpleIDE 'Zip Project' will work with PropBasic Projects, in the mean time, while the code size is small, I will just display the code, so you can just cut and paste, or just look at it without downloading. Below I just tried to show the most uncluttered way of displaying a message in PropBasic. The pbasic.lib contains all the "cluttering" code; and is this starting to look like pseudo C structured code? Maybe I should change TX_STR to printf subroutine/function and have it cover the whole ...

    Ray

    ' pbasic.pbas
    '
    
    ' Contains PropBasic program information.
    LOAD "pbasic.lib"
    
    
    '''''''''''''''
    PROGRAM Start
    '''''''''''''''
    
    Start:
    ' Wait for terminal screen.
      waitMS 300
    Main:
    'Display typical message.
      TX_STR "Hello, PropBasic World\r\n"
    
    END
    
    
    pbasic.lib
    ' SimpleIDE PropBasic library
    
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    
    ' Declarations for terminal use.
    Baud CON "T115200"
    
    TX PIN 30 HIGH
    RX PIN 31 INPUT
    
    ' Subroutine/Function declarations
    waitMS  SUB 1
    
    TX_STR  SUB 1
    TX_BYTE SUB 1
    
    ' Compiler directive for main code space.
    '{$CODE}
    ' 
    
    ' Subroutines/Functions
    ' Usage - waitMS xxxx, waitMS 1000 , 1000 = 1 second
    '
    '{$IFUSED waitMS}
    SUB waitMS
      PAUSE __param1
      ENDSUB
    '{$ENDIF}
    ' Use: TX_STR strpntr
    ' -- transmits a z-string at strpntr
    ' -- uses TX_BYTE
    
    ' Usage - TX_STR strgptr
    '{$IFUSED TX_STR}
    SUB TX_STR
    
      tsPntr      VAR     __param3
      tsChar      VAR     __param4
    
      tsPntr = __param1
      DO
        RDBYTE tsPntr, tsChar
        IF tsChar = 0 THEN EXIT
        TX_BYTE tsChar
        INC tsPntr
      LOOP
    
      ENDSUB
    '{$ENDIF}
    
    ' Usage - TX_BYTE char, count
    '
    '{$IFUSED TX_BYTE}
    SUB TX_BYTE
    
      SEROUT TX, Baud, __param1
    
      ENDSUB
    '{$ENDIF}
    
  • JonnyMacJonnyMac Posts: 8,924
    edited 2013-08-19 07:42
    I think it's bad form to put speed settings in a library; from project-to-project you may want to use the same library code but at different speed settings. Things like processor speed and baud rates should be part of the top file, not embedded in a library.

    It's also a good idea to separate libraries per their form. If you look above, I separated delays from serial as the two may be used together, but are not related nor interdependent.

    One of the things I don't like about what is happening on the C side of SimpleIDE is that there is one GIGANTIC library (simpletools) that does everything. Thankfully, the compiler strips out unused code but from a programming standpoint, multifunction libraries are hard to learn and manage. Just my opinion, of course.

    Question: Why do you use uppercase for some names (TX_STR) and camelcase for another (waitMS)? -- case is often used to indicate what something is, and waitMS looks like a variable to my programming eyes.
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-19 11:34
    I think it's bad form to put speed settings in a library; from project-to-project you may want to use the same library code but at different speed settings. Things like processor speed and baud rates should be part of the top file, not embedded in a library.
    Most of the boards that I have and use, are a standard setup, same speed covers all of my boards. If you are using SimpleIDE then you are expected to use 115200 BAUD to use the terminal. I figure if you ave a special board, then you will probably want to create a special library for the special project. I was looking to see what kind of library would be necessary for just a basic usage of PropBasic.
    Question: Why do you use uppercase for some names (TX_STR) and camelcase for another (waitMS)? -- case is often used to indicate what something is, and waitMS looks like a variable to my programming eyes.
    Yes, I am still trying out different stuff with that. The BASIC language that I have worked with had this form - 'subroutine()/function()', I wanted to see if using a camelcase would help in terms of making subroutines stand out from PropBasic commands, which are all upper case. Maybe something like tx_STR, and wait_MS, using the '_' symbol to designate that it is a subroutine/function. Still not sure which way is the best way.

    A general question that I have is, what is the best and quickest way to provide drivers for uSD, and some of the other things that you may want to use on a PropBOE, or Activity Board? I tried out the XBee socket, and that was very straight forward, SERIN/SEROUT handled that very well. Not sure how you would do the servo pins or the ADC sockets or ...

    For the uSD is there a way of using fsrw.spin in the PropBasic program? Maybe get it into its own library and have access to the commands via the lib.

    Ray
  • JonnyMacJonnyMac Posts: 8,924
    edited 2013-08-19 14:39
    you will probably want to create a special library for the special project.

    That defeats the purpose of a library: reusable code. You may as well skip the library process and copy-and-paste code.

    what is the best and quickest way to provide drivers for uSD

    This is part of the reason I never adopted PropBASIC. For Spin, there is a large selection of easy-to-use objects and it's very easy to write my own. Until those that want to see PropBASIC flourish match what can easily be done with Spin objects, I think it will continue to grow very slowly. As an example, look at the enormous amount of work done by the GCC team to port standard libraries and things common to Propeller users.

    Please understand that this is not an indictment of PropBASIC -- I'd like to see it flourish (I even contributed a little assembly code in the very beginning, and wrote about it in my N&V column). For it to really take off, though, it's going to need a bigger selection of libraries, and proper documentation.
  • jazzedjazzed Posts: 11,803
    edited 2013-08-19 15:22
    While SimpleIDE's terminal starts up by default at 115200, that can be changed in the terminal window.

    Simple libraries compiled with PropellerGCC have no trouble with 115200. That is possible mainly because every memory model has 64 longs of fcache overlay available in the kernel. So the bitbang simple serial library rx/tx routines for example actually run "at metal speed" or 20MIPS at 80MHz in the COG. A non-cog, non-fcache, LMM only solution would only be able to run at 57600 max. Of course finely hand crafted PASM drivers should run much faster.

    We gave some thought to overloading SPIN clock mode and clock rate the same way we do for Propeller-GCC based on board type, but in the end we felt that the desire by many for SPIN stay "as is" would make the effort a total waste of time. I would recommend letting the user set the clock by some means if possible. Of course, that means that clock dependent code would require appropriate waitcnt, etc....
  • RsadeikaRsadeika Posts: 3,824
    edited 2013-08-19 15:57
    For it to really take off, though, it's going to need a bigger selection of libraries, and proper documentation.
    I have to totally agree, with the above statement. I was looking at the date of the documentation that I have, and it is dated 2010, and the version is 1.14. Maybe Bean is holding back on the latest documentation, and all of the necessary drivers, waiting for the right time to release them. Until that happens, maybe I will have to revisit PropGCC, it has been awhile. For now I will have to continue with Spin even with the shortcoming of not having the ability of accessing LMM, in an easy manner. I think Spin 2 should be coming out shortly, that should have a slight learning curve, which will take some time to master. As for PropBASIC, I think I have been down this road before in 2009, which had the same problem as it is having now.

    Ray
  • BeanBean Posts: 8,129
    edited 2013-08-19 16:19
    Ray,
    The issue was that there was not a free IDE for PropBasic.

    Then came along BST and it was a good fit, but the issue was that I had to send the source files to BradC and he would have to make some changes to the source to make it work with BST.

    Since Brad has stopped supporting BST, I was left with no way to update the compiler for BST because I was never given the knowledge of what needed changed to make it work with BST.

    So, for a year or two very little has been done with PropBasic because of the same problem it had from the beginning...The lack of a free IDE (there is viewport, but it is not free).

    Now that it seems there is a willingness to support PropBasic from SimpleIDE, that problem has been eliminated.

    As for libraries and documentation...Well I think that the libraries will come as more people use it. Look how long it took spin to support SD cards. And documentation...well I guess I have to take the bullet for that. I simply MUST find the hours to improve the documentation.

    Bean
Sign In or Register to comment.