Shop OBEX P1 Docs P2 Docs Learn Events
Serial Communication (Parallax <-> PC) — Parallax Forums

Serial Communication (Parallax <-> PC)

eduardomoraiseduardomorais Posts: 11
edited 2011-01-10 20:57 in Propeller 1
Hello friends!

I'm working on a project that uses USB communication between a computer and a board propeller parallax.
I need a method that receives bytes from the USB and performs some tasks in accordance with such received bytes.
As the size of the received words will be something "random", I have to develop a method that will read in SPIN indefinitely from USB only stopping when a stop condition, for example a character
'\ r', is introduced to it.
I tried to do that anyway. Could anyone tell me another way of doing or where I'm wrong, because is not working that way.


C

Comments

  • ratronicratronic Posts: 1,451
    edited 2011-01-10 20:57
    eduardomorias - probably no one has answered this because it's hard to tell from your posted code what your trying to do. Next time copy and paste your code in between the code tags or post the spin file. I think this is what you were trying to do - try this
    CON 
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000
    NL = %00001101'= '\r' 
     
    OBJ
    PC: "FullDuplexSerial" 
     
    VAR
    byte teste
     
    PUB Main
      dirA[16..23]~~              
      PC.start(31, 30, 0, 9_600)  
      lerserial
     
    Pub lerserial
     
      Repeat until teste == nl
        teste := pc.rx
        case teste
          %01000001: !outA[16]     '65 A
          %01000010: !outA[17]     '66 B
          OTHER : !outa[16..17]
    
Sign In or Register to comment.