Giter VIP home page Giter VIP logo

Comments (5)

yaacov avatar yaacov commented on July 17, 2024 4

Can you give a code example ?

from node-modbus-serial.

HanSunyi avatar HanSunyi commented on July 17, 2024

@yaacov I find a variable named client._port._buffer
when I am in debug mode,I can see my data exits in client._port._buffer
Should I directlly use client._port._buffer to control my code as below?
something like

reqBuffer = client._port._buffer;
    if (reqBuffer) {
        if(reqBuffer[0] == 3){  //
        //    03      03    0000     0006         C4 2A
        var startHight = reqBuffer[2].toString(16);   // 
        var startLow = reqBuffer[3].toString(16);   //
        var start16 = startHight + startLow; //

        var lenHight = reqBuffer[4].toString(16);   // 
        var lenLow = reqBuffer[5].toString(16);   // 
        var len16 = lenHight + lenLow;          //
        response(parseInt(start16,16),parseInt(len16,16)) // 
        }
    }
           Help me out please!

from node-modbus-serial.

yaacov avatar yaacov commented on July 17, 2024

@HanSunyi hi, thanks

a. We currently only have tcp server [1][2] - a server waits for MoabusTCP requests, and responds to them.

b. We do not have a server for ModbusRTU :-(

c. You are using the client part of the library [3], this is the part that calls a server ( e.g. a controller ) , a client send a request, and then waits for an answer, see examples [4].

p.s
If you want to, you are very welcome to make a pull request adding a RTU server, copy the TCP one [2] and adjust it to listen to the serial port ...

[1] https://github.com/yaacov/node-modbus-serial/blob/master/examples/server.js
[2] https://github.com/yaacov/node-modbus-serial/tree/master/servers
[3] var client = new ModbusRTU(); client.connectRTUBuffered("com6", { baudrate: 9600 });
[4] https://github.com/yaacov/node-modbus-serial/blob/master/examples/logger.js

from node-modbus-serial.

HanSunyi avatar HanSunyi commented on July 17, 2024

@yaacov
Thank you for your help and your patience. : )
I just started using js,I still need to learn a lot of things.

from node-modbus-serial.

yaacov avatar yaacov commented on July 17, 2024

np :-)

from node-modbus-serial.

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.