Artifact Content
Not logged in

Artifact a2f7fb44570dfd286a245861be2e6f291a29f4fa:

Wiki page [snap7] by chw 2019-04-26 06:38:33.
D 2019-04-26T06:38:33.003
L snap7
P 1c6feb9357a57b4830698afab25c982e99e991bb
U chw
W 3722
<h2>snap7 command</h2>

<h3>Name</h3>

<b>snap7</b> - Tcl interface to the Snap7 library

<h3>Synopsis</h3>

<tt>package require Tcl 8.6</tt><br>
<tt>package require snap7</tt><br>
<tt>snap7::new <i>cmd</i></tt><br>
<tt><i>cmd</i> destroy</tt><br>
<tt><i>cmd</i> connect <i>addr port rack slot</i></tt><br>
<tt><i>cmd</i> disconnect</tt><br>
<tt><i>cmd</i> conntype <i>type</i></tt><br>
<tt><i>cmd</i> param <i>?name? ?value?</i></tt><br>
<tt><i>cmd</i> isconnected</tt><br>
<tt><i>cmd</i> pdulength</tt><br>
<tt><i>cmd</i> dbread <i>db start count</i></tt><br>
<tt><i>cmd</i> dbreada <i>db start count</i></tt><br>
<tt><i>cmd</i> dbwrite <i>db start data ...</i></tt><br>
<tt><i>cmd</i> dbwritea <i>db start bytes</i></tt><br>

<h3>Description</h3>

This  package provides a Tcl interface to the Snap7 library (see <a href="http://snap7.sourceforge.net/">http://snap7.sourceforge.net/</a>) using Ffidl and TclOO.

<h3>Commands</h3>

<tt>snap7::new <i>cmd</i></tt>

    Creates a new command <tt><i>cmd</i></tt> which implements a Snap7 connection object. Further operations on  that object are carried out by invoking methods on <tt><i>cmd</i></tt>.

<tt><i>cmd</i> destroy</tt>

    Destroys the connection object <tt><i>cmd</i></tt>, releases resources and closes communications links.

<tt><i>cmd</i> connect <i>addr port rack slot</i></tt>

    Connects the connection object <tt><i>cmd</i></tt> to its peer using the IP address <tt><i>addr</i></tt>, the TCP port number <tt><i>port</i></tt> and further address information (<tt><i>rack</i></tt> and <tt><i>slot</i></tt> numbers).

<tt><i>cmd</i> disconnect</tt>

    Closes the connection of the connection object <tt><i>cmd</i></tt>.

<tt><i>cmd</i> conntype <i>type</i></tt>

    Sets the connection type of the connection object <tt><i>cmd</tt></i>. Must be called before a connection is made using the <tt>connect</tt> method. Valid values for <tt><i>type</i></tt> are 1 (PG), 2 (OP), and 3 (basic).

<tt><i>cmd</i> param <i>?name? ?value?</i></tt>

    If invoked without arguments, returns a list of parameter names which can be queried or set on the connection object <tt><i>cmd</i></tt>. If <tt><i>name</i></tt> is provided, a query of this named parameter is performed. If both, <tt><i>name</i></tt> and <tt><i>value</i></tt> are provided, the named parameter is set to the value given.

<tt><i>cmd</i> isconnected</tt>

    Returns true or false depending on connection state of the connection object <tt><i>cmd</i></tt>.

<tt><i>cmd</i> pdulength</i></tt>

    Returns a two element list made up of requested and negotiated PDU length of the connection object <tt><i>cmd</i></tt>.

<tt><i>cmd</i> dbread <i>db start count</i></tt>

    Reads <tt><i>count</i></tt> bytes beginning at <tt><i>start</i></tt> from the data block <tt><i>db</i></tt> using the connection object <tt><i>cmd</i></tt>. Data is returned as a list of integer numbers.

<tt><i>cmd</i> dbreada <i>db start count</i></tt>

    Reads <tt><i>count</i></tt> bytes beginning at <tt><i>start</i></tt> from the data block <tt><i>db</i></tt> using the connection object <tt><i>cmd</i></tt>. Data is returned as a byte array.

<tt><i>cmd</i> dbwrite <i>db start data ...</i></tt>

    Writes the numbers specified by <tt><i>data</i></tt> and following arguments as bytes beginning at <tt><i>start</i></tt> into the data block <tt><i>db</i></tt> using the connection object <tt><i>cmd</i></tt>.

<tt><i>cmd</i> dbwritea <i>db start bytes</i></tt>

    Writes the byte array <tt><i>bytes</i></tt> beginning at <tt><i>start</i></tt> into the data block <tt><i>db</i></tt> using the connection object <tt><i>cmd</i></tt>.

Z 20170825c7774d9fd00403ccd9e42c80