Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
put data from post to socket js

I want to read modbus register using jsmodbus. From www site using POST send to modbus register and counter. I want to put variable inp1, inp2 from app.post to .readHoldingRegister(inp1,inp) How to do that

        app.post('/api/v1/tours', (req,res) =>{
        inp1 = req.body.register;
        inp2 = req.body.count;
        console.log(inp1,inp2);
        res.send('Done powrot');
        if(res.headersSent) { 
            
    console.log('res.headersSent');
        }
    });
    
    
    socket.on('connect', function () {
            
      client
      .readHoldingRegisters(inp1, inp2)
        .then(function (resp) {
          out = resp.response._body._values;
          console.log('out',out)
    
          
          app.get('/', (req, res) => {
        res.status(200).send(`Hello from server side ${resp.response._body.valuesAsArray}`);
        
    })
          socket.end()
        }).catch(function () {
          console.error(require('util').inspect(arguments, {
            depth: null
          }))
          socket.end()
          
        })
    
            
    })
    
    
    socket.on('error', console.error);
    socket.connect(options);
    console.log(out);

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!