PDA

View Full Version : Talk to BS1USB from C#?



aerodyno
09-26-2008, 08:09 PM
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):

??????????????????????????????????[gibberish]??????
????????????????????????????????[gibberish]????????
??????????????????????????????[gibberish]??????????
????????????????????????????[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? ;)

Thanks,
Aerodyno

aerodyno
09-26-2008, 10:29 PM
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.

aerodyno
09-27-2008, 08:06 AM
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 Green
09-27-2008, 08:17 AM
There's a Nuts and Volts Column on this subject (#131 - www.parallax.com/Resources/NutsVoltsColumns/tabid/272/Default.aspx (http://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.

aerodyno
09-27-2008, 08:35 AM
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

vinion
10-03-2008, 12:48 AM
I found this code www.codemammoth.com/ShowCode.php?Code=16 (http://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