~ubuntu-branches/ubuntu/trusty/libticalcs/trusty-proposed

« back to all changes in this revision

Viewing changes to docs/html/htlib.html

  • Committer: Package Import Robot
  • Author(s): Andreas B. Mundt
  • Date: 2013-08-27 19:58:21 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130827195821-biurlicyqb65gj3g
Tags: 1.1.8+dfsg2-2
* Provide original upstream source, but patch away pre-compiled
  binaries to be policy-compliant.
* Remove unnecessary dependency on 'autopoint', use autoreconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html>
3
 
<head>
4
 
  <title>Making programs against the TiCables library</title>
5
 
  <style type="TEXT/CSS">
6
 
<!--
7
 
BODY {FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; FONT-SIZE: 10pt}
8
 
TD {FONT-SIZE: 10pt}
9
 
H1 {FONT-SIZE: 18pt}
10
 
H3 {FONT-SIZE: 13pt}
11
 
PRE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
12
 
CODE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
13
 
-->
14
 
  </style>
15
 
</head>
16
 
<body alink="#ff0000" bgcolor="#ffffff" text="#000000" vlink="#0000ff">
17
 
<h1> How to make a program against the ticalcs library </h1>
18
 
<hr>
19
 
<pre>&nbsp;<em>&nbsp;</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>
24
 
<br>
25
 
<table style="width: 100%; text-align: left;" border="0" cellpadding="2"
26
 
 cellspacing="2">
27
 
  <tbody>
28
 
    <tr>
29
 
      <td style="vertical-align: top;">#include &lt;ticables.h&gt;<br>
30
 
#include &lt;tifiles.h&gt;<br>
31
 
#include &lt;ticalcs.h&gt;<br>
32
 
      <br>
33
 
static void print_lc_error(int errnum)<br>
34
 
{<br>
35
 
&nbsp;&nbsp;&nbsp; char *msg;<br>
36
 
      <br>
37
 
&nbsp;&nbsp;&nbsp; ticables_error_get(errnum, &amp;msg);<br>
38
 
&nbsp;&nbsp;&nbsp; fprintf(stderr, "Link cable error (code
39
 
%i)...\n&lt;&lt;%s&gt;&gt;\n", <br>
40
 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; errnum, msg);<br>
41
 
      <br>
42
 
&nbsp;&nbsp;&nbsp; free(msg);<br>
43
 
      <br>
44
 
}<br>
45
 
      <br>
46
 
int main(int argc, char **argv)<br>
47
 
{<br>
48
 
&nbsp;&nbsp;&nbsp; CableHandle* cable;<br>
49
 
&nbsp;&nbsp;&nbsp; CalcHandle* calc;<br>
50
 
&nbsp;&nbsp;&nbsp; int err;<br>
51
 
      <br>
52
 
&nbsp;&nbsp;&nbsp; // init libs<br>
53
 
&nbsp;&nbsp;&nbsp; ticables_library_init();<br>
54
 
&nbsp;&nbsp;&nbsp; ticalcs_library_init();<br>
55
 
      <br>
56
 
&nbsp;&nbsp;&nbsp; // set cable<br>
57
 
&nbsp;&nbsp;&nbsp; cable = ticables_handle_new(CABLE_BLK, PORT_2);<br>
58
 
&nbsp;&nbsp;&nbsp; if(cable == NULL)<br>
59
 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br>
60
 
      <br>
61
 
&nbsp;&nbsp;&nbsp; // set calc<br>
62
 
&nbsp;&nbsp;&nbsp; calc = ticalcs_handle_new(CALC_TI83);<br>
63
 
&nbsp;&nbsp;&nbsp; if(calc == NULL)<br>
64
 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br>
65
 
      <br>
66
 
&nbsp;&nbsp;&nbsp; // attach cable to calc (and open cable)<br>
67
 
&nbsp;&nbsp;&nbsp; err = ticalcs_cable_attach(calc, cable);<br>
68
 
      <br>
69
 
&nbsp;&nbsp;&nbsp; err = ticalcs_calc_isready(h);<br>
70
 
&nbsp;&nbsp;&nbsp; if(err)<br>
71
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print_lc_error(err);<br>
72
 
&nbsp;&nbsp;&nbsp; printf("Hand-held is %sready !\n", err ? "not " :
73
 
"");<br>
74
 
      <br>
75
 
&nbsp;&nbsp;&nbsp; // detach cable (made by handle_del, too)<br>
76
 
&nbsp;&nbsp;&nbsp; err = ticalcs_cable_detach(calc);<br>
77
 
      <br>
78
 
&nbsp;&nbsp;&nbsp; // remove calc &amp; cable<br>
79
 
&nbsp;&nbsp;&nbsp; ticalcs_handle_del(calc);<br>
80
 
&nbsp;&nbsp;&nbsp; ticables_handle_del(cable);<br>
81
 
      <br>
82
 
&nbsp; return 0;<br>
83
 
}<br>
84
 
      </td>
