Shop OBEX P1 Docs P2 Docs Learn Events
How to get c++ to receive BS2's readings — Parallax Forums

How to get c++ to receive BS2's readings

Kh3ldrinKh3ldrin Posts: 11
edited 2008-10-09 19:51 in BASIC Stamp
Hi, i asked this question before and received an answer that is to use serial in and serial out. But my BS2 is USB, also i do not know the program for the serial communication, can anyone help me with this?

Thanks

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-10-05 16:07
    Which board are you using? The stamp itself is not USB. To your computer the USB connection looks like a com port and if you look in device manager (if you are using microsoft) you will see them. There are commands in c++ to send and receive serial data and SERIN and SEROUT in pbasic to do the same.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Kh3ldrinKh3ldrin Posts: 11
    edited 2008-10-07 03:25
    I am using the board of education (USB). So can c++ read USB the way they read serial data? My laptop do not have serial ports as well.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-07 03:37
    The USB system provides a "virtual" com port. The USB to serial adapter built into the BOE-USB provides the Stamp end of the "virtual" com port. Your laptop's operating system (presumably Windows) provides the laptop end of the "virtual" com port. To your C++ program, this looks like a com port and behaves like an ordinary com port. To the Stamp, the USB to serial adapter looks like a com port. In this case, you can use either the DEBUG and DEBUGIN statements or you can use the SEROUT and SERIN statements with port #16 specified. Read the Stamp Basic Manual for details on the Stamp end. For C++, use whatever you would normally use to do serial port I/O.
  • SRLMSRLM Posts: 5,045
    edited 2008-10-07 03:54
    There's an excellent book that I have, called "The Definitive Guide to Building Java Robots" by Scott Preston. It's an excellent book that uses Java to think and send commands to the Basic Stamp, via COM ports. It has a couple of chapters dedicated to getting the communication up and running. I learned Java first several years ago, and now I'm learning C++. They're very similar, so similar in fact that you can probably pick up the other in a month. If you see the book, flip through and see what happens in Java, then see what the C++ equivalent is.
  • Kh3ldrinKh3ldrin Posts: 11
    edited 2008-10-07 10:25
    ok thanks
  • Kh3ldrinKh3ldrin Posts: 11
    edited 2008-10-09 16:55
    Btw, does the tokenizer convert BS2 code into .exe files? I think i can run .exe files with c++ as well
  • SRLMSRLM Posts: 5,045
    edited 2008-10-09 19:51
    Not unless you explicitly tell it to do so. You have to select "Generate Object Code" from the main menu, then select the EXE option. This allows you to download via a computer that does not have the editor.
Sign In or Register to comment.