Shop OBEX P1 Docs P2 Docs Learn Events
Serin/Serout — Parallax Forums

Serin/Serout

bboy8012bboy8012 Posts: 153
edited 2006-10-05 23:55 in BASIC Stamp
I am trying to get this code to work using the parallax wireless modules, but all I keep getting is the H in Hello! can someone give me tips on how to this code working correctly?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-05 04:29
    Hello,
    ·
    ·· This is happening because you are waiting for the “!” in your code and then receiving a single character.· When you loop you ignore everything until the next “!”.· So essentially what you are seeing is exactly what the code is supposed to do in this case.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • bboy8012bboy8012 Posts: 153
    edited 2006-10-05 12:11
    Is it possible to get an example
  • Steve JoblinSteve Joblin Posts: 784
    edited 2006-10-05 12:33
    I am just starting to play with the wireless modules myself... I think what Chris is saying is that your Receiving program is set to only capture the first byte of what is being sent... that is, you are sending the the word "hello", but only receiving the first byte, which is "h".· Make the following changes in your Receiving program:

    1.· change "letter VAR Byte" to "message VAR word"

    2.· change "SERIN recPin, baud, [noparse][[/noparse]WAIT("!"),letter]" to "SERIN recPin, baud, [noparse][[/noparse]WAIT("!"),message]"

    3.· change "DEBUG letter" to "DEBUG message"

    Does that work?· Please note that I am a newbie myself, so can someone please chime in and confirm that I am correct?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-05 19:19
    bboy8012, Steve,
    ·
    ·· Renaming the variable won’t work either.· The problem is that you can send the string in quotes using SEROUT but you cannot receive the whole thing in one byte.· You need to somehow indicate the end of the message, perhaps with a CR (13).· Then your receive routine will input bytes and display them one at a time until it receives a CR.· At that point you go back and wait for the “!”.· Basically you need a loop to receive and print characters one at a time until the CR.· I hope that helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-05 20:07
    bboy8012, Steve,
    ·
    ·· Okay, examples are here…These are not setup directly for the RF Modules, per say, just serial I/O in general.· You’ll notice in the SendGreeting.bs2 code I left a provision for the RF Module.· The code sends a small text message (greeting) out approximately every 2 seconds.
    ·
    ·· The GetGreeting.bs2 code shows how to receive using a BS2.· Notice this one requires a character buffer (array) to be created to hold the incoming characters.· The BSP version saves a lot of variable space by using the Scratch Pad RAM to buffer incoming text and display it right from the SPRAM.· I hope these examples help everyone.· Take Care!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • bboy8012bboy8012 Posts: 153
    edited 2006-10-05 23:55
    Thanks for the help
Sign In or Register to comment.