USB-UIRT: proposal to introduce retries
Posted: Fri Dec 04, 2009 11:05 am
I have a problem when multiple threads are hitting the USB-UIRT at the same time. The following code (in the class TransmitIR) is a proposal to change the plug-in and to introduce handling of retries.
I have noticed that it seems to work (got already several entries in log due to retries) as I expected
Best regards, Walter
I have noticed that it seems to work (got already several entries in log due to retries) as I expected
Best regards, Walter
Code: Select all
def __call__(self, code='', repeatCount=4, inactivityWaitTime=0):
if not self.plugin.dll:
print "dll"
raise self.Exceptions.DeviceNotReady
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 = ""
### Modified by Walter Kraembring. Introduced retries
bSuccess = False
for i in range(0,3):
if i>0:
print "USB-UIRT retries: ", i
time.sleep(0.5)
if 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
):
bSuccess = True
break
if not bSuccess:
raise self.Exceptions.DeviceNotReady
### End modification