Sub TrySetTarget(ByVal channel As Byte, ByVal target As UInt16)
Using device As Usc = ConnectToDevice()
device.setTarget(channel, target)
End Using
End Sub
Sub TrySetSpeed(ByVal channel As Byte, ByVal target As UInt16)
Using device As Usc = ConnectToDevice()
device.setSpeed(channel, target)
End Using
End Sub
Function ConnectToDevice() As Usc
Dim connectedDevices As List(Of DeviceListItem) = Usc.getConnectedDevices()
For Each dli As DeviceListItem In connectedDevices
Dim device As Usc = New Usc(dli)
Return device
Next
Throw New Exception("Could not find device. Make sure it is plugged in to USB and check your Device Manager.")
End Function