Plugin: Raw Socket
Launch Data (ActiveX
Classname): PH_Socket.phsocket
Initialization Data: A total of up
to 3 parameters each separated by a single space character. The first parameter is
the IP to connect to, the second parameter is the Port, and the third parameter
is a flag of either 0,1, or 2 controlling the
use of escape sequences within received data. If you omit the third parameter, a value of 0
is assumed. You also have the option of leaving the initialization data blank and manually
connect later through controller commands after PowerHome and the plugin have been loaded.
An example of initialization data might look like: "192.168.0.11 8200 1" without the
quotes.
This plugin provides raw
socket connectivity for PowerHome. If parameters are supplied in the Init Data, then a
connection will be established when the plugin is loaded. Otherwise, you can initiate
a connection manually using the ph_picmd function after the plugin is loaded.
Controller Commands supported:
Command Number |
Description |
1 |
Writes data to the socket. Parm1 contains a
timeout value in seconds. For no timeout, use 0. Parm3 contains the data
you wish send. |
2 |
Applies new Initialization Data and connects the socket. Socket must not already be
connected. Parm1 contains the port. Parm2 contains the escape sequence
flag (0, 1, 2). Parm3 contains the IP. |
3 |
Disconnects the socket |
4 |
Returns the connection status. Returns "0" if
connected. Returns " -2" if disconnected |
5 |
Returns the current IP for the socket |
6 |
Returns the current Port for the socket |
7 |
Returns the current Escape flag |
8 |
Sets a new value for the Escape flag. Parm1
contains the new value |
9 |
Forcibly disconnect socket |
10 |
Writes data to the socket but allows for the
passing of escape characters. A character is escaped by using the "\"
character followed by a 3 digit decimal number representing the ASCII
value of the character or using the "\" character followed by an "x"
followed by a 2 digit hexadecimal number representing the ASCII value.
Parm1 contains the timeout in seconds (Use 0 for no timeout) and Parm3
contains the data to send with special characters escaped. |
11 |
Returns the current socket timeout value |
12 |
Set the socket timeout value. Timeout value is in
Parm1 |
13 |
Returns the current "Mode". The mode is a number
of 0, 1, or 2 and represents how the plugin alerts PowerHome of events
(Error, Data received, etc). A value of 0 (default) will fire a plugin
trigger. A value of 1 will fire a PowerHome Windows event which can be
intercepted by a PowerHome trigger. A value of 2 will result neither a
trigger or a Windows event. |
14 |
Sets the current "Mode" |
100 |
Returns the current data in the receive
buffer |
101 |
Returns the last error number |
102 |
Returns the last error string |
Generic Plugin triggers
fired (when Mode = 0):
Command |
Option |
Description |
1 |
1 |
Fires when data is received by the socket. |
1 |
2 |
Fires when the socket connect |
1 |
3 |
Fires when the socket disconnects |
1 |
4 |
Fires when an error
occurs |
Escape flag values:
The Escape flag parameter
accepts values of either 0, 1, or 2 and controls how data received by the socket
is "escaped". PowerHome is not able to handle non-printable ASCII characters so
if you need to see these characters, they must be escaped.
A value 0 tells the plugin to NOT escape out of range ASCII characters. Any character
outside of the ASCII values of 9, 10, 13, or the range
32 to 125 will simply be dropped from the received data. A value 1 tells the
plugin to escape the out of range characters. Characters outside the range of ASCII
values 9, 10, 13, the range 32 to 125, and the "\" character (92) will be escaped
by a "\" followed by a 3 digit decimal ASCII value. The ASCII character represented
by decimal 15 would be escaped as \015 if the escape value is 1.
An escape value 2 tells the plugin to escape EVERY character received by the socket. This parameter
has nothing to do with how characters are sent to the socket.
Whether characters that are written to the socket are escaped or not is controlled by the controller
command number. See commands 1 and 10 above.
Mode values:
The Mode value is initially
set to 0 but can be changed either 0, 1, or 2 by controller command 14. A Mode
value of 0 (the default) tells the plugin to fire one of the generic plugin
triggers above when an event occurs. A value of 1 tells the plugin to instead
send a Windows command to the main PowerHome window handle allowing for the
firing of a "WM_USER" Trigger Type and a "Trigger 1" Trigger ID. The TEMP3
system variable will contain the Index of the plugin (this
is determined by the order the plugin is loaded. The first plugin loaded is
index 1, the second is index 2, etc. The load order is determined by the "Load
Order" column in the "Setup Plugins" screen. The TEMP4 variable
will contain a value matching the Option value in the Generic Plugin
triggers table above. For example, if the plugin has a "Load Order" of 40, the
Mode value is 1, and data is received by the socket, a Windows message will be
posted to the PowerHome window allowing a trigger of type WM_USER with a trigger
ID of "Trigger 1" to be fired. The TEMP3 system variable will contain the number
4 (Load Order / 10)and the TEMP4 variable will contain the number 1 (Option 1 in the Plugin
table is fired when data is received). A Mode value of 2 tells the plugin to
NOT fire a Generic Plugin trigger nor a
post a Windows message. PowerHome will receive no notification of incoming data, connect, disconnect, or errors.