Hello,
I am currently working on a USB HID-class device and I wanted to test communications between various OSes and the device.
I was able to communicate through standard USB with the device on other OSes such as Windows and Linux, through their integrated kernel modules and generic HID drivers. As a last test, I wanted to test macOS as well.
This is my code, running in a Swift-based command line utility:
import Foundation
import CoreHID
let matchingCriteria = HIDDeviceManager.DeviceMatchingCriteria(vendorID: 0x1234, productID: 0x0006) // This is the VID/PID combination that the device is actually listed under
let manager = HIDDeviceManager()
for try await notification in await manager.monitorNotifications(matchingCriteria: [matchingCriteria]) {
switch notification {
case .deviceMatched(let deviceReference):
print("Device Matched!")
guard let client = HIDDeviceClient(deviceReference: deviceReference) else {
fatalError("Unable to create client. Exiting.") // crash on purpose
}
let report = try await client.dispatchGetReportRequest(type: .input)
print("Get report data: [\(report.map { String(format: "%02x", $0) }.joined(separator: " "))]")
case .deviceRemoved(_):
print("A device was removed.")
default:
continue
}
}
The client.dispatchGetReportRequest(...) line always fails, and if I turn the try expression into a force-unwrapped one (try!) then the code, unsurprisingly, crashes.
The line raises a CoreHID.HIDDeviceError.unknown() exception with a seemingly meaningless IOReturn code (last time I tried I got an IOReturn code with the value of -536870211).
The first instinct is to blame my own custom USB device for not working properly, but it doesn't cooperate with with ANY USB device currently connected: not a keyboard (with permissions granted), not a controller, nothing.
I did make sure to enable USB device access in the entitlements (when I tried to run this code in a simple Cocoa app) as well.
...What am I doing wrong here? What does the IOReturn code mean?
Thanks in advance for anybody willing to help out!
Post
Replies
Boosts
Views
Activity
Let's say we have 2 decodable structs in Swift 5.5, and one of them has a property that contains an array of one of the structs:
struct MySecondDecodable: Decodable {
public let mySecondProperty: String
private enum CodingKeys: String, CodingKey {
case mySecondProperty
}
init(from decoder: Decoder) {
let values = try decoder.container(keyedBy: CodingKeys.self)
mySecondProperty = try values.decode(String.self, forKey: .mySecondProperty)
}
}
struct MyDecodable: Decodable {
public let myProperty: [MySecondDecodable]
private enum CodingKeys: String, CodingKey {
case myProperty
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
myProperty = try values.decode([MySecondDecodable].self, forKey: .myProperty)
}
}
I cannot breakpoint on MySecondDecodable's init function. In fact, I cannot even see it's running.
Why is this happening? Why can't I breakpoint the initialization of every single MySecondDecodable in the array? Is there a way to do such a thing?
For some reason, when I open a QLPreviewController on macOS Big Sur (using Mac Catalyst), the preview item title label is misaligned with the rest of the top bar components in the Quick Look window that was opened. Please refer to the link below for an image showing the issue (remove the spaces, this is in order to avoid the Apple Developer Forum system to filter my question).
Side note: this issue doesn't ever surface on iOS.
Link to image (remove all spaces):
h t t p s : / / p o s t i m g . c c / Z C W x 6 L 1 X
Thank you! This issue is not extremely urgent but I must say that it's pretty irritating 😅
I am trying to make a basic command-line tool that makes a VM and runs something using Apple Hypervisor.
When I try to run:
hv_vm_create(HV_VM_DEFAULT);
it gives me an error code -85377023.
I tried enforcing App Sandbox and setting the entitlement accordingly for the Big Sur compile target, and now I am getting this output in the console:
Killed
From what I understand from this, this is AMFI killing my process. Is this a bug or my problem?
When I decided to go down the rabbit hole, I found that in the MacOS Big Sur 11.0.1 beta release notes, they deprecated hv_vm_run(_:), while the API documentation says that this function is in beta.
I didn't go as far as disabling AMFI with a kernel flag, but I am almost certain that this is not expected behavior. And that, no matter what, hv_vm_run(_:) can never be deprecated OR be in beta. I am sure that this function existed well before Big Sur.
If anyone can help me with this or just give a response, please do. Do not keep me in darkness as I don't want to waste time on something which is potentially broken.
Thank you.
Hello,
Is making what was mentioned in the title possible?