Shop OBEX P1 Docs P2 Docs Learn Events
Serial Help — Parallax Forums

Serial Help

YojimboYojimbo Posts: 40
edited 2005-06-03 01:54 in BASIC Stamp
I am having some trouble trying to use the SERIN and SEROUT commands properly. I am attempting to write program to act as a go between from the CMUcamGUI program on my computer and the CMUcam1 mounted on my boe bot. I've written a test program to see what the java based CMUcamGUI is outputting. My code is as follows:

SERIN 16, 84, [noparse][[/noparse]STR result\4] 'here I am using an stringarray with 4 bytes because the java prog is sending "rs/r"
FREQOUT 4, 2000, 3000 'since both the CMUcamGUI and my Stamp Editor Debug window use COM1
PAUSE 10000 'I've added these 3 lines of code to give me time to close the java app after it sends the "rs/r"
FREQOUT 4, 2000, 3000 'command and open the debug window to view what it caught.
DEBUG STR result 'this should output the string "rs/r" SHOULD is the key word here, heh

when I run the program as I described in the 'comments, all I get back is a weird character that looks kinda like a y with umlots over it (you know, the two dots you sometimes see over U and A and other characters in other languages. Any help here would be much appreciated. Been trying to puzzle this out for a while so I can get this program working with the bot/cam.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 04:11
    Embedding baudmode constants always causes errors; in my standard template the baud values for popular rates are built in and conditional compilation takes care of selecting the right one based on the module I'm using.· In the end, I don't ever have to worry about it.· My template is attached.

    And when you're using the programming port (pin 16), you need to invert the data (a constant for that is built into the template too).


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-02 04:13
    Hello,

    ·· There are no string variables on the BASIC Stamp.· You would need to use an array and deal with the characters one at a time.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • YojimboYojimbo Posts: 40
    edited 2005-06-02 04:37
    well, I've messed around a bit more, but still not having much luck, here's the incarnation of code I am using to try and see what the java app is spitting out to me (it should be rs/r that I recieve as the reset command for the CMUcam1, but just getting those weird y's with umlots). I changed the 84 to 19468 to account for the invert on pin 16 (SIN)(thanks btw). I am trying a array to handle things as Chris suggested, but.... [noparse]:([/noparse] Any ideas? Thanks again for your time!

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    counter VAR Byte
    result VAR Byte
    dataResult VAR Byte(4)
    counter = 0
    dataResult = 0

    DO
    SERIN 16, 16468, 10000, NODATA, [noparse][[/noparse]result]
    dataResult(counter) = result
    counter = counter + 1
    LOOP

    NODATA:
    FREQOUT 4, 2000, 3000
    FOR counter = counter TO 0
    DEBUG CRSRXY, counter, 0, dataResult(counter) , CR
    NEXT
    RETURN
  • YojimboYojimbo Posts: 40
    edited 2005-06-03 01:54
    OK, I know this is probubly really wrong, but I'm posting it so perhaps someone can see what I am trying to do and correct me. Here's my code block:
    catch VAR Byte
    DO
    SERIN 16, 16468, [noparse][[/noparse]catch] 'catching incoming byte sent from PC
    SEROUT 7, 84, [noparse][[/noparse]catch] 'Send caught byte to AppMod CMUcam1
    SERIN 9, 84, [noparse][[/noparse]catch] 'catch AppMod CMUcam1's response
    SEROUT 16, 16468, [noparse][[/noparse]catch] 'send AppMod CMUcam1's response to PC Serial Port
    LOOP

    Any help will be greatly appreciated. Thanks!!
Sign In or Register to comment.