Shop OBEX P1 Docs P2 Docs Learn Events
Confused about sending data to PCs — Parallax Forums

Confused about sending data to PCs

cefncefn Posts: 2
edited 2006-07-23 22:54 in BASIC Stamp
A SIMPLE PROBLEM, SURELY

Can someone tell me how to send simple integer values from the Stamp and receive them with any other program? I'm working on my own and trying to pick things up as I go along, but really need some pointers from people who know.

The integers are in the range 0-255. I'm using the Basic Stamp across a KeySpan USB serial port.

At this stage, it would give me confidence to just be able to send any desired data from the Basic Stamp to another program which is not a Basic Stamp editor. I have not yet been able to do this.

Basically I've run into a brick wall with making the Basic Stamp send just simple integers over USB to a target program. The target program definitely receives it, but I'm concerned that DEBUG does something strange that I don't understand when encoding sending values, and I just want to send bytes pure and simple. SEROUT I'm guessing doesn't send stuff to the Serial port itself, but instead sends data using a serial protocol to the BS pins, unless these are somehow mapped to the serial port.

In terms of deployment, I can run the receiving program on Linux, or Windows, or Mac. I'm willing to rewire and rebuild as necessary if using the USB channel is an impossibility.

I can see the Serial device on /dev/cu.KeySerial1 and /dev/tty.KeySerial1, but don't know what program I can use to view the raw output from the stamp, and what invocations I should use on the stamp so it sends merely simple bytes across the (USB) serial port.

When I use an invocation like

' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG 1, 2, 4, 8, 16, 32, 64, 128
PAUSE 500
LOOP

...and use cat -v /dev/cu.KeySerial1 I get stuff like this...

^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^A^B^D^H^P @M-^@^C

When I run my own target program to receive bytes, invocations like...

DEBUG "A"

..instead of generating a number 65 at the other end, in fact generate the following sequence of values...

6
0
254

...with DEBUG "B" generating...

24
0
254

THE FULL STORY

I have set up an ultrasonic circuit on a Basic Stamp to pick up distances (integers, can be rounded and bounded to 0-255), and built another program which responds to these distances, I need to tie the two things up. The use of DEBUG is fine for the work I've done so far, but using DEBUG the output can only be received by the Parallax Editor (actually I'm using MacBS2 a lot of the time for convenience).

I therefore need to move to using the real target program double quick. The target program is written in PD, and is using the Comport object to receive data through a KeySpan Serial port which is mounted at /dev/cu.KeySerial1 and /dev/tty.KeySerial1.

I have only a week to complete this assignment in order to show the work on Saturday (coming). Your help would be highly appreciated.

Comments

Sign In or Register to comment.