Advertisement
dehqan

Untitled

Nov 10th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2.  
  3. // declare variables
  4. $handle = $reply = null;
  5. $filename = '/dev/ttyUSB1';
  6. $handle = @fopen($filename, 'r+');
  7.  
  8. // validate file handle
  9. if ( !is_file($handle) ){
  10. echo 'The device isn\'t detected';
  11.  
  12. }else{ // main code.
  13.  
  14. if ( fwrite($handle, 'AT') ) {
  15. echo 'Command is sent';
  16. $reply = fread($filename, 4);
  17. echo $reply;
  18. exit;
  19.  
  20. }else{
  21. echo 'The device isn\'t read';
  22. }
  23.  
  24. fclose( $handle );
  25. }
  26.  
  27. die;
  28.  
  29. ?>
  30.  
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement