PDA

View Full Version : FullDuplexSerial - txbuffer empty?



heliboy
12-16-2009, 05:26 AM
How can I tell when the txbuffer is empty in FullDuplexSerial ? I need to reverse a half-duplex 485 chip, but I need to hold the direction pin high until the TX buffer is empty. A fixed timeout does not seem to be reliable.

Thanks

Rayman
12-16-2009, 05:40 AM
maybe see if TX_head==TX_tail ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

heliboy
12-16-2009, 06:02 AM
Yes. That works since it is just a circular queue. I had to write·a txempty method in FullSerialDuplex. It would be nicer not to modify it. I take it there is no way to access a FullSerialVariable such as txhead or txtail from another object ?

Peter Jakacki
12-16-2009, 06:02 AM
Most of the time you could just compare tx buffer pointers to see if it's empty but that doesn't tell you if the driver is still sending the last character or not. I have quite a few objects that have RS485 built in at the PASM driver level set via the "mode" options so all the application has to do is transmit and receive while the driver handles the TE and flushing etc. If you want an object like this I can tidy one up a bit and comment it before posting if you like.

RS485 does not require a separate TX and RX line so it saves pins if you tie the TX and RX of the RS485 chip together and the /RE and TE together and just use 2 Prop I/Os.

(P.S. This can't be used with the standard serial objects of course. The PASM level stuff in my driver also asserts, holds and times out the TE line automatically)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Post Edited (Peter Jakacki) : 12/15/2009 11:36:07 PM GMT

Kye
12-16-2009, 06:09 AM
Check out my "Serial Port Driver - Medium Speed" in the OBEX. Its under the protcools.

The driver has a "change baud rate" function that waits until the tx buffer is empty and the last character is sent before it changes the buad rate. So you could just change the buad rate to the same baud rate and this will force you to wait till everything is sent before the function returns.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

heliboy
12-16-2009, 06:43 AM
Yes. There is still occational glitching when trying to monitor the queue. I would quite interested in the RS485 object, so Peter if you would not mind posting your code it would be very helpful. I am running at 57,600 baud so it needs to be able to handle that . Kye - I will check out your driver an your suggestion. It is all in the timing because when I use a commercial RS232-485 converter it works fine, but I want to implement the function with the MAX3430.

Thanks.

Peter Jakacki
12-16-2009, 07:47 AM
heliboy said...
Yes. There is still occational glitching when trying to monitor the queue. I would quite interested in the RS485 object, so Peter if you would not mind posting your code it would be very helpful. I am running at 57,600 baud so it needs to be able to handle that . Kye - I will check out your driver an your suggestion. It is all in the timing because when I use a commercial RS232-485 converter it works fine, but I want to implement the function with the MAX3430.

Thanks.


Ok, there's no problem with the speed as I have some objects running at 1M baud plus. I will try and tidy it up, test it out, and post it today.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Peter Jakacki
12-18-2009, 05:56 AM
Oops, almost forgot (if only life were simpler), just bumping this thread up to remind myself to post the code in the next few hours.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*