Shop OBEX P1 Docs P2 Docs Learn Events
Need help with FullDulexSerial coding ... — Parallax Forums

Need help with FullDulexSerial coding ...

JMLStamp2pJMLStamp2p Posts: 259
edited 2011-02-13 13:30 in Propeller 1
I am trying to send an "AT" command to another chip from the Propeller with the code below; I must be overlooking something simple. Is my serial.str( ) command formatted wrong? If I wanted to append a Carrage return command after the AT command as well should would I just add a /r outside the parenthesis?
Thanks for any help that you give,
JMLStamp2p

_______________________________________________________________________________________________
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 'Sets Clock Mde for 80 MHz

VAR
long rXdata 'Declares Local Varibles
long tXdata

OBJ
serial : "FullDuplexSerial" 'Includes access to the FullDuplexSerial Functions via the term"serial"

PUB MAIN

serial.start(31, 30, 0, 115200) 'Sets up Serial Baud rate and Pins
serial.rxFlush 'Flush Input Buffer
serial.str ("AT") 'Send AT command out pin 30 to SIMCOM900

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2011-02-11 13:46
    Hi JML,

    write
      serial.str(string("AT",13))
    

    instead of
      serial.str ("AT")
    

    SPIN can handle only bytes, words, longs directly

    a string must be transformed into a bytesequence which is terminated by value zero

    the command serial.str(string("AT",13)) stores the bytesequence decimal values 65,84,13,0 somewhere in the HUB-RAM and
    passes the HUB-RAM-ADRESS to the method "str"

    If you want to use strings with a variable content you have to define a byte-array
    and always have to pass the ADRESS of the bytearray by using the "@"-operatot

    best regards

    Stefan
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2011-02-11 18:19
    Stefan, thank you very much for takng time to aswer. Where is he bes tplace I can go to learn the nuts and bolts of Propeller code?
    JMLtamp2p
  • John MichaelJohn Michael Posts: 37
    edited 2011-02-13 12:17
    Stefan, I didn't see a "CTL" ASCII equivelent unless it is "17". I am trying to end the coding by a "CTL & Z" command. Should I use something like this ...

    serial.str(string(17,90,0)) 'Send the Equivelent of CTL & Z

    !outa[10] 'Flash LED when Completed.
    waitcnt(Wait_Cycles + cnt)

    JMLStamp2p
  • John MichaelJohn Michael Posts: 37
    edited 2011-02-13 12:31
    Or maybe like this ?
    serial.str(string(26,43,90,0))

    JMLStamp2p
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-13 12:40
    You can't have a zero byte in a string because that's used to mark the end of the string. If you need to transmit a zero byte, use serial.tx(0)
  • John MichaelJohn Michael Posts: 37
    edited 2011-02-13 13:14
    Mike, how would be the Correct way to code a "CTL+Z" to Transmit out pin 30 to another chip using "AT" commands? Not sure how to ...
    Thanks for your Help,
    JMLStamp2p
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-13 13:30
    CTRL-Z has nothing to do with "AT" commands. When you hold down the Control key on a keyboard, the upper 3 bits of the 8 bit byte are forced to zeros. CTRL-@ becomes a zero byte. CTRL-A becomes a $01, CTRL-Z becomes a $1A. CTRL-"]" becomes $1D, etc. To transmit CTRL-Z, you'd use serial.tx($1A). Rather than figuring out what's CTRL for every character, you can just do something like serial.tx("Z"&$1F) which forces the upper 3 bits of the character to zeros.
Sign In or Register to comment.