Using two serial ports.....
Potato
Posts: 18
I am writing a program which uses TWO serial ports, One Port is connected to Pins 31 and 30 and is used to debug and monitor the program. The other port uses pins 5 and 6, they are connected to a RS232 level converter and talk to a PC using the PC's serial port. I am now using FullDuplexSerialPlus.spin. to talk to Parallax Serial terminal using pins 31 and 30 (works great). I am using simple serial to talk to the PC through pins 5 and 6. I can send characters to the PC (works great).
The problem is, when I want to get characters from the PC SimpleSerial blocks my calling code until a byte is received. This brings my program to a halt until the PC sends a character. I need to use FullDuplexSerialPlus so I can use its buffering ability. If no character is sent by the PC, my program needs to continue on. My program will check it again, after doing some other tasks (Loop). Can I use two instances of FullDuplexSerialPlus? Do I need to use two if the only difference is the pins which are used (the baud rate of the PC and Parallax Serial Terminal are the same). What would you do?
Thanks for your input.
P.S. I guess we could say WWCD (What Would Chip Do)
The problem is, when I want to get characters from the PC SimpleSerial blocks my calling code until a byte is received. This brings my program to a halt until the PC sends a character. I need to use FullDuplexSerialPlus so I can use its buffering ability. If no character is sent by the PC, my program needs to continue on. My program will check it again, after doing some other tasks (Loop). Can I use two instances of FullDuplexSerialPlus? Do I need to use two if the only difference is the pins which are used (the baud rate of the PC and Parallax Serial Terminal are the same). What would you do?
Thanks for your input.
P.S. I guess we could say WWCD (What Would Chip Do)
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
What makes you believe that Potato is such kind of a beginner that can't cope with that other object? He's a retired engineer ...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
I've been using this brilliant bit of code by Tim Moore for many months now obex.parallax.com/objects/340/
One cog.
4 serial drivers in one object. 64 byte buffers for each serial port, so plenty of time to read in bytes and process them when you are ready. And if you want, very easy to add a few lines of spin to test for a byte without reading it (I can help you with that if you need it).
This is pretty simple to use.
define the object in a OBJ section of code
set it up at the beginning of the code
Send a byte
get a byte
test for a byte
and all ports work independently and nothing hangs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller
Post Edited (Dr_Acula) : 3/9/2010 12:59:17 PM GMT
But you are right, it's a brilliant bit of code that I have used myself for lower speed serial coms especially when I've been short on cogs (what, only 8 cores!).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller
I decided to go wading first, so now off to the deep end of the pool !