Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware that echoes transmitted bytes #35

Closed
wants to merge 2 commits into from
Closed

Hardware that echoes transmitted bytes #35

wants to merge 2 commits into from

Commits on Oct 23, 2011

  1. In some boards the serial hardware is wired in such a way that the re…

    …ceiver
    
    is always enabled so
    everything you transmit gets back on the receive buffer, libmodbus thinks it is
    the slave answer and fails with a checksum error.
    
    I tried to fix it by disabling the receiver before transmitting with tcsetatrr and
    turning it back on after transmission but it didn't worked, the bytes were still
    echoed to the receive buffer. So finally I fixed it by reading from the port the
    same amount of bytes transmitted so they get out of the buffer.
    
    Added a new field to the modbus_rtu structure, added a couple functions and
    modified the rtu's transmit function. The new functions are:
    
    int modbus_rtu_set_echohw_mode(modbus_t *ctx, uint8_t mode);
    int modbus_rtu_get_echohw_mode(modbus_t *ctx);
    
    echohw mode can be one of MODBUS_RTU_NO_ECHOHW or MODBUS_RTU_HAS_ECHOHW. By default
    the RTU is in MODBUS_RTU_NO_ECHOHW which means it works as usual, but if you change
    it to MODBUS_RTU_HAS_ECHOHW then all the transmitted bytes will be taken out of the
    receive buffer.
    Jaime Alberto Silva committed Oct 23, 2011
    Copy the full SHA
    ce09c6b View commit details
    Browse the repository at this point in the history
  2. Fixed some macros that made compilation break on systems that don't d…

    …efine
    
    HAVE_DECL_TIOCSRS485.
    Jaime Alberto Silva committed Oct 23, 2011
    Copy the full SHA
    834dfea View commit details
    Browse the repository at this point in the history