3

I am trying to communicate with a device over a RS-485 half duplex serial line. When I send a command to the device, it processes the command and replies immediately after processing. The problem is I have to turn my RS-485 chip into receive mode immediately after sending the command in order to receive the reply of the device. But because my write function of the UART is a non-blocking IO operation I have no way of knowing when to turn my RS-485 chip into receive mode.

How can I do a blocking write operation into the UART that the function will not exit unless all of the bytes are actually sent over the serial line?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
ibrahim
  • 113
  • 8

1 Answers1

0

What is your hardware platform? I have solved that problem before (atmel AT91SAM9260) by configuring the hardware to automatically set the RTS signal. That is your best bet unless you modify the serial drivers in the kernel (and sometimes not even doing that you can do it)

  • My hardware platform is i.MX53. I actually tried to use RTS signal for this purpose but somehow i failed. It seems RTS doesn't care if i'm transmitting something or not. Probably because i couldn't configure uart properly. – ibrahim Mar 09 '13 at 13:27