Opening a link to a calculator connected by USB¶
In order to open the link to the calculator, the steps are the following:
Call
cahute_open_simple_usb_link()
with the device address.Profit!
Call
cahute_close_link()
to close the link.
Note
If there are multiple calculators connected by USB to your system, you can manage multiple or a specific subset of them by:
Detecting available USB devices using
cahute_detect_usb()
. See Listing calculators connected by USB for steps to do so;Opening a link to a specific USB device using
cahute_open_usb_link()
.
An example program to do this is the following:
/* Compile using: gcc open-usb-link.c `pkg-config cahute --cflags --libs`. */
#include <stdio.h>
#include <cahute.h>
int main(void) {
cahute_link *link;
int err;
err = cahute_open_simple_usb_link(&link, 0);
if (err) {
fprintf(
stderr,
"cahute_open_simple_usb_link() has returned error 0x%04X.\n",
err
);
return 1;
}
/* Profit! */
printf("Link successfully opened!\n");
cahute_close_link(link);
return 0;
}