Christian Auby wrote:
Is it possible to use Boost asio serial with rs485? If yes, is there anything special you need to be aware of?
regards,
Christian
Hi Christian - The answer will depend on your rs485 hardware. RS485 tri-state is typically handled one of two ways: 1. the hardware detects the transmitter is active and asserts the transmitter signals onto the bus. The hardware has a "timeout" that continues to assert the transmitter after each byte (or bit) sent. After the last byte and the timeout period, the hardware will tri-state the bus again. 2. Complete software control. There is a signal that controls the state of the bus. Depending on the state it is either in tri-state or the transmitter drivers are active. This signal is often tied to RTS. If you have option 1... you are set. Just use asio as normal with serial and it will all just work. If you have option 2... life may be bad. The trick is asserting RTS at the right time. You need to know when the last character has actually left the transmit buffer of the hardware. This is the tricky part. If you have a 2-wire 485 you can monitor for your last character. If you have a 4-wire 485 then you are going to need some way to determine when the last character has left. Either way, it is the process is the same. Set the RTS mode to enable transmitters when you want to transmit and then set the mode for tri-state when done. ASIO doesn't have direct control of RTS AFAICT. I have recently answered another thread on this subject ... to quote myself: You can use get_option and set_option to get/set various bits in the windows DCB or posix termios. These pins are not currently described as far as I can tell. Options implement the SetabbleSerialPortOption and GettableSerialPortOption type requirements. Take a look at serial_port_base.hpp for the existing options (such as baud_rate). You will find the implementation in impl/serial_port_base.ipp. It should be fairly easy to use those as a guide to make your own options that support your platform. For windows you will modify the DCB structure and for posix the termios. HTH michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com