MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / get_report

Function get_report

lib/hidapi/mac/hid.c:1140–1177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138}
1139
1140static int get_report(hid_device *dev, IOHIDReportType type, unsigned char *data, size_t length)
1141{
1142 unsigned char *report = data;
1143 CFIndex report_length = length;
1144 IOReturn res = kIOReturnSuccess;
1145 const unsigned char report_id = data[0];
1146
1147 register_device_error(dev, NULL);
1148
1149 if (report_id == 0x0) {
1150 /* Not using numbered Reports.
1151 Don't send the report number. */
1152 report = data+1;
1153 report_length = length-1;
1154 }
1155
1156 /* Avoid crash if the device has been unplugged. */
1157 if (dev->disconnected) {
1158 register_device_error(dev, "Device is disconnected");
1159 return -1;
1160 }
1161
1162 res = IOHIDDeviceGetReport(dev->device_handle,
1163 type,
1164 report_id,
1165 report, &report_length);
1166
1167 if (res != kIOReturnSuccess) {
1168 register_device_error_format(dev, "IOHIDDeviceGetReport failed: (0x%08X) %s", res, mach_error_string(res));
1169 return -1;
1170 }
1171
1172 if (report_id == 0x0) { /* 0 report number still present at the beginning */
1173 report_length++;
1174 }
1175
1176 return (int) report_length;
1177}
1178
1179int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
1180{

Callers 2

hid_get_feature_reportFunction · 0.85
hid_get_input_reportFunction · 0.85

Calls 2

register_device_errorFunction · 0.70

Tested by

no test coverage detected