[PATCH] Documentation about RS485 serial communications

Chris Down chris at alcor.co.uk
Thu Oct 28 12:30:39 EDT 2010


On 28/10/2010 16:31, Claudio Scordino wrote:
> Chris Down ha scritto:
>> Just a minor issue.
>>
>> On 24/10/2010 12:29, Claudio Scordino wrote:
>>> +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.
>>
>>> +	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



More information about the linux-arm-kernel mailing list