LIBMODBUS WITH RS485 (AUTO FLOW CONTROL IC:

212 views
Skip to first unread message

sudhanshu.bh...@gmail.com

unread,
Nov 11, 2017, 8:04:52 AM11/11/17
to libmodbus
Hi libmodbus experts,

I have one RS485 port on my developement board and i have one RS485 T6441 COmet sensor which i need to interface using libmodbus.

My Isolated rs485 part is

My libmodbus source code calls following function after opening modbus context

int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
{
    if (ctx == NULL) {
        errno = EINVAL;
        if (ctx->debug) {
             fprintf(stderr, " FAILED IN CTX NULL\n");
        }
        return -1;
    }

    if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) {
#if HAVE_DECL_TIOCSRS485
        modbus_rtu_t *ctx_rtu = ctx->backend_data;
        struct serial_rs485 rs485conf;
        memset(&rs485conf, 0x0, sizeof(struct serial_rs485));
        if (ctx->debug) {
             fprintf(stderr, " RS 485 SETTING IOCTL WITH NEW PARAMS: %d \n", ctx->s);
        }

        if (mode == MODBUS_RTU_RS485) {
            rs485conf.flags |= SER_RS485_ENABLED;
            rs485conf.flags |= SER_RS485_RTS_AFTER_SEND;
            //rs485conf.delay_rts_before_send = 0;
            rs485conf.delay_rts_after_send = 0;

            if (ioctl(ctx->s, TIOCSRS485, &rs485conf) < 0) {
                if (ctx->debug) {
                 fprintf(stderr, "RS 485 SUD IOCTL FAILED\n");
                }
                return -1;
            }
            ctx_rtu->serial_mode = MODBUS_RTU_RS485;
            return 0;
        }


This will internally override settings for RS485 config in sc16is7xx_reconf_rs485
I am not able to get any success in configuring my SC I2C-UART IC 
DRIVER=sc16is7xx
OF_NAME=sc16is740
OF_FULLNAME=/soc/i2c@c00a6000/sc16is740@49
OF_COMPATIBLE_0=nxp,sc16is740
OF_COMPATIBLE_N=1
MODALIAS=i2c:sc16is740

using modbus configuration

I always get select timeout failure, and unable to read/write registers for my RTU based comet sensor.

Can anyone please let me know what is wrong in libmodbus source code which is not configuring RTS signals corrects?

When i probe my RTS pin, it always stay low, after i do modbus_rtu_set_serial_mode()
But, i see tx sending correct data to the RTU sensor, my RX pin is also showing the data, but RTS still shows low.

Also, my CUSTOM RTS / CTS flag is 0, i.e  HAVE_DECL_TIOCM_RTS = 0

Kindly give your thoughtful pointers

Regards
sudhanshu
Reply all
Reply to author
Forward
0 new messages