Shop OBEX P1 Docs P2 Docs Learn Events
SERIN with WAIT for OK what happens if it never comes? — Parallax Forums

SERIN with WAIT for OK what happens if it never comes?

Brian LeeBrian Lee Posts: 6
edited 2008-04-10 17:26 in BASIC Stamp
I am having a problem that I can’t find the answer for. I am sending a configuration string to a cell with SEROUT and before I send the next line I need to WAIT for OK for the modem by SERIN RxModem, 240, [noparse]/noparse]WAIT (“OK&#8221[noparse];)[/noparse but want happens if the modem does not respond?
·
I think the best way to handle this is WAIT x seconds then jump out of the WAIT state and go to a different part of the program to flash a LED to indicate an error then go back to the start of the modem configuration.
·
Does anyone have any suggestions on how to do this?

Comments

  • marzec309marzec309 Posts: 146
    edited 2008-04-09 22:41
    If you are use the BS2 family not the BS1 the SERIN command supports this review the basic stamp manual if you don't have one you can download it here
    www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

    The SERIN command alows you to set a timeout and if reached will jump to a different part of your program. The Manual will explain how to do this under SERIN.
  • Brian LeeBrian Lee Posts: 6
    edited 2008-04-10 15:03
    I guess I did not frame my question correctly; I am using the follow as an example:
    ·
    RxD·······················CON 16················ 'RxD at SIN
    Ipin ······················ CON 15················'Ipin is I/O pin 15
    TxModem ··········· ·CON 14··············· 'TxD to modem
    baud ···················· CON 240············· 'N9600 for BS2 p
    timeout·················CON 2000 ··········· 'Timeout = 1000 ms
    char ····················· VAR Byte
    ·
    start:
    SEROUT TxModem, baud, [noparse][[/noparse]"AT", CR]
    SERIN RxD\Ipin, baud, timeout, NoData, [noparse][[/noparse]char]
    DEBUG CR, "R: ", char
    GOTO start
    ·
    NoData:
    DEBUG CR, "No response from the device."
    PAUSE 1500
    GOTO start
    ·
    Is there other ways of accomplishing this task? Or is this the most efficient way?
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-10 17:26
    In your example, why is p16 (the debug port) being used for receive, but p14 for transmit? Have you tried the following and it doesn't work?

    The modem would have to be configured to use hardware handshaking and to send verbose result codes. Those may or may not be the defaults.

    Without hardware handshaking, there is danger that the modem will send responses before the Stamp is ready.

    SERIN RxD\Ipin, baud, timeout, NoData, [noparse][[/noparse]WAIT("OK")]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.