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

Method onSendOutputReport

lib/hidapi/testgui/test.cpp:372–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372long
373MainWindow::onSendOutputReport(FXObject *sender, FXSelector sel, void *ptr)
374{
375 char buf[256];
376 size_t data_len, len;
377 int textfield_len;
378
379 memset(buf, 0x0, sizeof(buf));
380 textfield_len = getLengthFromTextField(output_len);
381 data_len = getDataFromTextField(output_text, buf, sizeof(buf));
382
383 if (textfield_len < 0) {
384 FXMessageBox::error(this, MBOX_OK, "Invalid length", "Length field is invalid. Please enter a number in hex, octal, or decimal.");
385 return 1;
386 }
387
388 if (textfield_len > sizeof(buf)) {
389 FXMessageBox::error(this, MBOX_OK, "Invalid length", "Length field is too long.");
390 return 1;
391 }
392
393 len = (textfield_len)? textfield_len: data_len;
394
395 int res = hid_write(connected_device, (const unsigned char*)buf, len);
396 if (res < 0) {
397 FXMessageBox::error(this, MBOX_OK, "Error Writing", "Could not write to device. Error reported was: %ls", hid_error(connected_device));
398 }
399
400 return 1;
401}
402
403long
404MainWindow::onSendFeatureReport(FXObject *sender, FXSelector sel, void *ptr)

Callers

nothing calls this directly

Calls 3

errorFunction · 0.50
hid_writeFunction · 0.50
hid_errorFunction · 0.50

Tested by

no test coverage detected