How to make a program against the ticalcs library
You will find in the test folder of the library source archive
a test/example program which uses this library.
Below is a light version (most error management has been removed and
update functions are set to void) of this program to make it clearer:
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <ticables.h>
#include <tifiles.h>
#include <ticalcs.h>
static void print_lc_error(int errnum)
{
char *msg;
ticables_error_get(errnum, &msg);
fprintf(stderr, "Link cable error (code %i)...\n<<%s>>\n", errnum, msg);
g_free(msg);
}
int main(int argc, char **argv)
{
CableHandle* cable;
CalcHandle* calc;
int err;
// init libs
ticables_library_init();
ticalcs_library_init();
// set cable
cable = ticables_handle_new(CABLE_BLK, PORT_2);
if(cable == NULL)
return -1;
// set calc
calc = ticalcs_handle_new(CALC_TI83);
if(calc == NULL)
return -1;
// attach cable to calc (and open cable)
err = ticalcs_cable_attach(calc, cable);
err = ticalcs_calc_isready(h);
if(err)
print_lc_error(err);
printf("Hand-held is %sready !\n", err ? "not " : "");
// detach cable (made by handle_del, too)
err = ticalcs_cable_detach(calc);
// remove calc & cable
ticalcs_handle_del(calc);
ticables_handle_del(cable);
return 0;
}
That's all !
NOTE: for this example to work, you probably have to add compiler options related to the include path and library path, e.g.
gcc -I/usr/include/tilp2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Os -g -Wall -W <...>.c -o <...> -lglib-2.0 -lticalcs2
or better
gcc -Os -g -Wall -W `pkg-config --cflags --libs ticalcs2` ticalcs.c -o ticalcs