How to make a program against ticables library
You will find in the test folder of the libary source archive a test/example
program which uses this lib.
Below is listed a light version (error management has been removed) of this
program to make it clearer:
# include <tilp/ticables.h>
# include <tilp/pause.h>
int main(int argc, char **argv)
{
int err;
uint8_t data;
TicableLinkParam lp;
TicableLinkCable lc;
ticable_DISPLAY_settings(DSP_ON); // display verbose informations in a shell/console
ticable_init(); // set cable
ticable_get_default_param(&lp); // we get default parameters for a link cable
lp.delay = 10; // we modify fields with our own values
lp.timeout = 15;
lp.port = SERIAL_PORT_1;
ticable_set_param(&lp); // and make changes
ticable_set_cable(LINK_TGL, &lc); // we choose a link cable model; this init the lc structure
lc.init(); // initialize link cable
lc.open(); // open link cable access
DISPLAY("Wait 1 second...\n"); // display a message (console is enabled by default)
PAUSE(1000); // and we wait for 1 second
DISPLAY("Check if calc is OK...\n"); // we test if calc is ready (89/92+) by sending a RDY packet
lc.put(0x00);
lc.put(0x68);
lc.put(0x00);
lc.put(0x00);
lc.get(&data); // we should receive 4 bytes
printf("Data: %02X\n", data);
lc.get(&data);
printf("Data: %02X\n", data);
lc.get(&data);
printf("Data: %02X\n", data);
lc.get(&data);
printf("Data: %02X\n", data);
lc.close(); // we close link cable access
lc.exit(); // we close the link cable
return 0;
}
That's all !