Shop OBEX P1 Docs P2 Docs Learn Events
Extended Duplex help — Parallax Forums

Extended Duplex help

ChipperChipper Posts: 5
edited 2007-09-17 05:33 in Propeller 1
im just getting into propeller and trying to understand the full duplex object,could someone give me an example code of how to send the series of bytes (0xFF 0x55 0x03 0x00 0x01 0x04 0xF8) at 9800 buad? Help would be greatly appriciatedsmile.gif Thankyou smile.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-16 23:37
    1) You have to initialize the object first, supply transmit and receive pin numbers, mode information, and a Baud. Have a look at the start method if you haven't look at it yet. Typically, if you call the object SER, the call would look like SER.start(rxPin, txPin, %0000, 9600).

    2) For each byte you want to transmit, use SER.tx(value). In your case, you'd use something like SER.tx($FF), then SER.tx($55), etc.

    3) If you're sending a sequence of constant values not including zero, you could use SER.str(stringAddress). That won't work here because you want to transmit a zero byte. Just use a sequence of calls to SER.tx, one per line.
  • Mark BramwellMark Bramwell Posts: 56
    edited 2007-09-16 23:55
    I just posted color-code.spin

    It has a portion that writes some bytes to the serial port and then waits for 1 of 4 characters to be sent from hyperterminal.

    Check it out!

    Here are the important lines:

    
    VAr
    
     byte : KBcode
    
    OBJ
    
      Serial        : "FullDuplexSerial"
    
    PUB start
    
      Serial.start(31, 30, 0, 9600) ' HyperTerminal  9600, None, 1, no flow control 
      
     ' send some data
      Serial.str(string(13,10,13,10,13,10,13,10))
      Serial.str(string("     *** Propeller Color Code Tester for your TV ***",13,10,13,10))
      Serial.str(string("    Use the I,J,K,M keys to navigate on your TV screen",13,10,13,10))
      Serial.str(string("         I       I=Increase the current color value",13,10))
      Serial.str(string("        J K      Change which code we are examining",13,10))
      Serial.str(string("         M       M=Decrease the current color value",13,10,13,10))
      
     ' rx some data
        KBcode := Serial.rxcheck 
        Case KBcode
          107: ' lower case K
            CMD_Code := CMD_Right
          106: ' lower case J
            CMD_Code := CMD_Left
          105: ' lower case I
            CMD_Code := CMD_Up
          109: ' lower case M
            CMD_Code := CMD_Down
    
    
    
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-09-17 00:19
    I got a good lesson in FullDuplex myself yesterday..

    Grab a copy of PropCOMM from this thread:
    http://forums.parallax.com/showthread.php?p=675748

    Here's the core, it's another example...

    PUB start | i, a, b, TimeCnt
    
      key.start(keyPins)                                         ' Start keyboard driver
      text.start(12)                                                ' Start terminal screen   
      ser.start(serRecv,serXmit,%0000,9600)          ' Control link via prop-plug
    
    
    PRI terminal | local,remote,duplex
    
       duplex := 0
       repeat
          local := key.key
          if local <> 0
             if duplex == 1 
                text.out(local)           
             ser.tx(local)
    
          remote := ser.rxtime(20)
          if remote == 8
             text.str(string(backspace," ",backspace))
             remote := 0
             
          if remote > 10
               text.out(remote)
    
    



    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • ChipperChipper Posts: 5
    edited 2007-09-17 05:33
    You guys are amazingly helpful and quick thankyou, it is working great [noparse]:D[/noparse]
Sign In or Register to comment.