Code Monkey home page Code Monkey logo

Comments (3)

stephane avatar stephane commented on August 15, 2024

Which loop? Could you send me your modified code?
Do you use the new the tarball for v2.9.3?

from libmodbus.

harihanv avatar harihanv commented on August 15, 2024

I have used the tarball v2.9.3. To pass all the test cases, I have modified for loop in the unit-test-server.c to flush data. please find the snippet of code for reference, i have also marked "modbus_flush" function in bold.

for (;;) {
rc = modbus_receive(ctx, -1, query);
if (rc == -1) {
/* Connection closed by the client or error */
break;
}

    /* Read holding registers */
    if (query[header_length] == 0x03) {
        if (MODBUS_GET_INT16_FROM_INT8(query, header_length + 3)
            == UT_REGISTERS_NB_POINTS_SPECIAL) {
            printf("Set an incorrect number of values\n");
            MODBUS_SET_INT16_TO_INT8(query, header_length + 3,
                                     UT_REGISTERS_NB_POINTS);
        } else if (MODBUS_GET_INT16_FROM_INT8(query, header_length + 1)
            == UT_REGISTERS_ADDRESS_SPECIAL) {
            modbus_reply_exception(ctx, query,
                                   MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY);
            continue;
        }
    }

    rc = modbus_reply(ctx, query, rc, mb_mapping);
    if (rc == -1) {
        break;
    }

    modbus_flush(ctx);
  • Hide quoted text -
    }

from libmodbus.

stephane avatar stephane commented on August 15, 2024

OK, it's just a workaround but unit tests contain many strange things on purpose so I don't want to hide them with this call.
I don't have the problem on my computer so could you post at least 25 lines of history of server/client tests (github offers a pastebin like). Did you use TCP tests on localhost?

from libmodbus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.