Thread (44 messages) flat view 44 messages, 15 authors, 2010-11-16
STALE5763d

[PATCH] Documentation about RS485 serial communications

From: Chris Down <hidden>
Date: 2010-10-28 16:30:39

On 28/10/2010 16:31, Claudio Scordino wrote:
Chris Down ha scritto:
quoted
Just a minor issue.

On 24/10/2010 12:29, Claudio Scordino wrote:
quoted
+4. USAGE FROM USER-LEVEL
+
+   From user-level, RS485 configuration can be get/set using the previous
+   ioctls. For instance, to set RS485 you can use the following code:
+
+	#include <linux/serial.h>
+
+	/* Driver-specific ioctls: */
+	#define TIOCGRS485      0x542E
+	#define TIOCSRS485      0x542F
+
+	/* Open your specific device (e.g., /dev/mydevice): */
+	int fd = open ("/dev/mydevice", O_RDWR);
+	if (fd < 0) {
+		/* Error handling. See errno. */
+	}
+
+	struct serial_rs485 rs485conf;
+
+	/* Set RS485 mode: */
+	rs485conf.flags |= SER_RS485_ENABLED;
+
+	/* Set rts delay before send, if needed: */
This comment is misleading as the delay must be set regardless.
If it is not used it should be set to 0.
quoted
+	rs485conf.flags |= SER_RS485_RTS_BEFORE_SEND;
+	rs485conf.delay_rts_before_send = ...;
Hi.

What do you mean ?

The delay has not to be set regardless: if the
SER_RS485_RTS_BEFORE_SEND flag is not set, then the value of
delay_rts_before_send is ignored, whatever value is contained.

In other words, the value of delay_rts_before_send is used only when
SER_RS485_RTS_BEFORE_SEND is set.

If you don't need a delay, you have to unset the
SER_RS485_RTS_BEFORE_SEND flag rather than setting a delay equal to 0...

Best regards,

	Claudio
 

In that case perhaps it is best to mention that in the comment.
i.e. if the delay is not needed unset the flag as it defaults to set.


Best regards

Chris
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help