Shop OBEX P1 Docs P2 Docs Learn Events
Talk to BS1USB from C#? — Parallax Forums

Talk to BS1USB from C#?

aerodynoaerodyno Posts: 4
edited 2008-10-02 16:48 in BASIC Stamp
I'm writing a C# program and I want to be able to read from and write to my BS1USB.

I've created a sample program, now running on my BS1USB that prints a random value to the debug terminal.

Here's the DEBUG window output:
VALUE = 4980
VALUE = 4864
VALUE = 4633
VALUE = 4170

Every five seconds, it prints a new random value via DEBUG.

I'm trying to read this same output into my C# program. I've got the serial port open from C#, but I get lots of gibberish.
Here's what the output looks like in my C# program (ideally it would be the same as above):

??????????????????????????????????[noparse][[/noparse]gibberish]??????
????????????????????????????????[noparse][[/noparse]gibberish]????????
??????????????????????????????[noparse][[/noparse]gibberish]??????????
????????????????????????????[noparse][[/noparse]gibberish]????????????

Note that the 'gibberish' block appears regularly, and I believe it's the "VALUE = XXXX" text coming through, because the rate is once every 5 seconds.

I've concluded that my serial settings are wrong -- so I'm reading the 1s as characters. So what are the appropriate settings for the BS1USB to read this DEBUG information? I've scoured the documentation but haven't found anything.

Most of the documentation points to SERIN and SEROUT which is for specific pins, not the built-in USB serial connection, so I'm confused.

Any help? Is there some existing BS1USB <-> C# communication library I just haven't found? [noparse];)[/noparse]

Thanks,
Aerodyno

Comments

  • aerodynoaerodyno Posts: 4
    edited 2008-09-26 14:29
    Note that I get similar behavior when I open a "debug terminal" and select the COM port with my BS1USB on it.

    I get what appears to be random text in the terminal -- nothing like what I see in the DEBUG window I get after I click RUN.

    Any advice?

    Thanks in advance for your kindness and consideration.
  • aerodynoaerodyno Posts: 4
    edited 2008-09-27 00:06
    So I've figured out a bit more -- the documentation references a "custom packetized format" for the debug command on the BS1USB. I want to read the output of debug into my computer without using the basic stamp program -- please help!

    BS1 Documentation says the debug command is:

    Asychronous 4800 baud, N, 8, 1
    Inverted polarity, Raw Data
    Custom packetized format
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-27 00:17
    There's a Nuts and Volts Column on this subject (#131 - www.parallax.com/Resources/NutsVoltsColumns/tabid/272/Default.aspx).
    The information is in a special format and you'll need some kind of program on the PC to interpret it. There is no way to send information to the BS1USB using the built-in USB to serial adapter and there is no other way to get data from the BS1USB using the built-in adapter.
  • aerodynoaerodyno Posts: 4
    edited 2008-09-27 00:35
    Hey Mike, thanks so much for that pointer! I'll look in to it, at first glance it looks like just what I need.

    Again, thank you for your kindness and consideration.

    -s
  • vinionvinion Posts: 2
    edited 2008-10-02 16:48
    I found this code www.codemammoth.com/ShowCode.php?Code=16 it is for BS2 i dont know if it will work in BS1 but take a look it may inspire you
Sign In or Register to comment.