Jump to content

RxUsbDeregisterNotification: Difference between revisions

From EDM2
Created page with "==Description== Removes the registration of attach/detach notification semaphores. ==Syntax== <pre> rc = RxUsbDeregisterNotification(NotifyID) </pre> ==Parameters== ; Notif..."
 
W.m.brul (talk | contribs)
added return codes and remarks and corrected example code
Line 11: Line 11:


==Return Code==
==Return Code==
 
<pre>
0x0000 - NO_ERROR
</pre>
===Errors===
===Errors===
 
<pre>
0x0006 - ERROR_INVALID_HANDLE
0x001F - ERROR_GEN_FAILURE
0x0057 - ERROR_INVALID_PARAMETER
0x005F - ERROR_INTERRUPT
0x0064 - ERROR_TOO_MANY_SEMAPHORES
0x0067 - ERROR_TOO_MANY_SEM_REQUESTS
0x0069 - ERROR_SEM_OWNER_DIED
0x1B58 - USB_NOT_INIT
0xFF1F - ERROR_GEN_FAILURE
0xFF57 - ERROR_INVALID_PARAMETER
0xFFBB - ERROR_SEM_NOT_FOUND
</pre>
==Remarks==
==Remarks==
Device attach/detach notifications may be obtained by registering event
semaphores to be posted upon attach/detach of USB devices.
The RexxUtil library provides functions to work with event semaphores.
Some of these are used in the example code.


==Example Code==
==Example Code==
<pre>
<pre>
/* add SysCreateEventSem */
/* add RxUsbDeregisterNotification */
rc = RxFuncAdd('SysCreateEventSem','RexxUtil','SysCreateEventSem')
rc = RxFuncAdd('RxUsbDeregisterNotification','usbcalls','RxUsbDeregisterNotification')
say '+SysCreateEventSem(),RC=0x'd2x(rc)
say '+RxUsbDeregisterNotification(),RC=0x'd2x(rc)
 
/* invoke SysCreateEventSem() */
hSemAttach = SysCreateEventSem()
say '*SysCreateEventSem(),RC=0x'd2x(rc)
hSemDetach = SysCreateEventSem()
say '*SysCreateEventSem(),RC=0x'd2x(rc)
 
/* drop SysCreateEventSem */
rc = RxFuncDrop('SysCreateEventSem')
say '-SysCreateEventSem(),RC=0x'd2x(rc)
 
/* add RxUsbRegisterDeviceNotification */
rc = RxFuncAdd('RxUsbRegisterDeviceNotification','usbcalls','RxUsbRegisterDeviceNotification')
say '+RxUsbRegisterDeviceNotification(),RC=0x'd2x(rc)


/* invoke RxUsbRegisterDeviceNotification */
/* invoke RxUsbDeregisterNotification */
idVendor=x2d(046D) /* vendor identifier */
rc = RxUsbDeregisterNotification(NotifyID)
idProduct=x2d(0804) /* product identifier */
say '*RxUsbDeregisterNotification(),RC=0x'd2x(rc)
bcdDevice=x2d(0009) /* device release number */
hDevAdd = hSemAttach; /* attach semaphore handle */
hDevRem = hSemDetach; /* detach semaphore handle */
drop NotifyID /* to receive the notification identifier */
rc = RxUsbRegisterDeviceNotification(NotifyID,hDevAdd,hDevRem,idVendor,idProduct,bcdDevice)
say '*RxUsbRegisterDeviceNotification(),RC=0x'd2x(rc)


/* drop RxUsbRegisterDeviceNotification */
/* drop RxUsbDeregisterNotification */
rc = RxFuncDrop('RxUsbRegisterDeviceNotification')
rc = RxFuncDrop('RxUsbDeregisterNotification')
say '-RxUsbRegisterDeviceNotification(),RC=0x'd2x(rc)
say '-RxUsbDeregisterNotification(),RC=0x'd2x(rc)


