| 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 device number |
| 10 |
0 => int device; |
| 11 |
if( me.args() ) me.arg(0) => Std.atoi => device; |
| 12 |
|
| 13 |
// serial IO |
| 14 |
SerialIO cereal; |
| 15 |
// open serial |
| 16 |
cereal.open( device, SerialIO.B9600, SerialIO.BINARY ); |
| 17 |
|
| 18 |
// infinite time-loop |
| 19 |
while( true ) |
| 20 |
{ |
| 21 |
// wait for byte |
| 22 |
cereal.onByte() => now; |
| 23 |
// get the byte |
| 24 |
cereal.getByte() => int byte; |
| 25 |
// print |
| 26 |
chout <= "byte: " <= byte <= IO.newline(); |
| 27 |
} |