<< modbus_setDebug modbus modbus_setTimeout >>

modbus >> modbus > modbus_setSlave

modbus_setSlave

set slave number in Modbus context.

Calling Sequence

status = modbus_setSlave(mbc, slaveId)
[status, ierr] = modbus_setSlave(mbc, slaveId)

Arguments

mbc

The Modbus connection created with modbus_newTcp or modbus_newRtu.

slaveId

The slave ID to assign (from 0 to 254). 255 is used for broadcast.

status

0 if connection was successful and -1 otherwise.

ierr

Erreur number.

Description

This function sets the slave number in the Modbus connection context.

The behavior depends of network and the role of the device:

When called with one output argument, a Scilab error will occur when the setting fails. When called with two output arguments, no Scilab error will occur but ierr will contain the internal modbus error number.

Examples

mbc = modbus_newTcp("127.0.0.1", 502)
modbus_setSlave(mbc, 2);
modbus_free(mbc);

Report an issue
<< modbus_setDebug modbus modbus_setTimeout >>