Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial - txbuffer empty? — Parallax Forums

FullDuplexSerial - txbuffer empty?

heliboyheliboy Posts: 18
edited 2009-12-17 22:56 in Propeller 1
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

Comments

  • RaymanRayman Posts: 14,876
    edited 2009-12-15 22:40
    maybe see if TX_head==TX_tail ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • heliboyheliboy Posts: 18
    edited 2009-12-15 23:02
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-12-15 23:02
    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
  • KyeKye Posts: 2,200
    edited 2009-12-15 23:09
    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,
  • heliboyheliboy Posts: 18
    edited 2009-12-15 23:43
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-12-16 00:47
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2009-12-17 22:56
    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*
Sign In or Register to comment.