Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
USB-UIRT stops working ... Anyway to send reset?
USB-UIRT stops working ... Anyway to send reset?
Hey guys. I'm using EventGhost with a USB-UIRT. On occasion, the USB-UIRT stops working. I've found others having this problem in the USB-UIRT forums but no one had a good solution to the problem. For now, what I have to do is disable the USB-UIRT in EventGhost, go to device manager and disable then enable the USB-UIRT, go back into EventGhost and reenable the USB-UIRT. While this works, it is a pain as the computer I'm using it on is my HTPC that has no keyboard (IR input only).
Recently I've found the Microsoft devcon program that allows me to restart the device via commandline. The problem is that it seems I still need to disable the USB-UIRT in EventGhost before I can restart the USB-UIRT device.
Is there any way that EventGhost can detect when the USB-UIRT is not available and then restart the device using devcon or use some other method? Any help would be greatly appreciated.
Recently I've found the Microsoft devcon program that allows me to restart the device via commandline. The problem is that it seems I still need to disable the USB-UIRT in EventGhost before I can restart the USB-UIRT device.
Is there any way that EventGhost can detect when the USB-UIRT is not available and then restart the device using devcon or use some other method? Any help would be greatly appreciated.
Re: USB-UIRT stops working ... Anyway to send reset?
hi, I have noticed this as well.
CaM
CaM
Re: USB-UIRT stops working ... Anyway to send reset?
I've got an old one and never had a problem... use it many times a day.
Are you sure the issue is EG and not hardware?
Do you have the latest drivers installed?
Are you sure the issue is EG and not hardware?
Do you have the latest drivers installed?
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: USB-UIRT stops working ... Anyway to send reset?
EG? I'm pretty sure it has something to do with electrical interference of some sort. The problem happens maybe once a week or longer. Sometimes it happens multiple times in the same day. Other users have posted about the same problem. I am using the current driver.
The real question is can what I am asking actually be accomplished in EventGhost?
The real question is can what I am asking actually be accomplished in EventGhost?
Re: USB-UIRT stops working ... Anyway to send reset?
Bump ... Anyone?
Re: USB-UIRT stops working ... Anyway to send reset?
I've just reread your question. EventGhost is not the problem. The problem is definitely with the hardware. I can not fix the hardware problem so I am trying to find out if EG can detect when the USB-UIRT is no longer accessible and then run an external command to reset it.Livin wrote:I've got an old one and never had a problem... use it many times a day.
Are you sure the issue is EG and not hardware?
Do you have the latest drivers installed?
If this cannot be accomplished, is there a way to disable/enable the USB-UIRT in EG via commandline? I can script something to do this outside of EG.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: USB-UIRT stops working ... Anyway to send reset?
I have looked at the API for the USB-UIRT and there is no "reset" command available. Are you losing contact with the device also in Windows or just from EG???
I am also using an USB-UIRT since years and have never a problem. Even if I hardly believe it will fix your problem, looking at how the plug-in is written, it seems to be possible to introduce regular checks that the device is still alive. Once you detect that it is no longer responding, the only thing you can try to do from SW is to try to reconnect again. But if Windows have lost it too, this wouldn't help
Best regards, Walter
I am also using an USB-UIRT since years and have never a problem. Even if I hardly believe it will fix your problem, looking at how the plug-in is written, it seems to be possible to introduce regular checks that the device is still alive. Once you detect that it is no longer responding, the only thing you can try to do from SW is to try to reconnect again. But if Windows have lost it too, this wouldn't help
Best regards, Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
jsonnabend
- Experienced User
- Posts: 127
- Joined: Wed Apr 23, 2008 7:35 pm
Re: USB-UIRT stops working ... Anyway to send reset?
I was having this problem intermittently. I think uninstalling and re-installing the drivers fixed the problem.
- Jeff
- Jeff
Re: USB-UIRT stops working ... Anyway to send reset?
I'm not certain if it is available to Windows or not. It does not show with the 'broken' icon in device manager, IIRC. I cannot, however, just disable then enable the USB-UIRT in EG. I have to go to device manager and disable/enable it. I'm not sure what's going on, but I'm definitely not the only one that experiences this problem. I used to run Girder and I had the same problem with it as well.krambriw wrote:I have looked at the API for the USB-UIRT and there is no "reset" command available. Are you losing contact with the device also in Windows or just from EG???
I am also using an USB-UIRT since years and have never a problem. Even if I hardly believe it will fix your problem, looking at how the plug-in is written, it seems to be possible to introduce regular checks that the device is still alive. Once you detect that it is no longer responding, the only thing you can try to do from SW is to try to reconnect again. But if Windows have lost it too, this wouldn't help
Re: USB-UIRT stops working ... Anyway to send reset?
Thats it and each time have had these issues (4 setups) I was able to resolve it by rerouting the cables away from noisy devices (power supplies). This includes add-on bugs, not just the USB cable!dinki wrote:EG? I'm pretty sure it has something to do with electrical interference of some sort.
Windows XP Pro sp3 - Several Machines usually latest beta but who knows.
Inputs: TCP / IR (USBUIRT) / RF(X10 Remote) / CLI-Batch / CCTV Motion / Ocelot
Outputs: TCP / IR (USBUIRT) / SageTV / SageTV Clients / YAC CallerID / HAL v3.7.3 / Ocelot
Inputs: TCP / IR (USBUIRT) / RF(X10 Remote) / CLI-Batch / CCTV Motion / Ocelot
Outputs: TCP / IR (USBUIRT) / SageTV / SageTV Clients / YAC CallerID / HAL v3.7.3 / Ocelot
Re: USB-UIRT stops working ... Anyway to send reset?
If you would see my wiring closet you'd understand my desire to have a software solution! 
Really though, I guess I'll have to try and decipher what's going on in the EG code to try and accomplish this task. I can do it all manually, it's just a matter of figuring out how to detect if the USB-UIRT is active or not, how to disable the device in EG (is there a way to send EG a command via the commandline or some other way to do this?), run the devcon command to restart the USB-UIRT, and then reenable in EG.
Errhhh... Welcome to my convoluted world!
Really though, I guess I'll have to try and decipher what's going on in the EG code to try and accomplish this task. I can do it all manually, it's just a matter of figuring out how to detect if the USB-UIRT is active or not, how to disable the device in EG (is there a way to send EG a command via the commandline or some other way to do this?), run the devcon command to restart the USB-UIRT, and then reenable in EG.
Errhhh... Welcome to my convoluted world!
Re: USB-UIRT stops working ... Anyway to send reset?
I have had the same problem (frequently the USB-UIRT would drop out), and I have been doing a number of things to try to work around it recently. First, this USB-UIRT forum thread (http://www.usbuirt.com/phpBB2/viewtopic.php?t=5666) suggests adding ferrite cores to the cables plugged into the back of the USB-UIRT unit. The long-running theory is EMF received from external blaster cables is hosing the USB connection. I have not done this yet, but some people seem to think it works.
Second, I have implemented a software solution, by revising the USB-UIRT plugin code. Basically, whenever an error is detected on an attempted transmission, it calls devcon to disable/enable the driver to reset it. The following code counts on devcon being installed in the Program Files\Eventhost directory:
Note two things in the above code: (1) the new restartDriver method, and (2) the change to TransmitIR::__call__, in which a code starting with "RESTART" triggers the restartDriver method so you can do testing.
I combine the above code with the following code in the EventGhost XML:
This generates a junk IR transmission every 60 seconds. If a problem with the driver is detected, the restartDriver code should be called.
I have only been running the above for a few days, but it seems to have helped.
Good luck!
Second, I have implemented a software solution, by revising the USB-UIRT plugin code. Basically, whenever an error is detected on an attempted transmission, it calls devcon to disable/enable the driver to reset it. The following code counts on devcon being installed in the Program Files\Eventhost directory:
Code: Select all
# This file is part of EventGhost.
# Copyright (C) 2005 Lars-Peter Voss <[email protected]>
#
# EventGhost is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# EventGhost is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EventGhost; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# $LastChangedDate: 2009-07-06 19:09:53 +0200 (Mo, 06 Jul 2009) $
# $LastChangedRevision: 1092 $
# $LastChangedBy: Bitmonster $
"""<rst>
Hardware plugin for the `USB-UIRT <http://www.usbuirt.com/>`_ transceiver.
|
.. image:: picture.jpg
:align: center
:target: http://www.usbuirt.com/
"""
import eg
eg.RegisterPlugin(
name = "USB-UIRT",
author = "Bitmonster",
version = "1.0." + "$LastChangedRevision: 1092 $".split()[1],
kind = "remote",
canMultiLoad = True,
description = __doc__,
# (
# 'Hardware plugin for the <a href="http://www.usbuirt.com/">'
# 'USB-UIRT</a> transceiver.'
# '\n\n<p>'
# '<a href="http://www.usbuirt.com/"><p>'
# '<center><img src="picture.jpg" alt="USB-UIRT" /></a></center>'
# ),
icon = (
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACbklEQVR42mXTa4hMYRzH"
"8f9zzoxmsblMJrzYRHgj140XkiG1Vomd1OwoRVHKreSyRWSRvJHSZktKq0E7LvvCFG/k"
"kh0ZG7UoS1q7G7vjuqsxu2vOeXyfzvPO1Odc5jzP//+cc35HicgQOrEaU3EMO5HAdlxC"
"NRrQjgfoxyrUKTaDeIz1mIwdOIvX2IgPWIt7uIubuIK3OGIKfLeVTYGo7WoK5BFCM7Lo"
"s5O/4g2WYY8poNFmloOxOIBGjMESHMZSTMd1dOOJbXRQ0aKpLLKQk62YhNm4jd04jzW2"
"SNxOvIPLzOswY5QoFqH1CvsQu2yXcTiEEUzBSYTtyswtTLTjnirWP5cS78yoCnwROc35"
"BA6LcPALpkGfL9LC/hyONgYPtV4NxWKD4UKhKyJSW63UzA6tM1x4jz+20zCqcMI+h+Xc"
"3+YY3ceLLFa9iUQpPDAQieZyN44rdarS82r9oLOZnMMMxFhVN4Hxf4g83CdyplckyaBh"
"cwteIR733WIxFM3n59tQmd9e+wodm40LPWw+8sAp9pImZfau8h1Ha8cp99fUuNFsNs2f"
"2xjnsa9n/xmPTDJLIs9IVicRbGFpKap6NA8pKvkqOHHZpxm8xa5gnSmE+0jxOj4RyXZi"
"m+Y4Za+55hZ8lM19E702qm+aE6x7v02eSWDDb5GLz0V+UuQWQdnAdd8kVVFNEzmP1+fy"
"FSUJfSutF1UEUW22H800mlwzbWfRYKVIhsh6I3YFpVGRyFUSRpfkPC4wo8oNAlMM5oh5"
"fn93sTDGKjKTIZZ1lSKjijh534jlK/JuosaxamVVSv7/NXGtJwiI5rt/QdoW/AOsdcg6"
"Kwb6cgAAAABJRU5ErkJggg=="
),
)
import wx
from ctypes import (
c_int, c_uint, c_ulong, byref, c_ubyte, c_char_p, c_void_p, POINTER,
WINFUNCTYPE, Structure, GetLastError, create_string_buffer, WinDLL,
string_at,
)
import datetime
import threading
import os
class Text:
uuInfo = "USB-UIRT Info"
uuProtocol = "Protocol Version: "
uuFirmVersion = "Firmware Version: "
uuFirmDate = "Firmware Date: "
redIndicator = "Red Indicator LED Operation"
blinkRx = "Blink when Receiving IR"
blinkTx = "Blink when Transmitting IR"
notFound = "<not found>"
irReception = "IR Reception"
legacyCodes = "Generate 'legacy' UIRT2-compatible events"
stopCodes = "Pass short repeat codes as enduring events"
class TransmitIR:
name = "Transmit IR"
description = "Transmits an IR code via the USB-UIRT hardware."
irCode = "IR Code:"
learnButton = "Learn an IR Code..."
repeatCount = "Repeat Count:"
infinite = "Infinite"
wait1 = "Wait:"
wait2 = "ms of IR inactivity before transmission"
zone = "Zone:"
zoneChoices = (
"All",
"Ext. Jack R-Pin",
"Ext. Jack L-Pin",
"Internal Emitter",
)
class LearnDialog:
title = "Learn IR Code"
frequency = "Frequency"
signalQuality = "Signal"
progress = "Learn Progress"
acceptBurstButton = "Accept Burst"
forceRaw = "Force RAW-Mode learning"
helpText = \
"1. Aim remote directly at USB-UIRT\n"\
"approximately 6 inches from USB-UIRT face.\n\n"\
"2. PRESS and HOLD the desired button on\n"\
"your remote until learning is complete..."
INVALID_HANDLE_VALUE = -1
UINT32 = c_uint
class UUINFO(Structure):
_fields_ = (
('fwVersion', c_uint),
('protVersion', c_uint),
('fwDateDay', c_ubyte),
('fwDateMonth', c_ubyte),
('fwDateYear', c_ubyte),
)
PUUINFO = POINTER(UUINFO)
UUIRTDRV_ERR_NO_DEVICE = 0x20000001
UUIRTDRV_ERR_NO_RESP = 0x20000002
UUIRTDRV_ERR_NO_DLL = 0x20000003
UUIRTDRV_ERR_VERSION = 0x20000004
UUIRTDRV_CFG_LEDRX = 0x0001
UUIRTDRV_CFG_LEDTX = 0x0002
UUIRTDRV_CFG_LEGACYRX = 0x0004
UUIRTDRV_IRFMT_UUIRT = 0x0000
UUIRTDRV_IRFMT_PRONTO = 0x0010
UUIRTDRV_IRFMT_LEARN_FORCERAW = 0x0100
UUIRTDRV_IRFMT_LEARN_FORCESTRUC = 0x0200
UUIRTDRV_IRFMT_LEARN_FORCEFREQ = 0x0400
UUIRTDRV_IRFMT_LEARN_FREQDETECT = 0x0800
UUCALLBACKPROC = WINFUNCTYPE(c_int, POINTER(c_ubyte), c_ulong, c_ulong)
LEARNCALLBACKPROC = WINFUNCTYPE(c_int, c_uint, c_uint, c_ulong, c_void_p)
class USB_UIRT(eg.IrDecoderPlugin):
text = Text
def __init__(self):
eg.IrDecoderPlugin.__init__(self, 50.0)
self.dll = None
self.enabled = False
self.AddAction(TransmitIR)
def __close__(self):
self.irDecoder.Close()
def __start__(
self,
ledRX=True,
ledTX=True,
legacyRX=False,
repeatStopCodes=False,
):
self.args = (ledRX, ledTX, legacyRX, repeatStopCodes)
self.codeFormat = UUIRTDRV_IRFMT_PRONTO
try:
dll = WinDLL('uuirtdrv')
except:
raise self.Exceptions.DriverNotFound
puDrvVersion = c_uint(0)
if not dll.UUIRTGetDrvInfo(byref(puDrvVersion)):
raise self.Exception("Unable to retrieve uuirtdrv version!")
if puDrvVersion.value != 0x0100:
raise self.Exception("Invalid uuirtdrv version!")
if self.info.evalName[-1].isdigit():
self.deviceStr = "USB-UIRT-%s" % self.info.evalName[-1]
else:
self.deviceStr = "USB-UIRT"
hDrvHandle = dll.UUIRTOpenEx(self.deviceStr, 0, 0, 0)
if hDrvHandle == INVALID_HANDLE_VALUE:
err = GetLastError()
if err == UUIRTDRV_ERR_NO_DLL:
raise self.Exceptions.DriverNotFound
elif err == UUIRTDRV_ERR_NO_DEVICE:
raise self.Exceptions.DeviceNotFound
elif err == UUIRTDRV_ERR_NO_RESP:
raise self.Exceptions.DeviceInitFailed
else:
raise self.Exceptions.DeviceInitFailed
self.hDrvHandle = hDrvHandle
puuInfo = UUINFO()
if not dll.UUIRTGetUUIRTInfo(hDrvHandle, byref(puuInfo)):
raise self.Exceptions.DeviceInitFailed
self.firmwareVersion = str(puuInfo.fwVersion >> 8) + '.' + str(puuInfo.fwVersion & 0xFF)
self.protocolVersion = str(puuInfo.protVersion >> 8) + '.' + str(puuInfo.protVersion & 0xFF)
self.firmwareDate = datetime.date(
puuInfo.fwDateYear+2000,
puuInfo.fwDateMonth,
puuInfo.fwDateDay
)
self.dll = dll
self.receiveProc = UUCALLBACKPROC(self.ReceiveCallback)
res = dll.UUIRTSetRawReceiveCallback(self.hDrvHandle, self.receiveProc, 0)
if not res:
self.dll = None
raise self.Exception("Error calling UUIRTSetRawReceiveCallback")
self.SetConfig(ledRX, ledTX, legacyRX, repeatStopCodes)
self.enabled = True
eg.Bind("System.DeviceRemoved", self.OnDeviceRemoved)
def restartDriver(self):
if self.dll:
self.dll.UUIRTClose(self.hDrvHandle)
os.system("c:\\Program Files\\EventGhost\\devcon disable USB*VID_0403*PID_F850*")
os.system("c:\\Program Files\\EventGhost\\devcon enable USB*VID_0403*PID_F850*")
self.__start__(*self.args)
def __stop__(self):
eg.Unbind("System.DeviceRemoved", self.OnDeviceRemoved)
self.enabled = False
dll = self.dll
if dll:
self.dll = None
if not dll.UUIRTClose(self.hDrvHandle):
raise self.Exception("Error calling UUIRTClose")
# fix for USB-UIRT driver bug, See OnComputerSuspend for details.
self.hDrvHandle = dll.UUIRTOpenEx(self.deviceStr, 0, 0, 0)
# without the UUIRTSetUUIRTConfig call, the driver seems to need
# much more time to close.
self.SetConfig(*self.args)
dll.UUIRTSetReceiveCallback(self.hDrvHandle, None, 0)
dll.UUIRTClose(self.hDrvHandle)
def OnComputerSuspend(self, suspendType):
# The USB-UIRT driver seems to have a bug, that prevents the wake-up
# from standby feature to work, if UUIRTSetRawReceiveCallback was used.
# To workaround the problem, we re-open the device with
# UUIRTSetReceiveCallback just before the system goes into standby and
# later do the reverse once the system comes back from standby.
dll = self.dll
if dll is None:
return
dll.UUIRTClose(self.hDrvHandle)
self.hDrvHandle = dll.UUIRTOpenEx(self.deviceStr, 0, 0, 0)
dll.UUIRTSetReceiveCallback(self.hDrvHandle, None, 0)
def OnComputerResume(self, suspendType):
dll = self.dll
if dll is None:
return
dll.UUIRTClose(self.hDrvHandle)
self.hDrvHandle = dll.UUIRTOpenEx(self.deviceStr, 0, 0, 0)
dll.UUIRTSetRawReceiveCallback(self.hDrvHandle, self.receiveProc, 0)
self.SetConfig(*self.args)
def OnDeviceRemoved(self, event):
if event.payload[0].split("#")[1] == 'Vid_0403&Pid_f850':
if self.dll:
if not self.dll.UUIRTClose(self.hDrvHandle):
raise self.Exception("Error calling UUIRTClose")
self.dll = None
eg.Bind("System.DeviceAttached", self.OnDeviceAttached)
def OnDeviceAttached(self, event):
if event.payload[0].split("#")[1] == 'Vid_0403&Pid_f850':
if self.enabled:
self.__start__(*self.args)
eg.Unbind("System.DeviceAttached", self.OnDeviceAttached)
def SetConfig(self, ledRX, ledTX, legacyRX, repeatStopCodes=False):
value = 0
if ledRX:
value |= UUIRTDRV_CFG_LEDRX
if ledTX:
value |= UUIRTDRV_CFG_LEDTX
if legacyRX:
value |= UUIRTDRV_CFG_LEGACYRX
if repeatStopCodes:
value |= 16
if not self.dll.UUIRTSetUUIRTConfig(self.hDrvHandle, UINT32(value)):
self.dll = None
raise self.Exception("Error calling UUIRTSetUUIRTConfig")
def ReceiveCallback(self, buf, length, userdata):
# TODO: find a more efficient way to find the terminator
data = []
for i in range(2, 1024):
value = buf[i]
data.append(value)
if value == 255:
break
self.irDecoder.Decode(data, len(data))
return 0
def Configure(
self,
ledRx=True,
ledTx=True,
legacyRx=None,
repeatStopCodes=False,
):
text = self.text
if self.dll:
protocolVersion = self.protocolVersion
firmwareVersion = self.firmwareVersion
firmwareDate = self.firmwareDate.strftime("%x")
else:
protocolVersion = text.notFound
firmwareVersion = text.notFound
firmwareDate = text.notFound
panel = eg.ConfigPanel()
ledRxCheckBox = panel.CheckBox(ledRx, text.blinkRx)
ledTxCheckBox = panel.CheckBox(ledTx, text.blinkTx)
legacyRxCheckBox = panel.CheckBox(legacyRx, text.legacyCodes)
stopCodesRxCheckBox = panel.CheckBox(repeatStopCodes, text.stopCodes)
infoGroupSizer = wx.StaticBoxSizer(
wx.StaticBox(panel, -1, text.uuInfo),
wx.VERTICAL
)
infoSizer = wx.FlexGridSizer(3, 2)
infoSizer.AddMany([
(panel.StaticText(text.uuProtocol), 0, wx.EXPAND),
(panel.StaticText(protocolVersion), 0, wx.EXPAND),
(panel.StaticText(text.uuFirmVersion), 0, wx.EXPAND),
(panel.StaticText(firmwareVersion), 0, wx.EXPAND),
(panel.StaticText(text.uuFirmDate), 0, wx.EXPAND),
(panel.StaticText(firmwareDate), 0, wx.EXPAND),
])
infoGroupSizer.Add(infoSizer, 0, wx.LEFT, 5)
panel.sizer.Add(infoGroupSizer, 0, wx.EXPAND)
panel.sizer.Add((15, 15))
ledGroupSizer = wx.StaticBoxSizer(
wx.StaticBox(panel, -1, text.redIndicator),
wx.VERTICAL
)
ledGroupSizer.Add(ledRxCheckBox, 0, wx.ALL, 10)
ledGroupSizer.Add(ledTxCheckBox, 0, wx.ALL, 10)
panel.sizer.Add(ledGroupSizer, 0, wx.EXPAND)
panel.sizer.Add((15, 15))
receiveGroupSizer = wx.StaticBoxSizer(
wx.StaticBox(panel, -1, text.irReception),
wx.VERTICAL
)
receiveGroupSizer.Add(legacyRxCheckBox, 0, wx.ALL, 10)
receiveGroupSizer.Add(stopCodesRxCheckBox, 0, wx.ALL, 10)
panel.sizer.Add(receiveGroupSizer, 0, wx.EXPAND)
while panel.Affirmed():
panel.SetResult(
ledRxCheckBox.GetValue(),
ledTxCheckBox.GetValue(),
legacyRxCheckBox.GetValue(),
stopCodesRxCheckBox.GetValue(),
)
class TransmitIR(eg.ActionClass):
repeatCount = 4
inactivityWaitTime = 0
def __call__(self, code='', repeatCount=4, inactivityWaitTime=0):
if not self.plugin.dll:
raise self.Exceptions.DeviceNotReady
if code.startswith("RESTART"):
self.plugin.restartDriver()
return
if len(code) > 5:
start = 0
if code[0] == "Z":
start = 2
if code[start+3] == "R":
codeFormat = UUIRTDRV_IRFMT_UUIRT
elif code[start+4] == " ":
codeFormat = UUIRTDRV_IRFMT_PRONTO
else:
codeFormat = UUIRTDRV_IRFMT_LEARN_FORCESTRUC
else:
repeatCount = 0
codeFormat = UUIRTDRV_IRFMT_PRONTO
code = ""
tryagain = True
while tryagain:
if not self.plugin.dll.UUIRTTransmitIR(
self.plugin.hDrvHandle, # hHandle
c_char_p(code), # IRCode
codeFormat, # codeFormat
repeatCount, # repeatCount
inactivityWaitTime, # inactivityWaitTime
0, # hEvent
0, # reserved1
0 # reserved2
):
if tryagain:
tryagain = False
self.plugin.restartDriver()
else:
raise self.Exceptions.DeviceNotReady
else:
return
def GetLabel(self, code='', repeatCount=4, inactivityWaitTime=0):
return self.name
def Configure(self, code='', repeatCount=None, inactivityWaitTime=None):
text = self.text
panel = eg.ConfigPanel()
if repeatCount is None:
repeatCount = self.repeatCount
if inactivityWaitTime is None:
inactivityWaitTime = self.inactivityWaitTime
if len(code) > 0:
zone = 0
if code[0] == "Z":
zone = int(code[1])
code = code[2:]
else:
zone = 0
editCtrl = panel.TextCtrl(code, style=wx.TE_MULTILINE)
font = editCtrl.GetFont()
font.SetFaceName("Courier New")
editCtrl.SetFont(font)
editCtrl.SetMinSize((-1, 100))
repeatCtrl = eg.SpinIntCtrl(panel, -1, value=repeatCount, min=1, max=127)
repeatCtrl.SetInitialSize((50, -1))
infiniteCtrl = wx.CheckBox(panel, -1, text.infinite)
if repeatCount == 32767:
repeatCtrl.SetValue(4)
repeatCtrl.Enable(False)
infiniteCtrl.SetValue(True)
else:
repeatCtrl.SetValue(repeatCount)
def OnInfiniteCtrl(event):
repeatCtrl.Enable(not infiniteCtrl.GetValue())
event.Skip()
infiniteCtrl.Bind(wx.EVT_CHECKBOX, OnInfiniteCtrl)
waitCtrl = panel.SpinIntCtrl(inactivityWaitTime, 0, 500)
waitCtrl.SetInitialSize((50, -1))
zoneCtrl = panel.Choice(zone, text.zoneChoices)
learnButton = panel.Button(text.learnButton)
if self.plugin.dll is None:
learnButton.Enable(False)
panel.sizer.Add(panel.StaticText(text.irCode))
panel.sizer.Add(editCtrl, 1, wx.EXPAND)
panel.sizer.Add((5, 5))
stFlags = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT
gridSizer = wx.GridBagSizer(5, 5)
gridSizer.Add(panel.StaticText(text.repeatCount), (0, 0), flag=stFlags)
tmpSizer = wx.BoxSizer(wx.HORIZONTAL)
tmpSizer.Add(repeatCtrl)
tmpSizer.Add((5, 5))
tmpSizer.Add(infiniteCtrl, 0, wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(tmpSizer, (0, 1))
gridSizer.Add(panel.StaticText(text.wait1), (1, 0), flag=stFlags)
tmpSizer = wx.BoxSizer(wx.HORIZONTAL)
tmpSizer.Add(waitCtrl)
tmpSizer.Add((5, 5))
tmpSizer.Add(panel.StaticText(text.wait2), 0, wx.ALIGN_CENTER_VERTICAL)
gridSizer.Add(tmpSizer, (1, 1))
gridSizer.Add(panel.StaticText(text.zone), (2, 0), flag=stFlags)
gridSizer.Add(zoneCtrl, (2, 1))
gridSizer.AddGrowableCol(4, 1)
gridSizer.Add(
learnButton,
(0,5),
flag=wx.ALIGN_RIGHT|wx.EXPAND
)
panel.sizer.Add(gridSizer, 0, wx.EXPAND)
def LearnIR(event):
learnDialog = IRLearnDialog(
None,
self.plugin.dll,
self.plugin.hDrvHandle,
text.LearnDialog
)
learnDialog.ShowModal()
if learnDialog.code:
editCtrl.SetValue(learnDialog.code)
learnDialog.AbortLearnThreadWait()
learnDialog.Destroy()
learnButton.Bind(wx.EVT_BUTTON, LearnIR)
while panel.Affirmed():
zone = zoneCtrl.GetValue()
if zone > 0:
code = "Z" + str(zone) + editCtrl.GetValue()
else:
code = editCtrl.GetValue()
if infiniteCtrl.GetValue():
self.__class__.repeatCount = 32767
else:
self.__class__.repeatCount = repeatCtrl.GetValue()
self.__class__.inactivityWaitTime = waitCtrl.GetValue()
panel.SetResult(
code,
self.repeatCount,
self.inactivityWaitTime
)
class IRLearnDialog(wx.Dialog):
def __init__(self, parent, dll, hDrvHandle, text):
self.dll = dll
self.hDrvHandle = hDrvHandle
self.code = None
self.codeFormat = UUIRTDRV_IRFMT_PRONTO
wx.Dialog.__init__(
self,
parent,
-1,
text.title,
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER
)
staticText = wx.StaticText(self, -1, text.helpText)
sb = wx.StaticBox(self, -1, text.progress)
progressSizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
progressCtrl = wx.Gauge(self, -1, 100, size=(250, 25))
self.progressCtrl = progressCtrl
progressSizer.Add(progressCtrl, 0, wx.ALL|wx.EXPAND, 5)
sb = wx.StaticBox(self, -1, text.signalQuality)
sigQualitySizer = wx.StaticBoxSizer(sb, wx.HORIZONTAL)
sigQualityCtrl = wx.Gauge(
self,
-1,
100,
size=(25, 100),
style=wx.GA_VERTICAL|wx.GA_SMOOTH
)
self.sigQualityCtrl = sigQualityCtrl
sigQualitySizer.Add(sigQualityCtrl, 0, wx.ALL|wx.EXPAND, 5)
sb = wx.StaticBox(self, -1, text.frequency)
carrierFreqSizer = wx.StaticBoxSizer(sb, wx.HORIZONTAL)
carrierFreqCtrl = wx.StaticText(self, -1, "-", style=wx.ALIGN_CENTER)
self.carrierFreqCtrl = carrierFreqCtrl
carrierFreqSizer.Add(carrierFreqCtrl, 1, wx.EXPAND|wx.ALL, 5)
forceRawCtrl = wx.CheckBox(self, -1, text.forceRaw)
forceRawCtrl.Bind(wx.EVT_CHECKBOX, self.OnRawBox)
self.forceRawCtrl = forceRawCtrl
cancelButton = wx.Button(self, wx.ID_CANCEL, eg.text.General.cancel)
cancelButton.Bind(wx.EVT_BUTTON, self.OnCancel)
cancelButton.SetDefault()
burstButton = wx.Button(self, wx.ID_CANCEL, text.acceptBurstButton)
burstButton.Bind(wx.EVT_BUTTON, self.OnAcceptBurst)
burstButton.Enable(False)
self.burstButton = burstButton
leftSizer = wx.BoxSizer(wx.VERTICAL)
leftSizer.Add(staticText, 0, wx.EXPAND|wx.TOP, 5)
leftSizer.Add((5, 5), 1)
leftSizer.Add(forceRawCtrl)
rightSizer = wx.BoxSizer(wx.VERTICAL)
rightSizer.Add((15, 15))
rightSizer.Add(burstButton, 0, wx.EXPAND|wx.ALIGN_RIGHT)
rightSizer.Add((5, 5))
rightSizer.Add(cancelButton, 0, wx.EXPAND|wx.ALIGN_RIGHT)
rightSizer.Add((0, 0), 1)
rightSizer.Add(carrierFreqSizer, 0, wx.EXPAND)
upperRowSizer = wx.BoxSizer(wx.HORIZONTAL)
upperRowSizer.Add(leftSizer, 1, wx.EXPAND)
upperRowSizer.Add((5, 5))
upperRowSizer.Add(sigQualitySizer, 0, wx.EXPAND)
upperRowSizer.Add((5, 5))
upperRowSizer.Add(rightSizer, 0, wx.EXPAND)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(upperRowSizer, 1, wx.EXPAND|wx.ALL, 5)
sizer.Add(progressSizer, 0, wx.EXPAND|wx.ALL, 5)
self.SetSizer(sizer)
self.SetAutoLayout(True)
sizer.Fit(self)
self.SetMinSize(self.GetSize())
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.StartLearnIR()
def SetRawMode(self, flag=True):
if flag:
self.codeFormat = UUIRTDRV_IRFMT_LEARN_FORCERAW
else:
self.codeFormat = UUIRTDRV_IRFMT_PRONTO
def StartLearnIR(self):
self.learnThreadAbortEvent = threading.Event()
self.bAbortLearn = c_int(0)
self.learnThread = threading.Thread(target=self.LearnThread)
self.learnThread.start()
def AbortLearnThread(self):
self.bAbortLearn.value = True
def AbortLearnThreadWait(self):
self.bAbortLearn.value = True
self.learnThreadAbortEvent.wait(10)
def AcceptBurst(self):
self.bAbortLearn.value = -1
def LearnThread(self):
learnBuffer = create_string_buffer('\000' * 2048)
self.dll.UUIRTLearnIR(
self.hDrvHandle, # hHandle
self.codeFormat, # codeFormat
learnBuffer, # IRCode buffer
LEARNCALLBACKPROC(self.LearnCallback), # progressProc
0x5a5a5a5a, # userData
byref(self.bAbortLearn), # *pAbort
0, # param1
0, # reserved0
0 # reserved1
)
if self.bAbortLearn.value != 1:
self.OnLearnSuccess(learnBuffer.value)
self.learnThreadAbortEvent.set()
def LearnCallback(self, progress, sigQuality, carrierFreq, userData):
if progress > 0:
self.burstButton.Enable(True)
self.progressCtrl.SetValue(progress)
self.sigQualityCtrl.SetValue(sigQuality)
self.carrierFreqCtrl.SetLabel(
"%d.%03d kHz" % (carrierFreq / 1000, carrierFreq % 1000)
)
return 0
def OnLearnSuccess(self, code):
self.code = code
self.Close()
def OnRawBox(self, event):
self.AbortLearnThreadWait()
self.SetRawMode(self.forceRawCtrl.GetValue())
self.burstButton.Enable(False)
self.progressCtrl.SetValue(0)
self.sigQualityCtrl.SetValue(0)
self.StartLearnIR()
def OnAcceptBurst(self, event):
self.AcceptBurst()
def OnClose(self, event):
self.AbortLearnThread()
event.Skip()
def OnCancel(self, event):
self.Close()
I combine the above code with the following code in the EventGhost XML:
Code: Select all
<Macro Name="Restart USB-UIRT Loop" Expanded="True">
<Event Name="Main.OnInit" />
<Event Name="Main.RestartUSBUIRT" />
<Action Name="IR Xmit: JUNK">USB_UIRT.TransmitIR(u'Z30000 0048 0001 0011 0017 0163 0017 0061 0017 00a3 0017 00a3 0017 0061 0017 0061 0017 0061 0017 0061 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 00a3 0017 0163', 1, 1)</Action>
<Action>EventGhost.TriggerEvent(u'RestartUSBUIRT', 60.0)</Action>
</Macro>I have only been running the above for a few days, but it seems to have helped.
Good luck!
Last edited by rcw on Tue Aug 11, 2009 1:33 pm, edited 1 time in total.
Re: USB-UIRT stops working ... Anyway to send reset?
Note that EventGhost must be running as Administrator on Vista and Windows 7 in order for devcon to run (which may require you to turn UAC off to get EventGhost to run automatically at startup). If you do a test RESTART command, the event log should show disconnect/reconnect events.
Re: USB-UIRT stops working ... Anyway to send reset?
Hi. I just wanted to quickly say thank you. I've had this exact same problem and couldn't for the life of me figure out how to fix it. Finally after reading your post I discovered the Disable/Enable trick through Device Manager. I use it with SageTV on Vista x64.
-
pricequest
- Posts: 1
- Joined: Tue Feb 19, 2013 4:53 pm
Re: USB-UIRT stops working ... Anyway to send reset?
All of my intermittent connection drops went away when I connected the USB-UIRT to a port on a dedicated USB PCI card (I used a dual port USB3.0 card, renasys driver).
I have 2 HD-PVR's which may have been related to the connection loss.
Just make sure you re-install the beta USB-UIRT drivers :
http://forums.sagetv.com/forums/showthr ... post440588
when you change the USB-UIRT's usb port.
I have 2 HD-PVR's which may have been related to the connection loss.
Just make sure you re-install the beta USB-UIRT drivers :
http://forums.sagetv.com/forums/showthr ... post440588
when you change the USB-UIRT's usb port.