85
 
    </tr>
86
 
  </tbody>
87
 
</table>
88
 
<br>
89
 
That's all !
90
 
<pre></pre>
91
 
<h3><a href="index.html">Return to the main index</a> </h3>
92
 
<br>
93
 
<br>
94
 
<br>
95
 
<br>
96
 
</body>
97
 
</html>
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
  <title>Making programs against the TiCables library</title>
 
5
  <style type="TEXT/CSS">
 
6
<!--
 
7
BODY {FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; FONT-SIZE: 10pt}
 
8
TD {FONT-SIZE: 10pt}
 
9
H1 {FONT-SIZE: 18pt}
 
10
H3 {FONT-SIZE: 13pt}
 
11
PRE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
 
12
CODE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
 
13
-->
 
14
  </style>
 
15
</head>
 
16
<body alink="#ff0000" bgcolor="#ffffff" text="#000000" vlink="#0000ff">
 
17
<h1> How to make a program against the ticalcs library </h1>
 
18
<hr>
 
19
<pre>&nbsp;<em>&nbsp;</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>
 
24
<br>
 
25
<pre>#include &lt;stdio.h&gt;
 
26
#include &lt;stdlib.h&gt;
 
27
#include &lt;glib.h&gt;
 
28
#include &lt;ticables.h&gt;
 
29
#include &lt;tifiles.h&gt;
 
30
#include &lt;ticalcs.h&gt;
 
31
      
 
32
static void print_lc_error(int errnum)
 
33
{
 
34
  char *msg;
 
35
 
 
36
  ticables_error_get(errnum, &amp;msg);
 
37
  fprintf(stderr, "Link cable error (code %i)...\n&lt;&lt;%s&gt;&gt;\n", errnum, msg);
 
38
 
 
39
  g_free(msg);
 
40
}
 
41
 
 
42
int main(int argc, char **argv)
 
43
{
 
44
  CableHandle* cable;
 
45
  CalcHandle* calc;
 
46
  int err;
 
47
 
 
48
  // init libs
 
49
  ticables_library_init();
 
50
  ticalcs_library_init();
 
51
 
 
52
  // set cable
 
53
  cable = ticables_handle_new(CABLE_BLK, PORT_2);
 
54
  if(cable == NULL)
 
55
    return -1;
 
56
 
 
57
  // set calc
 
58
  calc = ticalcs_handle_new(CALC_TI83);
 
59
  if(calc == NULL)
 
60
    return -1;
 
61
 
 
62
  // attach cable to calc (and open cable)
 
63
  err = ticalcs_cable_attach(calc, cable);
 
64
 
 
65
  err = ticalcs_calc_isready(h);
 
66
  if(err)
 
67
     print_lc_error(err);
 
68
  printf("Hand-held is %sready !\n", err ? "not " : "");
 
69
 
 
70
  // detach cable (made by handle_del, too)
 
71
  err = ticalcs_cable_detach(calc);
 
72
 
 
73
  // remove calc &amp; cable
 
74
  ticalcs_handle_del(calc);
 
75
  ticables_handle_del(cable);
 
76
 
 
77
  return 0;
 
78
}</pre>
 
79
That's all !<br><br>
 
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 &lt;...&gt;.c -o &lt;...&gt; -lglib-2.0 -lticalcs2</pre>
 
82
or better
 
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>
 
85
</body>
 
86
</html>