Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: PlugIn Comand - Serial Port Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 06 2012 at 12:11 | IP Logged Quote smarty

I use the PowerHome Raw Comm plugin for a couple of things. Once in a while, it appears they become (or what they attach to becomes) unresponsive. Therefore, i thought I would try to use the PH_PICMD() to disconnet and reconnect. My formula useage is below:

ph_picmd(0,"PH-VSP",7,0,0,"","")

From the PH help file:
+++++++++++++++++++++++++++++++++++++++++++
Raw COMM
Launch Data (ActiveX Classname): PH_Socket.phsocket
Initialization Data: The COM port, a space, the comma separated settings string. Can be left blank to establish a connection manually. In all cases where a "settings" string is required, it consists of the BPS, the data bits, the parity, and the stop bits all separated by commas. An example of 9600 BPS, 8 data bits, No parity, and 1 stop bit would be: 9600,N,8,1

This plugin provides raw COM port functionality for PowerHome. If a COM port and settings string is supplied in the Init Data parameter then the connection will be established when the plugin is loaded. Several commands are available using the ph_picmd function. Command 1 will send the string in data3 out the COM if a connection is already established. This string can contain binary characters by escaping them with the "\" character followed by 3 digits for a decimal representation of the ASCII code or followed by an "x" and 2 digits for a hexadecimal representation of the ASCII code. Command 2 will send a single character represented by the ASCII value contained in the data1 parameter (assuming the COM is connected). Command 3 will manually connect to the COM port in data1 using the settings supplied in data3 (you must be disconnected first). Command 4 disconnect the COM port if already connected. Command 5 will return the current connection status (0 = connected, 1 = disconnected). Command 6 will return the COM port. Command 7 will return the settings.
This plugin will also fire a generic plugin trigger whenever data is received on a connected COM port. The trigger fired will be command 1, option 1 with the length of the data, the string data with binary characters escaped, and the string data with ALL characters escaped available in the [TEMP] variables

===================================
Formula Useage Description
Sends a command to a Generic PowerHome Plugin Control using the standard plugin interface function of phpi_command.
Syntax
ph_picmd ( timeout, id, cmd, data1, data2, data3, data4 )
Argument Description
timeout The length of time in seconds to wait for the plugin to return a value. Use a value of 0 to wait indefinately. Use a negative number to not wait for a return value (post the function call).
id The ID of the PowerHome Plugin.
cmd A long representing the command number.
data1 A long representing the Data 1 value.
data2 A long representing the Data 2 value.
data3 A string representing the Data 3 value.
data4 A string representing the Data 4 value.

Return value
String. Returns the value returned from the Plugin's phpi_command function. Returns empty string if the plugin is not valid or you passed a negative number for the timeout. Returns "*ERROR - PLUGIN TIMEOUT" if the plugin did not return a value before your timeout expired.
Usage
Use this function for general communication with a Generic PowerHome Plugin. This function is a direct passthru to the phpi_command function required by the PowerHome Generic Plugin Interface. Implementation of the cmd and data1 thru data4 parameters is dependent upon the indivdual plugin.

===========================================
My plugin ID is "PH-VSP". The above formula -
ph_picmd(0,"PH-VSP",7,0,0,"","") does nt return what is expected, (nor do the other 1-6 commands of this formule/plugin).

Ideas?


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 06 2012 at 20:01 | IP Logged Quote dhoward

Smarty,

Took a look at the sourcecode and the command (1 thru 7) only returns valid data if the plugin is enabled. If the plugin is not enabled, you should get "100" returned.

I would try running this:

ph_pictrl("PH-VSP","status",0)

to see if the plugin is enabled or disabled. You can also use the ph_pictrl function enable or disable the plugin. Another option for an unresponsive plugin may be reinit with:

ph_pictrl("PH-VSP","reinit",1)

You say you don't get what is expected...just wondering what is returned?

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 07 2012 at 14:11 | IP Logged Quote smarty

