Communicating two props to each other
demket
Posts: 8
I'm trying to communicate two props with each other. Rx pin connected to Tx pin of other. And I uploaded the code which is below, both of them. When I sent some characters from computer with keyborad, sometimes it's working, sometimes silence intrudes
Where am I doing wrong?
Thanks,
OBJ
UART : "pcFullDuplexSerial4FC" ' 4 port serial driver in one cog.
PUB Main | io_data, pcal
UART.AddPort(0,31,30,-1,-1,0,0,1200)
UART.AddPort(1,3,2,-1,-1,0,0,1200)
UART.Start ' start the object
UART.Start ' start the object
waitcnt(clkfreq + cnt)
repeat
if uart.rxcheck(0)
pcal := uart.rx(0)
uart.tx(1,pcal)
if UART.rxcheck(1)
io_data := UART.rx(1)
uart.tx(0,io_data)
Where am I doing wrong?
Thanks,
OBJ
UART : "pcFullDuplexSerial4FC" ' 4 port serial driver in one cog.
PUB Main | io_data, pcal
UART.AddPort(0,31,30,-1,-1,0,0,1200)
UART.AddPort(1,3,2,-1,-1,0,0,1200)
UART.Start ' start the object
UART.Start ' start the object
waitcnt(clkfreq + cnt)
repeat
if uart.rxcheck(0)
pcal := uart.rx(0)
uart.tx(1,pcal)
if UART.rxcheck(1)
io_data := UART.rx(1)
uart.tx(0,io_data)
Comments
Also, When I disconnect cable which was pluged to rx (pin 3), İt receive "?" and absurd characters. Is this normal.
Your code used rxcheck without saving the value so you'd lose the first character in the buffer and have the program sit and wait for the next character with the rx method.
The main difference between rx and rxcheck is rx waits for a character if there isn't one there and rxcheck returns -1 if there isn't a character. They both return the first character from the buffer if there is one.
Duane
Yes, it's normal. The driver is trying to interpret the noise as characters. The most frequent error character I receive is the infinity sign (character 255).
What is the source of noise? What should we do to prevent the noise?