tuxnsk / nodejs_libmodbus

libmodbus binding for nodejs
41 stars 66 forks source link

TCP id #12

Closed snugglebitchi0 closed 7 years ago

snugglebitchi0 commented 9 years ago

hi, How can I connect to specific slave with specific id? In the RTU connection I specify the slave Id when creating connection while in the TCP connection there is no option.

I would appreciate your help, thanks.

tuxnsk commented 9 years ago

ModBus TCP devices not having id. For TCP id replaced to ip address.

2014-12-07 14:31 GMT+06:00 bShnaider notifications@github.com:

hi, How can I connect to specific slave with specific id? In the RTU connection I specify the slave Id when creating connection while in the TCP connection there is no option.

I would appreciate your help, thanks.

— Reply to this email directly or view it on GitHub https://github.com/tuxnsk/nodejs_libmodbus/issues/12.

Contacts: http://tuxnsk.ru/

snugglebitchi0 commented 9 years ago

I have several slave which connected serial on the same bus but all beyond tcp/ip communication card, so i have to create TCP connection. There is no option to request data from specific slave? Is there any other option?

chaser92 commented 9 years ago

Use my fork of jsmodbus for that. Unfortunately no documentation, just read into code or ask me

On Sunday, December 7, 2014, bShnaider notifications@github.com wrote:

I have several slave which connected serial on the same bus but all beyond tcp/ip communication card, so i have to create TCP connection. There is no option to request data from specific slave? Is there any other option?

— Reply to this email directly or view it on GitHub https://github.com/tuxnsk/nodejs_libmodbus/issues/12#issuecomment-65931858 .

Pozdrawiam, Mariusz Kierski

robinxc commented 9 years ago

I want used TCP slaveid ,but this cannot connect to specific slave with specific id

snugglebitchi0 commented 9 years ago

I was able to do it with this project: https://github.com/morkai/h5.modbus

aik8 commented 9 years ago

You could also use native functions. Check this example from README:

var log = console.log;
var native = require('modbus').native;

// create context
var ctx = native.new_tcp("127.0.0.1", 1502);

/* Here you can set the slave id */
native.set_slave(ctx, 255);

// connect to slave device
native.connect(ctx);

// get value
var result = [];
native.read_registers(ctx, 2, 1, result);
log(result[0]);

// set value
native.write_bit(ctx, 1, native.OFF);

// close context
native.close(ctx);
native.free(ctx);