mesmariusz

serial_php_001

May 16th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set( 'display_errors', 'On' );
  4. error_reporting( E_ALL );
  5.  
  6. include("php_serial.class.php");
  7. $serial = new phpSerial();
  8. $serial->deviceSet("/dev/ttyS0");
  9. $serial->confBaudRate(4800);
  10. $serial->confParity("none");
  11. $serial->confCharacterLength(8);
  12. $serial->confStopBits(1);
  13. $serial->confFlowControl("none");
  14.  
  15. $str = "cd gp1\n\r";
  16. print $str;
  17.  
  18. $serial->deviceOpen();
  19. $serial->sendMessage($str);
  20. $read = $serial->readPort();
  21. print $read;
  22.  
  23. $serial->deviceClose();
  24.  
  25. alamakota;
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment