Advertisement
dehqan

Untitled

Nov 10th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. <form action="" method="post" >
  3. <input type=text name=cmd />
  4. <input type="submit" value=" send " name=send />
  5.  
  6. <?php
  7.  
  8. $filename = "/dev/ttyUSB1";
  9.  
  10.  
  11.  
  12. if (!$handle = fopen($filename, 'r+'))
  13.  
  14. {
  15.  
  16. echo "The device isn't detected";
  17.  
  18. exit;
  19.  
  20. }
  21.  
  22. else
  23.  
  24. {
  25.  
  26. if (fwrite($handle, $_POST['cmd']))
  27.  
  28. {
  29. $data = fwrite($handle, $_POST['cmd']);
  30. var_dump( $data );
  31.  
  32. echo "Command is sent";
  33.  
  34. $reply = fread ($handle,4);
  35. echo $reply;
  36.  
  37.  
  38.  
  39. }
  40. else
  41.  
  42. echo "The device isn't read";
  43.  
  44. }
  45.  
  46. fclose($handle);
  47. exit;
  48.  
  49. ?>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement