Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Artifact ID: | dfb81d0a3824ec7072dea5e25b22121637cec361 |
---|---|
Page Name: | modbus |
Date: | 2020-11-05 14:56:19 |
Original User: | chw |
Parent: | 138d161dd978a10d2796b17b76bf8ba7909ad786 |
modbus command
Name
modbus - Tcl interface to libmodbus
Synopsis
package require Tcl 8.6
package require modbus
modbus::new cmd host service
modbus::new cmd serial baud parity data stop ?slave_addr?
cmd destroy
cmd connect
cmd close
cmd setchan chan
cmd response_timeout ?ms?
cmd serial_mode ?mode?
cmd read_bits addr ?number?
cmd read_input_bits addr ?number?
cmd read_registers addr ?number?
cmd read_input_registers addr ?number?
cmd write_bit addr value
cmd write_register addr value
cmd write_bits addr value ...
cmd write_registers addr value ...
cmd set_slave slave_addr
Description
This package provides a Tcl interface to libmodbus (see http://libmodus.org) using Ffidl and TclOO.
Commands
modbus::new cmd host service
Creates a new command cmd which implements a Modbus-TCP connection object to the given host (IP address or hostname) and service (symbolic or numeric TCP port). Further operations on that object are carried out by invoking methods on cmd.
modbus::new cmd serial baud parity data stop ?slave_addr?
Creates a new command cmd which implements a Modbus-RTU connection object on the serial line serial with parameters baud rate, parity (N=none, O=odd, E=even), data bits, and stop bits. The optional parameter slave_addr specifies the Modbus-RTU slave address and defaults to zero. Further operations on that object are carried out by invoking methods on cmd.
cmd destroy
Destroys the connection object cmd, releases resources and closes communications links.
cmd connect
Connects the connection object cmd to its peer (a TCP server for Modbus-TCP or a serial line for Modbus-RTU).
cmd close
Closes the connection (either the socket or the serial line) of the connection object cmd.
cmd setchan chan
On POSIX platforms, this method duplicates the operating system handle of the Tcl channel chan and wraps it into the cmd connection object. The Tcl channel can be closed immediately after this operation. Depending on the constructor, the operating system handle must provide socket or tty semantics for further I/O methods on cmd to succeed. On Windows platforms, this method is not supported.
cmd response_time ?ms?
Queries or sets the response timeout on the connection object cmd. The timeout is specified in milliseconds.
cmd serial_mode ?mode?
Queries or sets RS-232 or RS-485 mode on the Modbus-RTU connection object cmd. For RS-232 mode must be 0, for RS-485 it must be 1.
cmd read_bits addr ?number?
Reads number coil status bits starting with address addr from the connection object cmd. Number defaults to one.
cmd read_input_bits addr ?number?
Reads number input status bits starting with address addr from the connection object cmd. Number defaults to one.
cmd read_registers addr ?number?
Reads number holding registers starting with address addr from the connection object cmd. Number defaults to one.
cmd read_input_registers addr ?number?
Reads number input registers starting with address addr from the connection object cmd. Number defaults to one.
cmd write_bit addr value
Writes value into the coil status bit with address addr on the connection object cmd.
cmd write_register addr value
Writes value into the holding register with address addr on the connection object cmd.
cmd write_bits addr value ...
Writes one ore more values into the coil status bits starting with address addr on the connection object cmd.
cmd write_registers addr value ...
Writes one ore more values into the holding registers starting with address addr on the connection object cmd.
cmd set_slave ?slave_addr?
Sets the slave address for Modbus-RTU on the connection object cmd to slave_addr.