File: ints-bin.ck

package info (click to toggle)
chuck 1.5.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 40,904 kB
  • sloc: cpp: 120,943; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 456; python: 174; perl: 86
file content (27 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (4)
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
// serial IO list
SerialIO.list() @=> string list[];
// print list
for( int i; i < list.size(); i++ )
{
    chout <= i <= ": " <= list[i] <= IO.newline();
}

// device number
0 => int device;
if( me.args() ) me.arg(0) => Std.atoi => device;
// serial io
SerialIO cereal;
// open serial device
cereal.open( device, SerialIO.B9600, SerialIO.BINARY );

// infinite time-loop
while( true )
{
    // wait on event
    cereal.onInts(1) => now;
    // get int
    cereal.getInts() @=> int i[];
    // print
    if( i.size() > 0 )
        chout <= "int: " <= i[0] <= "\n";
}