Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
MacOS Swift, send data to USB device with Parameters

Sending data via USB with parameters.

I would like to send data to my USB device, but all the examples only show whereby the request consists only with 1 byte data. My communication document state that I need to send request with parameters consists of 1 word data. How can I do that?

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)")
    }

}

I assume that My request consists of 1 Byte and my parameter consists of 1 word data, but in sequence that would be 3 bytes of data. How can I construct this request?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!