PDA

View Full Version : Full Duplex Serial



Newzed
09-03-2007, 11:44 PM
Iam using FullDuplex so my Proto Board can commnicate with Hyper, and everything works fine. Now i want to send a word -35000 - to Hyper but the FullDuplex method comm.rx will only handle a byte. How do I modify FullDuplex so I can send a word terminated with Enter?

Thanks

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)

Mike Cook
09-03-2007, 11:51 PM
Sid,

If possible use FullDuplexSerial.spin from the Propeller Tool v1.05.5 (http://www.parallax.com/dl/sw/propeller/Setup-Propeller-Tool-v1.05.5.exe), it has the dec method you are looking for.




PUB dec(value) | i
'' Print a decimal number
if value < 0
-value
tx("-")
i := 1_000_000_000
repeat 10
if value => i
tx(value / i + "0")
value //= i
result~~
elseif result or i == 1
tx("0")
i /= 10

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike (http://www.allsurplus.net/)

Mightor
09-03-2007, 11:52 PM
Hi,

Use something like this:
Debug.str(string("Your word goes here", 10, 13))

This is assuming you have defined FullDuplexSerial as Debug :)

Gr,
Mightor

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| To know recursion, you must first know recursion.

Newzed
09-04-2007, 12:25 AM
I have no problem using comm.dec -I can display any number I want. What I want to do is enter a number larger than 255 "on the fly". This is used to clear my EEPROM. My program tells me the last EEPROM byte used - say it was 38442. So now I want to clear my EEPROM to 38450. I must be abe to enter that number from the keyboard - i do not want to have to go into the program, enter the value, and reload.

Does anyone have the answer I need?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)

Mike Cook
09-04-2007, 12:39 AM
Ok, If you want to send a number terminated with a Carriage Return, from hyperterm to the Propeller,then you need Martin Hebel's "Extended Full Duplex Serial", this can be found in the Propeller Object Exchange. It has the following method:



PUB rxDec : Value | place, ptr, x
{{
Accepts and returns serial decimal values, such as "1234" as a number.
String must end in a carriage return (ASCII 13)
x:= Serial.rxDec ' accept string of digits for value
}}
place := 1
ptr := 0
value :=0
dataIn[ptr] := RX
ptr++
repeat while (DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter)
dataIn[ptr] := RX
ptr++
if ptr > 2
repeat x from (ptr-2) to 1
if (dataIn[x] => ("0")) and (datain[x] =< ("9"))
value := value + ((DataIn[x]-"0") * place)
place := place * 10
if (dataIn[0] => ("0")) and (datain[0] =< ("9"))
value := value + (DataIn[0]-48) * place
elseif dataIn[0] == "-"
value := value * -1
elseif dataIn[0] == "+"
value := value

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike (http://www.allsurplus.net/)

Jonathan
09-04-2007, 12:42 AM
to eter a word value from a keyboard, here is the cheesy method I use, there is more than likely a better way. Lets assume you type "32000" on the keyboard. Collect it in a 5 byte arre and then:

value :=value + databyte[0] * 10_000
value := value + databyte * 1000
value := value + databyte * 100
value := value + databyte * 10
value := value + databyte

HTH,

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot

Jonathan
09-04-2007, 12:44 AM
dang, I shoulld have put it in a code snip, it took away the square brackets.

/code

value := value + databyte[0] * 10_000
value := value + databyte * 1000
value := value + databyte * 100
value := value + databyte* 10
value := value + databyte

/code

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info (http://www.madlabs.info) - Home of the Hydrogen Fuel Cell Robot

Fred Hawkins
09-04-2007, 02:26 AM
Try editing one of these posts (click on the pencil), [ code /code ] ought to work in that editor. Then your code snippet should display correctly. The quick reply editor isn't as smart.

Tom Wyckoff
09-04-2007, 08:02 AM
If you use FullDuplexSerialPlus you can enter the value you need, as long as the variable you're putting it into is a long, not a byte.
Try this, it's what I used when I testing FullDuplexSerialPlus.spin :




CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
_stack = 200

obj
comm: "FullDuplexSerialPlus"

var
byte str1[36]
byte str2[36]
long num1
long num2
long num3





pub main | index, index2
comm.start(16,17,0,57600)
comm.str(string("Gimme a number!",10,13))
num1 := comm.GetDec
comm.str(string("I'm going to double that",10,13))
num2 := num1 * 2
comm.dec(num2)
comm.str(string(10,13,"Our original number was: "))
comm.dec(num1)
comm.str(string(10,13))
comm.str(string(10,13,"Maybe you want it in HEX? ",10,13))
comm.hex(num1,8)
comm.str(string(10,13,"Or maybe in binary even?",10,13))
comm.bin(num1,12)
comm.str(string(10,13))
comm.str(string("Now give me one in HEX",10,13))
num2 := comm.gethex
comm.str(string(10,13,"OK That was:",10,13))
comm.hex(num2,8)
comm.str(string(10,13,"Can we make it decimal easily?",10,13))
comm.dec(num2)
comm.str(string(10,13))
comm.str(string("Now for binary, gimme another number",10,13))
num2 := comm.getbin
comm.str(string(10,13,"In decimal that's",10,13))
comm.dec(num2)
comm.str(string(10,13))
comm.str(string("Now just give me a word or two, up to 30 characters",10,13))
comm.getstr(@str2)
index := strsize(@str2)
comm.dec(index)
comm.str(string(10,13))
repeat index2 from index to 0
comm.tx(str2[index2])
comm.str(string(10,13,"Oops, I got it backwards!",10,13))

Post Edited (Tom Wyckoff) : 9/4/2007 12:10:01 AM GMT