/
6.1-roStorageHotplug

6.1-roStorageHotplug

ON THIS PAGE


This object provides roStorageAttached messages when storage devices appear and roStorageDetached messages when storage devices disappear. There is currently no way to poll for media. 

Object Creation: The roStorageHotplug object is created with no parameters.

CreateObject("roStorageHotplug")

ifUserData

SetUserData(user_data As Object)

Sets the user data that will be returned when events are raised.

GetUserData() As Object

Returns the user data that has previously been set via SetUserData(). It will return Invalid if no data has been set.

ifMessagePort

SetPort(port As roMessagePort)

Posts messages of type roStorageAttached and roStorageDetached to the attached message port.

 


 

In order to avoid race conditions at startup, you should check for any storage devices that might have existed prior to the message port being set. We recommend doing this after the object is created and the message port is set, but before instructing the script to wait for any events.

Example
Sub Main()
    mp = CreateObject("roMessagePort")
    sh = CreateObject("roStorageHotplug")
    gpio = CreateObject("roControlPort", "brightsign")

    sh.SetPort(mp)
    gpio.SetPort(mp)

    finished = false
    while not finished
    ev = mp.WaitMessage(0)
    if type(ev) = "roControlDown"
        finished = true
    else if type(ev) = "roStorageAttached"
        print "ATTACHED "; ev.GetString()
    else if type(ev) = "roStorageDetached"
        print "DETACHED "; ev.GetString()
    else
        print type(ev)
        stop
    end if
    end while
End Sub 

 

 

Related content

roStorageHotplug
roStorageHotplug
More like this
6.1-roStorageAttached, roStorageDetached
6.1-roStorageAttached, roStorageDetached
More like this
roStorageAttached, roStorageDetached
roStorageAttached, roStorageDetached
More like this
usbhotplug
usbhotplug
More like this
roStorageInfo
roStorageInfo
More like this
roAudioEventMx
roAudioEventMx
More like this