Shop OBEX P1 Docs P2 Docs Learn Events
Some serial comms and variable sizes — Parallax Forums

Some serial comms and variable sizes

realolmanrealolman Posts: 65
edited 2009-01-20 20:36 in Propeller 1
I have been trying to use chip gracey's full duplex serial and the Extended _FDSerial, and I am having some success.

·In another thread a few guys helped me to send and receive, and I have the code I have been using here.· It is stuff that I got from them that I have modified somewhat.

SER : "Extended_FDSerial" 
 

VAR 


long MyVariable 

 


 
PUB Main 


MyVariable :=(string("This is it oh yes it is furthermore how much stuff will this vatiable hold??")) 
 

ser.start(31,30,0,38400) 
 
dira[noparse][[/noparse]15] := 1 ' output port to also flash an LED for example
outa[noparse][[/noparse]15] := 1

ser.str(string("Communication with propeller", $0D)) 

ser.str(MyVariable) 

waitcnt(10_000 + cnt) 

ser.tx(13) 
ser.tx(10) 



the questions I have are:
I defined the Variable "MyVariable" as a long... why is it able to transmit so much in the Main


Is it even using the "MyVariable" that I defined in the VAR block?

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-01-17 17:26
    The string function creates a string in memory and returns it's address. MyVariable holds the address. So MyVariable does not hold all of the bytes in "This is it..., but points to the first byte of the data.

    John Abshier
  • realolmanrealolman Posts: 65
    edited 2009-01-20 11:26
    Thank you.

    Now I'm trying to recieve some serial transmissions...

    ··
    dira[noparse][[/noparse]17..21]:=1 
    
    repeat 
    
     MyVariable :=ser.rx 
    
     outa[noparse][[/noparse]17..21] :=MyVariable
    


    I was hoping to see the led's connected to 17... 21 change state according to the input character.
    it definately does something... 21 will go on and off when transmissions are recieved but that's it.
    No patterns as·I expected.

    EDIT: I realized what was wrong as soon as I posted this... seting dira[noparse][[/noparse]17..21] :=%11111· did the trick.

    Post Edited (realolman) : 1/20/2009 11:33:32 AM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-01-20 20:36
    Hello,

    another testing method is to just send back what you received

    VAR
      byte MyChar1
    
    PUB test
    
      repeat
        ser.str(string("wait for character to be received"))
        MyChar1 := ser.rx
        ser.str(string("received character is:"))
        ser.tx(MyChar1)
        ser.tx(13)
        ser.tx(13)
    
    
    



    best regards

    Stefan
Sign In or Register to comment.