/* add SysWaitEventSem */
/* add SysCloseEventSem */
rc = RxFuncAdd('SysWaitEventSem','RexxUtil','SysWaitEventSem')
rc = RxFuncAdd('SysCloseEventSem','RexxUtil','SysCloseEventSem')
say '+SysWaitEventSem(),RC=0x'd2x(rc)
say '+SysCloseEventSem(),RC=0x'd2x(rc)


/* invoke SysWaitEventSem() */
/* invoke SysCloseEventSem() */
timeout = 8000; /* await 8 seconds */
rc = SysCloseEventSem(hSemAttach)
rc = SysWaitEventSem(hSemAttach,timeout)
say '*SysCloseEventSem(),RC=0x'd2x(rc)
say '*SysWaitEventSem(),RC=0x'd2x(rc)
rc = SysCloseEventSem(hSemDetach)
if (rc=0) then say 'obtained Attach Notification'
say '*SysCloseEventSem(),RC=0x'd2x(rc)
rc = SysWaitEventSem(hSemDetach,timeout)
say '*SysWaitEventSem(),RC=0x'd2x(rc)
if (rc=0) then say 'obtained Detach Notification'


/* drop SysWaitEventSem */
/* drop SysCloseEventSem */
rc = RxFuncDrop('SysWaitEventSem')
rc = RxFuncDrop('SysCloseEventSem')
say '-SysWaitEventSem(),RC=0x'd2x(rc)
say '-SysCloseEventSem(),RC=0x'd2x(rc)
</pre>
</pre>



Revision as of 18:32, 23 January 2017

Description

Removes the registration of attach/detach notification semaphores.

Syntax

rc = RxUsbDeregisterNotification(NotifyID)

Parameters

NotifyID
the NotifyID received from RxUsbChangeNotification or RxUsbDeviceNotification.

Return Code

0x0000 - NO_ERROR

Errors

0x0006 - ERROR_INVALID_HANDLE
0x001F - ERROR_GEN_FAILURE
0x0057 - ERROR_INVALID_PARAMETER
0x005F - ERROR_INTERRUPT
0x0064 - ERROR_TOO_MANY_SEMAPHORES
0x0067 - ERROR_TOO_MANY_SEM_REQUESTS
0x0069 - ERROR_SEM_OWNER_DIED
0x1B58 - USB_NOT_INIT
0xFF1F - ERROR_GEN_FAILURE
0xFF57 - ERROR_INVALID_PARAMETER
0xFFBB - ERROR_SEM_NOT_FOUND

Remarks

Device attach/detach notifications may be obtained by registering event semaphores to be posted upon attach/detach of USB devices. The RexxUtil library provides functions to work with event semaphores. Some of these are used in the example code.

Example Code

/* add RxUsbDeregisterNotification */
rc = RxFuncAdd('RxUsbDeregisterNotification','usbcalls','RxUsbDeregisterNotification')
say '+RxUsbDeregisterNotification(),RC=0x'd2x(rc)

/* invoke RxUsbDeregisterNotification */
rc = RxUsbDeregisterNotification(NotifyID)
say '*RxUsbDeregisterNotification(),RC=0x'd2x(rc)

/* drop RxUsbDeregisterNotification */
rc = RxFuncDrop('RxUsbDeregisterNotification')
say '-RxUsbDeregisterNotification(),RC=0x'd2x(rc)

/* add SysCloseEventSem */
rc = RxFuncAdd('SysCloseEventSem','RexxUtil','SysCloseEventSem')
say '+SysCloseEventSem(),RC=0x'd2x(rc)

/* invoke SysCloseEventSem() */
rc = SysCloseEventSem(hSemAttach)
say '*SysCloseEventSem(),RC=0x'd2x(rc)
rc = SysCloseEventSem(hSemDetach)
say '*SysCloseEventSem(),RC=0x'd2x(rc)

/* drop SysCloseEventSem */
rc = RxFuncDrop('SysCloseEventSem')
say '-SysCloseEventSem(),RC=0x'd2x(rc)

Related Functions