| 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 |
// device number |
| 10 |
0 => int device; |
| 11 |
if( me.args() ) me.arg(0) => Std.atoi => device; |
| 12 |
// serial io |
| 13 |
SerialIO cereal; |
| 14 |
// open serial device |
| 15 |
cereal.open( device, SerialIO.B9600, SerialIO.ASCII ); |
| 16 |
|
| 17 |
// infinite time-loop |
| 18 |
while( true ) |
| 19 |
{ |
| 20 |
// wait on event |
| 21 |
cereal.onInts(2) => now; |
| 22 |
// get ints |
| 23 |
cereal.getInts() @=> int ints[]; |
| 24 |
// print |
| 25 |
chout <= "ints: "; |
| 26 |
for( int i; i < ints.size(); i++ ) |
| 27 |
{ |
| 28 |
chout <= ints[i] <= " "; |
| 29 |
} |
| 30 |
chout <= IO.newline(); |
| 31 |
} |