Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!extension_loaded("dio")) print "skip";
- // declare variables
- $handle = $reply = null;
- $filename = '/dev/ttyUSB1';
- $handle = dio_open($filename, O_RDWR | O_NOCTTY | O_NONBLOCK);
- //validate file handle
- if ( !is_file($handle) ){
- echo 'The device isn\'t detected';
- }else{ // main code.
- dio_fcntl($handle, F_SETFL, O_SYNC);
- dio_tcsetattr($handle, array(
- 'baud' => 9600,
- 'bits' => 7,
- 'stop' => 1,
- 'parity' => 0));
- if ( dio_write($handle, 'AT') ) {
- echo 'Command is sent';
- $reply = dio_read($handle, 10);
- //echo $reply;
- }else{
- echo 'The device isn\'t read';
- }
- dio_close( $handle );
- }
- die;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement