Announcement

Collapse
No announcement yet.

HS3 Plugin Samples

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mrhappy
    replied
    Originally posted by donstephens View Post
    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?
    The sample (if I never edited mine) just wants an optional reference by parameter...if this helps here is some source code of a plugin to send data to a RGB LED controller by TCP socket. Not saying my programming is the best but it the creating devices stuff works fine and you want a rough idea it could be somewhere to start...it is quite simple.
    Last edited by mrhappy; January 31, 2015, 05:30 PM.

    Leave a comment:


  • donstephens
    replied
    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:


  • rmasonjr
    replied
    Set your breakpoint (F9) to a line in InitIO. This is where the plugin initializes its connection to HomeSeer.

    Leave a comment:


  • mrhappy
    replied
    Originally posted by donstephens View Post
    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.
    I personally don't use step through so I can't help there, is there a specific error or function you are trying to run through? All I do from Visual Studio is run the project and it runs the project, any debugging I try and do into the console window. If I must I set a breakpoint but it is rare I need one. With HS3 now you do not need to enable the plugin in the interfaces menu and can just run it straight from VS.

    Leave a comment:


  • donstephens
    replied
    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:


  • donstephens
    replied
    Thanks Adam. Will try it when I get home.

    Sent from my XT1080 using Tapatalk

    Leave a comment:


  • mrhappy
    replied
    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
    Then I create it with this;

    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
    I call InitCom from InitIO just using
    Code:
    InitComm(port)
    which just passes the port straight through. Then to handle the data I just use this event handler
    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
    Which passes the line read to another sub routine for processing.

    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:


  • donstephens
    replied
    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 
    In the same module I'm trying to open and close a com port using the following code.

    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 
    Question 1: How do I get the port number to use in the Sub myComPort? In HS2 I declared a public
    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?

    Thanks
    Last edited by donstephens; June 4, 2014, 11:25 PM.

    Leave a comment:


  • mrhappy
    replied
    Originally posted by Kirby View Post
    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.
    That is my understanding of it also, whoever wrote that plugin should be able to elaborate on whether they are or not...

    Leave a comment:


  • Kirby
    replied
    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:


  • Kirby
    replied
    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:


  • Kirby
    replied
    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:


  • rjh
    replied
    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 Post
    I 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:


  • rjh
    replied
    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 Post
    Could it be linked to this http://forums.homeseer.com/showthread.php?t=166099 ? Seems to be the right symptoms...

    Leave a comment:


  • mrhappy
    replied
    Could it be linked to this http://forums.homeseer.com/showthread.php?t=166099 ? Seems to be the right symptoms...

    Leave a comment:

Working...
X