Debian Codegraph @

examples/serial/bytes.ck

raw
1 // serial IO list
2 SerialIO.list() @=> string list[];
3 // print list
4 for( int i; i < list.size(); i++ )
5 {
6 chout <= i <= ": " <= list[i] <= IO.newline();
7 }
8
9 // serial io
10 SerialIO cereal;
11 // open serial
12 cereal.open( 0, SerialIO.B9600, SerialIO.BINARY );
13
14 // infinite time-loop
15 while( true )
16 {
17 // wait on bytes
18 cereal.onBytes(4) => now;
19 // get bytes
20 cereal.getBytes() @=> int bytes[];
21 // print
22 chout <= "bytes: ";
23 for( int i; i < bytes.size(); i++ )
24 {
25 chout <= bytes[i] <= " ";
26 }
27 // output endline
28 chout <= IO.newline();
29 }