1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<title>Making programs against the TiCables library</title>
5
<style type="TEXT/CSS">
7
BODY {FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; FONT-SIZE: 10pt}
11
PRE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
12
CODE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
16
<body alink="#ff0000" bgcolor="#ffffff" text="#000000" vlink="#0000ff">
17
<h1> How to make a program against the ticalcs library </h1>
19
<pre> <em> </em></pre>
20
You will find in the <i>test</i> folder of the library source archive
21
a test/example program which uses this library.<br>
22
Below is listed a light version (error management has been removed and
23
update functions are set to void) of this program to make it clearer:<br>
25
<table style="width: 100%; text-align: left;" border="0" cellpadding="2"
29
<td style="vertical-align: top;">#include <ticables.h><br>
30
#include <tifiles.h><br>
31
#include <ticalcs.h><br>
33
static void print_lc_error(int errnum)<br>
35
char *msg;<br>
37
ticables_error_get(errnum, &msg);<br>
38
fprintf(stderr, "Link cable error (code
39
%i)...\n<<%s>>\n", <br>
40
errnum, msg);<br>
42
free(msg);<br>
46
int main(int argc, char **argv)<br>
48
CableHandle* cable;<br>
49
CalcHandle* calc;<br>
50
int err;<br>
52
// init libs<br>
53
ticables_library_init();<br>
54
ticalcs_library_init();<br>
56
// set cable<br>
57
cable = ticables_handle_new(CABLE_BLK, PORT_2);<br>
58
if(cable == NULL)<br>
59
return -1;<br>
61
// set calc<br>
62
calc = ticalcs_handle_new(CALC_TI83);<br>
63
if(calc == NULL)<br>
64
return -1;<br>
66
// attach cable to calc (and open cable)<br>
67
err = ticalcs_cable_attach(calc, cable);<br>
69
err = ticalcs_calc_isready(h);<br>
70
if(err)<br>
71
print_lc_error(err);<br>
72
printf("Hand-held is %sready !\n", err ? "not " :
75
// detach cable (made by handle_del, too)<br>
76
err = ticalcs_cable_detach(calc);<br>
78
// remove calc & cable<br>
79
ticalcs_handle_del(calc);<br>
80
ticables_handle_del(cable);<br>
91
<h3><a href="index.html">Return to the main index</a> </h3>
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<title>Making programs against the TiCables library</title>
5
<style type="TEXT/CSS">
7
BODY {FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; FONT-SIZE: 10pt}
11
PRE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
12
CODE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
16
<body alink="#ff0000" bgcolor="#ffffff" text="#000000" vlink="#0000ff">
17
<h1> How to make a program against the ticalcs library </h1>
19
<pre> <em> </em></pre>
20
You will find in the <i>test</i> folder of the library source archive
21
a test/example program which uses this library.<br>
22
Below is a light version (most error management has been removed and
23
update functions are set to void) of this program to make it clearer:<br>
25
<pre>#include <stdio.h>
26
#include <stdlib.h>
27
#include <glib.h>
28
#include <ticables.h>
29
#include <tifiles.h>
30
#include <ticalcs.h>
32
static void print_lc_error(int errnum)
36
ticables_error_get(errnum, &msg);
37
fprintf(stderr, "Link cable error (code %i)...\n<<%s>>\n", errnum, msg);
42
int main(int argc, char **argv)
49
ticables_library_init();
50
ticalcs_library_init();
53
cable = ticables_handle_new(CABLE_BLK, PORT_2);
58
calc = ticalcs_handle_new(CALC_TI83);
62
// attach cable to calc (and open cable)
63
err = ticalcs_cable_attach(calc, cable);
65
err = ticalcs_calc_isready(h);
68
printf("Hand-held is %sready !\n", err ? "not " : "");
70
// detach cable (made by handle_del, too)
71
err = ticalcs_cable_detach(calc);
73
// remove calc & cable
74
ticalcs_handle_del(calc);
75
ticables_handle_del(cable);
80
<strong>NOTE</strong>: for this example to work, you probably have to add compiler options related to the include path and library path, e.g.
81
<pre>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</pre>
83
<pre>gcc -Os -g -Wall -W `pkg-config --cflags --libs ticalcs2` ticalcs.c -o ticalcs</pre>
84
<h3><a href="index.html">Return to the main index</a> </h3>