Shop OBEX P1 Docs P2 Docs Learn Events
bs2 serin troubles — Parallax Forums

bs2 serin troubles

flippydooflippydoo Posts: 8
edited 2008-05-28 06:07 in BASIC Stamp
So I'm using a sparkfun bluesmirf hooked up to a bs2 and sending data from my computer to the bs2. after days of struggling I finally have the bs2 and bluesmirf properly hooked up, and I'm trying to run this program:

BAUDMODE CON 84

serdata VAR Byte

main:
SEROUT 6, BAUDMODE, [noparse][[/noparse]"Activate?"]
SERIN 7, BAUDMODE, 10000, main, [noparse][[/noparse]DEC serdata]
SEROUT 6, BAUDMODE, [noparse][[/noparse]"OK'']

alarm:
leds and piezos that work fine
SEROUT 6, BAUDMODE, [noparse][[/noparse]"Turn off?"]
SERIN 7, BAUDMODE, 10000, alarm, [noparse][[/noparse]DEC serdata]

GOTO main



So the program can get through the first serout just fine. "Activate?" pops up in hyperterminal, but when I go to enter a 1 to fulfill the SERIN on the next line, it usually either takes about fifty tries to move on or simply never moves on.

When it does manage to move on, it gets through the lights and beeping just fine, but gets stalled again at the "turn off?" stage, where again I think simply entering a 1 or other digit should get it to keep going.

this is my first attempt at anything of this nature at all (a month ago, a basic stamp was a completely foreign object)...am I way off base here in thinking that this should work? Is there an easier way to do this? Any ideas as to what's going wrong?

thanks!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-28 05:27
    When you use the DEC formatter, this relies on having a non-digit character follow a bunch of digits. The DEC formatter doesn't continue until you supply a non-digit. If you want to be able to use a single digit, leave out the DEC and serdata will contain the character that's entered rather than the numeric value of a bunch of digits.
  • flippydooflippydoo Posts: 8
    edited 2008-05-28 05:51
    sorry, I should have been a little bit more clear. I'm currently entering 1 followed by a space or another non-digit character, but the stamp either takes a bunch of tries to respond or simply never responds. given that the serout is working, and that the first serin occasionally goes through, I'm wondering whether this is a coding issue, a timing issue, or simply a bad communication issue?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-28 05:57
    I'm sure you're having some kind of communications error or problem. The BS2 end of things is very straightforward. Perhaps the bluesmirf is configured improperly. Since the bluesmirf has to make a packetized protocol (RFCOMM) look like a character-by-character bidirectional serial port, there's all sorts of information on packet sizes and timeouts. How is your bluesmirf configured?
  • flippydooflippydoo Posts: 8
    edited 2008-05-28 06:07
    d
    ***Settings***
    BTA=00066600A45D
    BTName=FireFly-A45D
    Baudrt=9600
    Parity=None
    Mode =Slav
    Authen=0
    Encryp=0
    PinCod=1234
    Bonded=0
    Rem=NONE SET
    e
    ***ADVANCED Settings***
    SrvName= SPP
    SrvClass=0000
    DevClass=1F00
    InqWindw=0200
    PagWindw=0200
    CfgTimer=60
    StatuStr=NULL
Sign In or Register to comment.