Serial Help
Yojimbo
Posts: 40
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.
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
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
·· 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
' {$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
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!!