Artifact [1c6feb9357]
Not logged in

Artifact 1c6feb9357a57b4830698afab25c982e99e991bb:

Wiki page [snap7] by chw 2018-05-30 06:54:06.
D 2018-05-30T06:54:06.597
L snap7
U chw
W 3696
<h2>Name</h2>

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

<h2>Synopsis</h2>

<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>

<h2>Description</h2>

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.

<h2>Commands</h2>

<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 b1e8011e3a42b2124b892b51c4bfac82