Shop OBEX P1 Docs P2 Docs Learn Events
View Basic Stamp debug in linux terminal — Parallax Forums

View Basic Stamp debug in linux terminal

idlepozeidlepoze Posts: 2
edited 2013-11-04 14:28 in BASIC Stamp
Hi, I've currently bought the Basic Stamp Discovery Kit to learn and play around with. I'm using Ubuntu 13.10 and VirtualBox to emulate Windows XP to run the Basic Stamp Editor, which works great.

But I had an idea to to make a program in linux that can read the debug commands sent from the Basic Stamp microcontroller. I have so far written a small C++ program to open the usb port and looking at the data recieved. Since I'm new to all of this I was hoping that somebody could point me in the right direction. The program so far initiates the program written into the EEPROM and recieves data which is all scrambled. I'm guessing here that it has something to do with ASCII encoding or HEX but not quite sure if I need to understand more about how the usb sends data or how Basic stamp sends information.

My basic stamp program looks like this (It sets the servo to 45 degrees for 3 seconds)
' {STAMP BS2}
' {PBASIC 2.5}

DEBUG "Program Running!", CR
counter VAR Word
DEBUG "Position = 45 degrees...", CR

FOR counter = 1 TO 150
 PULSOUT 14,500
 PAUSE 20
NEXT

END

And my C++ code looks like this, which I compile with "g++ main.cpp -o main" and then run with ./main
#include <iostream>
#include <fstream>
using namespace std;
std::string str;
int main() 
{
    fstream f;
    f.open("/dev/ttyUSB0");
    while(true) 
    {
        while(f >> str) {
            cout << str;
        }    
    }
    
    return 0;
}


Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-11-03 20:53
    The DEBUG statement is a special case of the SEROUT statement. I/O pin #16 is a special case for SERIN and SEROUT in that it inputs and outputs characters via the USB port at 9600 Baud. The Stamp Editor's debug window knows this and is configured for 9600 Baud. The same isn't true for Linux. I don't know offhand of the proper way to configure a serial port under Linux, but you should be able to find out how to set the Baud for the fstream f.
  • idlepozeidlepoze Posts: 2
    edited 2013-11-04 14:28
    Thank you, I will try that and see if I can manage a solution
Sign In or Register to comment.