Announcement

Collapse
No announcement yet.

COM port staying open

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    COM port staying open

    In HS3 I have a script to turn on my TV that is connected VIA COM port 3. Every time I start HS3 this script works properly and turns on the TV. After a while(6-12 hours) it stops working and I find this in the log. Any ideas what causes this?

    HTML Code:
    Aug-12 7:34:39 AM Warning   Attempt to send to COM port 3, port is not open   
      Aug-12 7:34:39 AM       Error  In OpenComPort, error opening port: Unable to obtain a handle to the COM port

    #2
    Is this for HS2 or HS3? Post the script so we can see if we can spot anything. Is this serial device connected to an on-board serial port or an adapter? If it's on an adapter is the USB root hub set to all the device to hibernate?
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      HS3. Here is the script. I currently only use "TV on" and "TV off" commands.
      When i start HS3 I can trigger the the script multiple times before this happens so it's not every time. It's not isolated to 1 command. Sometimes I turn of the TV and can't turn it back off. Sometimes I turn it off and can't turn it back on. When this happens I just have to restart HS3 and all is well for a little while.

      PHP Code:
        Const ComP As Integer 
        
      Const LT As String "tv" '
        Dim CmdSent As String = ""
         
        Sub Main(ByVal Parms As Object)
         
        hs.writelog(LT, "tv")
         
        End Sub
         
        Sub TVOn(ByVal Parms As Object)
         
        hs.opencomport(ComP, "9600,N,8,1", 1, "tv.vb", "RecData") 
         
        CmdSent = chr(2) & "PON" & chr(3)  
         
        hs.writelog(LT, "Sent : " & CmdSent)
        hs.sendtocomport(ComP, CmdSent & vbCr)
         
        hs.closecomport(ComP)
         
        End Sub
         
        Sub tvOff(ByVal Parms As Object)
         
        hs.opencomport(ComP, "9600,N,8,1", 1, "tv.vb", "RecData")
         
        CmdSent = chr(2) & "POF" & chr(3)
         
        hs.writelog(LT, "Sent : " & CmdSent)
        hs.sendtocomport(ComP, CmdSent)
         
        hs.closecomport(ComP)
         
        End Sub
         
        Sub TV3D(ByVal Parms As Object)
         
        hs.opencomport(ComP, "9600,N,8,1", 1, "tv.vb", "RecData")
         
        CmdSent = chr(2) & "O3D" & chr(3)
         
        hs.writelog(LT, "Sent : " & CmdSent)
        hs.sendtocomport(ComP, CmdSent)
         
        hs.closecomport(ComP)
         
        End Sub
         
        Sub RecData(ByVal Parms As String)
         
        hs.writelog(LT, "Received From tv: " & Parms)
         
        End Sub 

      Comment


        #4
        My experience with that error is that the port disappears from the windows system for whatever reason and then any attempts to get hold of it to connect to fail. This only happens for me on Bluetooth ports so I would look at as Rupp is saying, how is the TV connected to HS. If it is at all possible and you have onboard on motherboard serial ports then try these to see if these behave any better.

        Comment


          #5
          The TV is connected directly to the serial port on the Hometroller.

          Comment


            #6
            Originally posted by freeon View Post
            HS3. Here is the script. I currently only use "TV on" and "TV off" commands.
            When i start HS3 I can trigger the the script multiple times before this happens so it's not every time. It's not isolated to 1 command. Sometimes I turn of the TV and can't turn it back off. Sometimes I turn it off and can't turn it back on. When this happens I just have to restart HS3 and all is well for a little while.
            I would recommend taking a look at drule's IP/Serial Plugin for this, instead of a script. I use it to turn on my pesky Samsung TVs that are controllable over IP for everything EXCEPT switching them on.

            See here for the HS3 version
            cheeryfool

            Comment


              #7
              Originally posted by mrhappy View Post
              My experience with that error is that the port disappears from the windows system for whatever reason and then any attempts to get hold of it to connect to fail. This only happens for me on Bluetooth ports so I would look at as Rupp is saying, how is the TV connected to HS. If it is at all possible and you have onboard on motherboard serial ports then try these to see if these behave any better.
              You say it disappears from windows for whatever reason. It has work properly for 2 years with HS2. It only does this whith HS3. Is it possible HS3 is what is making it disapear from window or does the fact that it works with HS2 iliminate that possibility that it's disapearing from windows.

              Comment


                #8
                There's nothing else grabbing COM3 by any chance (HS2 still running?)

                Just for grins, try putting a "closecomport()" just before you open it again and see if that works. The closecomports in your script may not always be closing? Unfortunately there's no feedback provided for that call to tell if it was successful..

                Z

                Comment


                  #9
                  HS2 is not running and don't currently have another scripts running. The first time I get this message I look at the log between the last time it ran correctly and the error and don't see anything that would open the port. I tried putting " hs.closecomport(ComP)) before the open com port command and I get the same error.

                  Comment


                    #10
                    So what brings that port back to life? Restart HS3? Reboot? Randomly recovers?

                    HomeTroller runs which OS?

                    Z

                    Comment


                      #11
                      Do you need to keep opening and closing the port?

                      Put your opencomport statement in your startup.vb to open the port when Homeseer starts. Then just use sendtocomport as necessary. The port is automatically closed when Homeseer is shut down. All my ports are done this way on my setup and stops other apps taking control.
                      Jon

                      Comment


                        #12
                        I simply restart HS3 then I'm good for day. Hometroller runs on windows XPe.

                        Comment


                          #13
                          Jon's solution would also tell you if it's an HS3/Hometroller issue where the comport gets disconnected...

                          Z

                          Comment


                            #14
                            Originally posted by freeon View Post
                            You say it disappears from windows for whatever reason. It has work properly for 2 years with HS2. It only does this whith HS3. Is it possible HS3 is what is making it disapear from window or does the fact that it works with HS2 iliminate that possibility that it's disapearing from windows.
                            If absolutely nothing has changed between the HS2 install and the HS3 one apart from HS3 is running instead of HS2 then that obviously points to HS3 being the problem. I would do what Jon said really, I wrote the plugin for HS2 for the LGTV's and opened the port at the start and closed it when it shut down and I never had this issue reported to me.

                            Comment


                              #15
                              Ok I have set up HS3 to open the COM port on start up. It can take a day before I get the error so will test this for the next few days and report back. Thanks for now.

                              Comment

                              Working...
                              X