My Serial comms program not working
Lee Marshall
Posts: 106
i have written a simple program which inputs 5 characters from the PC over RS232, and then displays them, unfortunately, something weird is happening:
It starts by sending the string: Input 5 characters, this works fine.
I enter 5 characters:
nothing happens at all if i use hyperterminal, and if i use PuTTY it gets the 2nd and 3rd letters wrong in a strange sort of way.
I enter aaaaa.
I get aueaa.
if i enter bbbbb.
i get bvfbb.
if i enter zzzzz.
i get z~~zz.
EDIT:
I have found something which could point to a cause. if i remove the definition of the Numbers object, the output is different.
i enter aaaaa
i get a
'Recieves and Transmits 5 characters to PC CON _CLKMODE = XTAL1 + PLL4X _XINFREQ = 14_000_000 OBJ SLink : "Simple_Serial" Num : "Numbers" VAR Byte char PUB Main SLink.start(31,30,9600) SLink.tx(12) 'Form Feed SendLine(string("Input 5 Characters")) char[noparse][[/noparse]0] := SLink.rx char := SLink.rx char := SLink.rx char := SLink.rx char := SLink.rx SLink.tx(char[noparse][[/noparse]0]) waitcnt(cnt+1_000_000) SLink.tx(char) waitcnt(cnt+1_000_000) SLink.tx(char) waitcnt(cnt+1_000_000) SLink.tx(char) waitcnt(cnt+1_000_000) SLink.tx(char) PUB SendLine(straddr) SLink.str(straddr) SLink.tx(10) 'Line Feed SLink.tx(13) 'Carriage Return
It starts by sending the string: Input 5 characters, this works fine.
I enter 5 characters:
nothing happens at all if i use hyperterminal, and if i use PuTTY it gets the 2nd and 3rd letters wrong in a strange sort of way.
I enter aaaaa.
I get aueaa.
if i enter bbbbb.
i get bvfbb.
if i enter zzzzz.
i get z~~zz.
EDIT:
I have found something which could point to a cause. if i remove the definition of the Numbers object, the output is different.
i enter aaaaa
i get a
Comments
also the forum seems to be messing up the code.
i have defined char as a 5 pos array "byte char [noparse][[/noparse] 4 ]"
and i am writing to the array like so:
char[noparse][[/noparse] 0 ] := SLink.rx
char[noparse][[/noparse] 1 ] := SLink.rx
char[noparse][[/noparse] 2 ] := SLink.rx
char[noparse][[/noparse] 3 ] := SLink.rx
char[noparse][[/noparse] 4 ] := SLink.rx
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Holy parallel processing, Batman!
Post Edited (Mr Crowley) : 10/4/2007 2:46:28 PM GMT
however, using fullduplexserial instead of simpleserial fixes the problem.
thanks for help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Holy parallel processing, Batman!