123456789101112131415 |
- <?php
- $fd = dio_open("/dev/ttyACM0", O_RDWR | O_NONBLOCK | O_NOCTTY);
- // first read after initial power up:
- $first = dio_read($fd, 1024);
- // send an 'R', then read again
- dio_write($fd, "R" . PHP_EOL);
- sleep(1);
- $second = dio_read($fd, 1024);
- dio_close($fd);
- var_dump(strlen($first), $first, PHP_EOL, "hello", strlen($second), $second);
|