See the picture. Edit - My small .jpg file could not be uploaded (couldn't upload a zipped file either)...it appears the PH website might be messed up?

Anyway...
My virtual COMM plugins are active and working (they show up in the Windows Device Manager and they can control the hardware they are connected to), but all I get is "100" returned.

Additionally, when I try:
ph_pictrl("PH-VSP","status",0)
I either get a "0" or a "1".

Even when I get the "1" (I guess that means "active"?),the
ph_picmd(0,"PH-VSP",7,0,0,"","")
still returns "100"

...something seems amiss...

Edited by smarty - May 07 2012 at 14:15


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 08 2012 at 20:03 | IP Logged Quote smarty

I had a little more time to play with this...

By looking at the "Help - About" screen:
ph_pictrl("PH-VSP","status",0)
yeilds a "1" when the plugin status is "enabled"
yeilds a "0" when the plugin staus is "disabled"

The plugin can be disabled using:ph_pictrl("PH-VSP","disable",0)

The pluging can be re-enabled by:ph_pictrl("PH-VSP","reinit",1)
NOTE:ph_pictrl("PH-VSP","enable",0) does NOT seem to do anything???

When the plugin was disabled or re-enabled, the Windows device manager remained unchanged, and still showed the virtual COMMs that where established during the start up process.

Lastly, the ph_picmd() command with options 1-7 just returns 100 (like it is not enabled, even though I can see the plugin status change in the HelpAbout screen). Maybe I am using the command wrong?? Here is my actual command syntax:

ph_picmd(0,"PH-VSP",6,0,0,"","")
or
ph_picmd(0,"PH-VSP",7,0,0,"","")

Ideas...or a bug?
..........................................

Below is from the HelpAbout Screen for my Plugin:

PowerHome Virtual Serial Port Plugin
COM: 50
Remote Host: 192.168.0.104
Remote Port: 2101
PowerHome Plugin ID: PH-VSP
Plugin Version: 1.0
SDK Version: 1.2
Current Status: Enabled.



Edited by smarty - May 08 2012 at 20:06


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 08 2012 at 21:47 | IP Logged Quote dhoward

Smarty,

Got it figured it out. You're actually using the PowerHome Virtual serial port plugin and not the Raw COMM plugin (a I thought you were using). The instuctions you pasted in the first post only apply to the Raw COMM plugin.

With the Virtual serial port plugin, the behaviour you describe is accurate. The plugin currently accepts NO parameters for the ph_picmd function and will always return 100 if the plugin is enabled and 999 if it is disabled.

Doing a ph_pictrl("PH-VSP","disable",0) should (according to the sourcecode) disconnect the socket and delete the virtual serial port (so I would suspect it would no longer show in your device manager but it sounds like this may not be the case). A ph_pictrl("PH-VSP","enable",0) should create the virtual serial port, open the socket control, and make a connection to the remote IP and port.

I can see some room for improvement in error checking and the like so will see what I can do towards working on an improved version. It will most likely have to wait until I get the next beta out as I am way behind and that front.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 09 2012 at 07:34 | IP Logged Quote smarty

Many thanks for the clarification.


I know how I got confused....With the release of version PH 2.12 (and subsequent patches upto Ver 2.14), the help file has a plugin section that describes what they are and their functionality.

The PH-VSP plugin is not mentioned in the help file (but the RAW COMM plugin is). The only place I could find the PH-VSP plugin mentioned is in the changelog description for the release of PH version 2.12.

++++++++++++++++++++

I think the plugin is working fine, but it would be good to see the plugin documention so that I could implement periodic error checking. Is there anything more than the commands already mentioned in this thread?

Edited by smarty - May 09 2012 at 07:48


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: May 09 2012 at 19:15 | IP Logged Quote smarty

dhoward wrote:
....With the Virtual serial port plugin, the behaviour you describe is accurate.

Doing a ph_pictrl("PH-VSP","disable",0) should (according to the sourcecode) disconnect the socket and delete the virtual serial port (so I would suspect it would no longer show in your device manager but it sounds like this may not be the case).
That is correct, the Device Manager still shows the COMM port, even though the plugin shows as disabled in the Help/About window.

dhoward wrote:
... a ph_pictrl("PH-VSP","enable",0) should create the virtual serial port, open the socket control, and make a connection to the remote IP and port.

The "enable" doesn't seem to work (after the "disable" is used).

What does work is: ph_pictrl("PH-VSP","reinit",1) to re-enable the plugin.

Are there any triggers associated with this plugin that could be used for error checking?

Edited by smarty - May 09 2012 at 19:16


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum