Shop OBEX P1 Docs P2 Docs Learn Events
Spin interpreter over serial? — Parallax Forums

Spin interpreter over serial?

Hey guys,
is there any way to access the Spinterpreter over serial? Kind of like how I can access a Bash prompt over serial on the Raspberry Pi?
I'm learning spin and I want a Spin prompt where I can just play with the language and get instant feedback.

Thanks!

Comments

  • Spin isn't interactive that way. Thankfully, though, you can knock together a bit of code and run in RAM -- the process is fast since the EEPROM doesn't have to be written. I am reminded how much I enjoy this every time a friend asks me to help them with Arduino code; it's a very slow process to download and run the tiniest programs on that platform.
  • Thanks! However, I don't know how to write such code to make the Spinterpreter interactive.
    Can you provide me with the code, or at least tell me how?
  • kwinnkwinn Posts: 8,697
    As JonnyMac posted you cannot make spin interactive that way. What you can do is write and download a simple program that performs a single function and sends the result to PST. Then that single function can be changed to some other function and downloaded.
    The Spin compile, download, and execute is so fast that it is almost like having an interactive interpreter.
  • If you want a powerful interactive language for the Propeller try Tachyon Forth.
  • Or prop basic.
  • potatohead wrote: »
    Or prop basic.
    PropBasic is not interactive the last I knew.

  • Maybe not exactly what you're looking for, but possibly close enough? @mpark 's Sphinx:
    http://forums.parallax.com/discussion/114023/sphinx%C2%97as-seen-at-upew

    Maybe the terminal code could be adapted to work on a serial terminal, instead of TV.
    It doesn't look like its been worked on in quite awhile, but the links on the referenced site seem to work still.
    I've never tried it myself...I think I was too green back then. Having dug it up, now I want to try it...

    Cheers,
    Jesse
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-02-27 00:31
    pico wrote: »
    Hey guys,
    is there any way to access the Spinterpreter over serial? Kind of like how I can access a Bash prompt over serial on the Raspberry Pi?
    I'm learning spin and I want a Spin prompt where I can just play with the language and get instant feedback.

    Thanks!

    "Spin" itself is not designed as an interactive language since the compiler runs on the PC and simply generates Spin byte code (and assembly if included) which is run by the Spin byte code interpreter in ROM on the Propeller. This is not an interactive terminal interface "interpreter", it is a VM that simply reads compiled byte codes and decodes and executes them etc.

    If you want interactive you should have a look at my Tachyon, you can even interact with FAT32 files on SD and over the Internet etc.

    Here are some simple one line "scripts" which could run from the serial port or even create a new definition with as shown. The ASCII character script takes less than 4ms to execute at 921600 baud but 672us if not limited.
    ...  CR $20 FROM 95 FOR I EMIT NEXT 
     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ok
    ...  PRINT" HELLO WORLD"   HELLO WORLD ok
    ...  CLKFREQ PRINT 80000000 ok
    ...  $12345678 $7F00 !  ok
    ...  $7F00 @ .LONG 1234.5678 ok
    ...  15 PIN@ PRINT 0 ok
    

    Create a new function on the fly and execute it by name.
    ...  : HELLO PRINT" HELLO WORLD"  ; 
    ...  HELLO  HELLO WORLD ok
    ...  3 FOR HELLO NEXT HELLO WORLDHELLO WORLDHELLO WORLD ok
    
  • Cluso99Cluso99 Posts: 18,066
    avsa242 wrote: »
    Maybe not exactly what you're looking for, but possibly close enough? @mpark 's Sphinx:
    http://forums.parallax.com/discussion/114023/sphinx%C2%97as-seen-at-upew

    Maybe the terminal code could be adapted to work on a serial terminal, instead of TV.
    It doesn't look like its been worked on in quite awhile, but the links on the referenced site seem to work still.
    I've never tried it myself...I think I was too green back then. Having dug it up, now I want to try it...

    Cheers,
    Jesse
    I built Michael's Sphinx compiler into my Prop OS. I didn't do a lot of testing but it did compile correctly. Instructions and source is in the link in my signature.
    Sorry, but you will need an editor on the prop. I don't know of any :(

  • The Sphinx compiler has also been ported to the Spinix OS. There are also 3 different text editors that run under spinix. You can also run Forth under spinix using the pfth Forth interpreter. You can also write simple Bash scripts using the shell that runs in spinix.
  • Cluso99Cluso99 Posts: 18,066
    Thanks Dave. I wasn't aware of any editors so I should take a look when I get time :)
  • David BetzDavid Betz Posts: 14,511
    edited 2018-02-27 16:06
    However, even if you can get Sphinx running you still don't have an interactive language. You still have to go through an edit/compile/run sequence. I think Tachyon (and pfth) and FemtoBasic are the only real interactive languages. My ebasic works but it isn't really complete enough to do much with.
  • If you want interactive you should have a look at my Tachyon, you can even interact with FAT32 files on SD and over the Internet etc.

    Sounds nice.
Sign In or Register to comment.