Originally posted by donstephens
View Post
Announcement
Collapse
No announcement yet.
HS3 Plugin Samples
Collapse
This is a sticky topic.
X
X
-
Last edited by mrhappy; January 31, 2015, 05:30 PM.
-
Thanks to much help I am now receiving data from my Denon Receiver. On to creating devices. The sample code has a function called InitHSDevice. One of the params it wants is
a type Scheduler.Classes.DeviceClass. A bit lost here... do I create a new variable of the type Scheduler.Classes.DeviceClass?
Dim NewDevice As New Scheduler.Classes.DeviceClass?
Leave a comment:
-
Set your breakpoint (F9) to a line in InitIO. This is where the plugin initializes its connection to HomeSeer.
Leave a comment:
-
Originally posted by donstephens View PostStill struggling. I'm trying to walk through the code (Visual Studio Express) but hangs if I start with the step thru and the plugin isn't initialized. If I initialize it via Interfaces page and then try to step through the code I get an error saying the plugin is already active.
Is there some simple (read novice) way to step through the code to see what is going on?
Sorry for the lame questions.
Leave a comment:
-
Still struggling. I'm trying to walk through the code (Visual Studio Express) but hangs if I start with the step thru and the plugin isn't initialized. If I initialize it via Interfaces page and then try to step through the code I get an error saying the plugin is already active.
Is there some simple (read novice) way to step through the code to see what is going on?
Sorry for the lame questions.
Leave a comment:
-
Thanks Adam. Will try it when I get home.
Sent from my XT1080 using Tapatalk
Leave a comment:
-
Don, the first warning is just a warning and it should compile and run without it. HS I don't believe have documented or are really using the search functionality so I would not worry too much about it.
Concerning the serial port is this the .net ports class you are using or the old mscomm control that was used with VB6 (it looks .net-ish but the control name is an older control name). I guess there is nothing wrong with using it but if you are trying for linux support then it should be the .net version. I do this with the .net ports class:
In the declarations declare
Code:Public WithEvents sP As New System.IO.Ports.SerialPort
Code:Private Sub InitComm(ByVal port As String) Log("InitComm Called: " & port, LogLevel.Debug) With sP .PortName = port .BaudRate = 57600 .DataBits = 8 .ReadBufferSize = 214740 .Handshake = Handshake.None .Parity = Parity.None End With Try sP.Open() If sP.IsOpen Then Log("COM Port Open", LogLevel.Debug) Log("COM Port Open", LogLevel.Normal) Else Catch ex As Exception Log("Unable To Open COM Port: " & ex.Message, LogLevel.Normal) Log("InitComm Exception: " & ex.Message, LogLevel.Debug) End Try End Sub
Code:InitComm(port)
Code:Private Sub SerialData(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles sP.DataReceived Log("SerialData Sub Called", LogLevel.Debug) DataInput(sP.ReadLine) End Sub
So in respect to 1) I would pass 'port' into your myComPort routine, accept it as a parameter and use this when you are creating the new serial port however for 2) if you placed 'Dim MSComm1 As New SerialPort' outside of the subroutine then it should be across the class so you would then just need to instead select the port name (so you would add another line of .portname = port or some such) and you could close it by just doing mscomm1.close (or whatever the command is) from another sub.
Leave a comment:
-
I hope not to drive everyone crazy with not to bright questions but I'm trying to run the HSPI_SAMPLE_BASIC plugin and the compiler complains
Warning 1 Function 'Search' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\HS3 Development\HSPI_SAMPLE_BASIC\hspi.vb 280 5 HSPI_SAMPLE_BASIC
I've tried a return statement return "" but doesn't like that.
What is the search function looking for? The exe does compile....
Also I'm struggling with opening and closing a comport.
in the hspi.vb module I found the port# string in the var port which I'm assuming it gets from the interface
page.
PHP Code:Public Function InitIO(ByVal port As String) As String Implements HomeSeerAPI.IPlugInAPI.InitIO
Return oPlugin.InitIO(port)
End Function
PHP Code:Public Shared Sub myComPort()
Dim MSComm1 As New SerialPort(x)
MSComm1.BaudRate = 9600
MSComm1.Parity = Parity.None
MSComm1.StopBits = StopBits.One
MSComm1.DataBits = 8
MSComm1.Handshake = Handshake.None
'AddHandler MSComm1.DataReceived, AddressOf DataReceivedHandler
MSComm1.Open()
End Sub
variable and assigned it the port number in the Function InitIO.
Question 2: How do I make the object MSComm1 public, so I can create a sub to close it without creating a new serial port object?
ThanksLast edited by donstephens; June 4, 2014, 11:25 PM.
Leave a comment:
-
Originally posted by Kirby View PostMy sample now works also. The only plugin I needed to add a reference to was HSPI_HAI_Omnistat.exe.
I guess, from the thread that Mr. Happy pointed me to, that this plugin is serializing complex objects that can't be deserialized without the class definition.
Leave a comment:
-
My sample now works also. The only plugin I needed to add a reference to was HSPI_HAI_Omnistat.exe.
I guess, from the thread that Mr. Happy pointed me to, that this plugin is serializing complex objects that can't be deserialized without the class definition.
Leave a comment:
-
Your example is working now. I copied the plugins from the hometroller to the sample directory and it now works.
The three I copied were:
HSPI_Zwave.exe
HSPI_HAI_Omnistat.exe
HSPI_Sample_CS.exe (a C# version of HSPI_SAMPLE)
Leave a comment:
-
I'm still getting the error. This is what it says in the HS Log.
Initializing plug-in(2): Sample Plugin Instance::Object reference not set to an instance of an object.0STACK: at System.Runtime.Remoting.Messaging.LogicalCallContext.Propaga teIncomingHeadersToCallContext(IMessage msg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Mess ageData& msgData, Int32 type) at HomeSeerAPI.IPlugInAPI.InitIO(String port) at Scheduler.clsHSPI.CheckInterfaces()
I have a couple of plugins on the Hometroller that are not copied to the directory on the remote machine where the HSPI_Sample is running from. Could that be the problem?
Leave a comment:
-
I ran it here and it worked fine a remote PC. Download the latest sample, maybe I need to update the posted samples:
ftp://homeseer.com/pub/HSPI_SAMPLE.exe
On the remote PC launch the plugin with a command prompt with:
hspi_sample.exe server=x.x.x.x
Should connect without error.
Originally posted by Kirby View PostI have run the installer and all three of the HS3 dlls are referenced:
HomeSeerAPI.dll 2/17/14 1.0.2.1
HSCF.dll 2/17/14 1.0.0.2
Scheduler.dll 2/17/14 3.0.0.0
Leave a comment:
-
Should not be, the sample does not use any custom objects. I will load it here and see if I can re-create.
Originally posted by mrhappy View PostCould it be linked to this http://forums.homeseer.com/showthread.php?t=166099 ? Seems to be the right symptoms...
Leave a comment:
-
Could it be linked to this http://forums.homeseer.com/showthread.php?t=166099 ? Seems to be the right symptoms...
Leave a comment:
Leave a comment: