ioctl and TIOCSRS485 problem

I have to set my serial port for a rs485 serial comunication but when I use the ioctl function I have an error, this is the code:
struct serial_rs485 rs485conf;
memset(&rs485conf, 0x0, sizeof(struct serial_rs485));

.......
rs485conf.flags = SER_RS485_ENABLED;
if (ioctl(tty_descriptor, TIOCSRS485, &rs485conf) < 0)
{
return -1;
}
The perror function tell me "Invalid argument".
I 'googled' many pages about ioctl and TIOCSRS485 and everybody use a similar code . The only values that function with ioctl is 2 and 0x5401 (TCGETS). I use a 3.0.0-1-686-pae kernel.
Thank you


What is the declaration of struct serial_rs485? Are you filling out all of the fields you need to?
it is a system struct defined in serial.h
the code is
....
struct serial_rs485 rs485conf;
memset(&rs485conf, 0x0, sizeof(struct serial_rs485));
if (mode == MODBUS_RTU_RS485)
{
rs485conf.flags = SER_RS485_ENABLED;
...
...
Sorry, I don't have the header handy, which is why I asked. The error means that you didn't fill out one or more of the fields correctly, but not knowing what's in the struct, I can't help any more than that.
the struct is so defined
struct serial_rs485 {
__u32 flags; /* RS485 feature flags */
#define SER_RS485_ENABLED (1 << 0)
#define SER_RS485_RTS_ON_SEND (1 << 1)
#define SER_RS485_RTS_AFTER_SEND (1 << 2)
#define SER_RS485_RTS_BEFORE_SEND (1 << 3)
__u32 delay_rts_before_send; /* Milliseconds */
__u32 delay_rts_after_send; /* Milliseconds */
__u32 padding[5]; /* Memory is cheap, new structs
are a royal PITA .. */
};
I tried with some values but nothing change. I will look in the ioctl source in the kernel. Thank you
Topic archived. No new replies allowed.