Shop OBEX P1 Docs P2 Docs Learn Events
Does a Basic Stamp API exist? — Parallax Forums

Does a Basic Stamp API exist?

Jeff GerberJeff Gerber Posts: 6
edited 2013-12-08 14:05 in BASIC Stamp
This is my first post in the forums, so hello to everyone! Searching for API turns up zero results in the forums so I have to ask: What/Where is the API for interacting with the BASIC Stamp, as opposed to using the "BASIC Stamp Editor"? The intent is of course to be able to write an application of my own design (e.g. write an app in my language of choice to read data output from the BASIC stamp and display it as a graph). (Apologies, I have no idea how to get CR/LF to work in this HTML editor.) -Jeff

Comments

  • ZootZoot Posts: 2,227
    edited 2013-12-03 18:13
    The Stamp can send serial data out to the PC (see SEROUT in the Pbasic manual, esp. as it relates to SEROUTing on pin 16, which is the RS-232 serial port).

    If you can program on the PC (or Mac) side to read the serial port properly, you can write in whatever language you want, and set up whatever serial data format you care to on the Stamp side.

    The only real caveat with the serial conn. to the PC on the Stamp is that the RS-232 circuitry on the Stamp will cause all characters to "echo", so you need to accommodate that in your PC application.
  • Jeff GerberJeff Gerber Posts: 6
    edited 2013-12-03 19:13
    Ah, beautiful, thank you Zoot! :cool: I have the USB version and I see COM5 appear when I plug in and it is set to 9600 8N1, good enough. I should be able to write a little app. I noticed the Stamp Editor folder has a "Developer" sub-folder with a couple pascal apps that read stdin/stdout after being launched in this fashion:
    Stampw.exe  /PIPE  EditorMaster.exe
    
    though I don't see documentation on the syntax.
  • Desy2820Desy2820 Posts: 138
    edited 2013-12-03 19:15
    You can also check out MakerPlot. http://www.makerplot.com/
    It is designed to accept serial data and display it in a variety of formats.
  • ZootZoot Posts: 2,227
    edited 2013-12-03 19:33
    Don't forget, there's no real "syntax" -- rather, the syntax is whatever you write and do in your program you download to the Stamp.

    You could have code that sends an ASCII header, followed by 3 bytes of binary data, e.g. "ATTN1:",%01010101,,%01010101,%01010101

    If you want a checksum, write the code that way for the Stamp. If the Stamp is "slaved", then the program in the Stamp can wait for a specific serial string (as a kind of header) followed by data from the PC, or just presume that activity on the serial line is the start of bytes, or whatever you want to do.

    The Stamp can be kind of slow (esp the slower members of the family) to setup and/or parse out data as it goes out/in, so you may want to keep that in mind for the host side, and have the host app be somewhat tolerant of space between bytes in a serial stream. Likewise the changeover from SERIN, say, accepting a command, and then SEROUTing to send the PC data can be slow, relatively.
  • Jeff GerberJeff Gerber Posts: 6
    edited 2013-12-04 19:39
    I gave it a try tonight and I'm chuckling at how wonderfully easy this. :smile: pg. 169 - "On all the BS2 models, DEBUG is actually special case of the SEROUT instruction." pg. 171 - "DEBUGIN is actually a special case of the SERIN instruction."

    I wrote a tiny in/out program on the stamp and also an app just as tiny in C# and it worked immediately.
  • Dirty HowiDirty Howi Posts: 20
    edited 2013-12-08 14:05
    i just got the outgoing figured out, will work on the incoming next.

    I've been kicking around writing a .NET API for the stamp, just to facilitate comms, if i get anything solid and usable, i'll post it :)
Sign In or Register to comment.