<< modbus_tcpListen modbus modbus_writeBits >>

modbus >> modbus > modbus_writeBit

modbus_writeBit

write single bit

Calling Sequence

res = modbus_writeBit(mbc, addr, data)
[res, ierr] = modbus_writeBit(mbc, addr, data)

Arguments

mbc

The Modbus connection created with modbus_newTcp or modbus_newRtu.

addr

The address on device where bits should be write from.

data

A boolean or double scalar to write. Non-zero values are considered as TRUE.

res

The number of written bits. -1 if an error occured

ierr

Erreur number.

Description

This function writes the status of bits (coils) from data at the address addr of the remote device

The function uses the Modbus function code 0x0F (force multiple coils).

When called with one output argument, a Scilab error will occur when the writing 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_connect(mbc);
data = 0;
res = modbus_writeBit(mbc, 0, data);
rData = modbus_readBit(mbc, 0)
data == rData
modbus_close(mbc)
modbus_free(mbc)

Report an issue
<< modbus_tcpListen modbus modbus_writeBits >>