Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum EsconRequest: UInt8 {
- case GETSTATUS = 0x01
- case ENABLE = 0x05
- }
- func systemEnable () throws {
- guard let deviceInterface = self.deviceInfo.deviceInterfacePtrPtr?.pointee?.pointee else {
- throw EsconDeviceError.DeviceInterfaceNotFound
- }
- var kr:Int32 = 0
- let length:Int = 2
- var requestPtr:[UInt16] = [UInt16](repeating: 0, count: length)
- // creating request
- var request = IOUSBDevRequest(bmRequestType: 161,
- bRequest: EsconRequest.ENABLE.rawValue,
- wValue: 0,
- wIndex: 0,
- wLength: UInt16(length),
- pData: &requestPtr,
- wLenDone: 255)
- kr = deviceInterface.DeviceRequest(self.deviceInfo.deviceInterfacePtrPtr, &request)
- if (kr != kIOReturnSuccess) {
- throw EsconDeviceError.RequestError(desc: "Enable Device request Error: (kr)")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement