Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. enum EsconRequest: UInt8 {
  2. case GETSTATUS = 0x01
  3. case ENABLE = 0x05
  4. }
  5.  
  6. func systemEnable () throws {
  7. guard let deviceInterface = self.deviceInfo.deviceInterfacePtrPtr?.pointee?.pointee else {
  8. throw EsconDeviceError.DeviceInterfaceNotFound
  9. }
  10.  
  11. var kr:Int32 = 0
  12. let length:Int = 2
  13. var requestPtr:[UInt16] = [UInt16](repeating: 0, count: length)
  14. // creating request
  15. var request = IOUSBDevRequest(bmRequestType: 161,
  16. bRequest: EsconRequest.ENABLE.rawValue,
  17. wValue: 0,
  18. wIndex: 0,
  19. wLength: UInt16(length),
  20. pData: &requestPtr,
  21. wLenDone: 255)
  22.  
  23. kr = deviceInterface.DeviceRequest(self.deviceInfo.deviceInterfacePtrPtr, &request)
  24.  
  25. if (kr != kIOReturnSuccess) {
  26. throw EsconDeviceError.RequestError(desc: "Enable Device request Error: (kr)")
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement