File: htlib.html

package info (click to toggle)
libticalcs 1.1.8%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,916 kB
  • ctags: 4,610
  • sloc: ansic: 21,347; sh: 11,834; asm: 1,370; pascal: 425; makefile: 204; sed: 16
file content (86 lines) | stat: -rw-r--r-- 2,506 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Making programs against the TiCables library</title>
  <style type="TEXT/CSS">
<!--
BODY {FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; FONT-SIZE: 10pt}
TD {FONT-SIZE: 10pt}
H1 {FONT-SIZE: 18pt}
H3 {FONT-SIZE: 13pt}
PRE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
CODE {FONT-FAMILY: Courier New; FONT-SIZE: 9pt}
-->
  </style>
</head>
<body alink="#ff0000" bgcolor="#ffffff" text="#000000" vlink="#0000ff">
<h1> How to make a program against the ticalcs library </h1>
<hr>
<pre>&nbsp;<em>&nbsp;</em></pre>
You will find in the <i>test</i> folder of the library source archive
a test/example program which uses this library.<br>
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:<br>
<br>
<pre>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;glib.h&gt;
#include &lt;ticables.h&gt;
#include &lt;tifiles.h&gt;
#include &lt;ticalcs.h&gt;
      
static void print_lc_error(int errnum)
{
  char *msg;

  ticables_error_get(errnum, &amp;msg);
  fprintf(stderr, "Link cable error (code %i)...\n&lt;&lt;%s&gt;&gt;\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 &amp; cable
  ticalcs_handle_del(calc);
  ticables_handle_del(cable);

  return 0;
}</pre>
That's all !<br><br>
<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.
<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>
or better
<pre>gcc -Os -g -Wall -W `pkg-config --cflags --libs ticalcs2` ticalcs.c -o ticalcs</pre>
<h3><a href="index.html">Return to the main index</a> </h3>
</body>
</html>