PDA

View Full Version : Some serial comms and variable sizes



realolman
01-18-2009, 12:15 AM
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[15] := 1 ' output port to also flash an LED for example
outa[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?

John Abshier
01-18-2009, 12:26 AM
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

realolman
01-20-2009, 06:26 PM
Thank you.

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




dira[17..21]:=1

repeat

MyVariable :=ser.rx

outa[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 asI expected.

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

Post Edited (realolman) : 1/20/2009 11:33:32 AM GMT

StefanL38
01-21-2009, 03:36 AM
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