Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //error_reporting(-1);
- require "php_serial.class.php";
- // Source: https://github.com/Xowap/PHP-Serial/blob/develop/src/PhpSerial.php
- $serial = new phpSerial;
- $serial->deviceSet("COM4");
- $serial->confBaudRate(9600); // Baud rate: 9600
- $serial->confParity("none"); // Parity (this is the "N" in "8-N-1")
- $serial->confCharacterLength(8); // Character length (this is the "8" in "8-N-1")
- $serial->confStopBits(1); // Stop bits (this is the "1" in "8-N-1")
- $serial->confFlowControl("none"); //
- $serial->deviceOpen(); // Then we need to open it
- $serial->sendMessage("AT+CUSD=1,'*152#',15"); // To write into
- sleep(3); // wait for modem to send message
- $read=$serial->readPort(); // read the response
- $response = $serial->_dHandle;
- echo "Response: ".$response."<br>";
- //echo get_resource_type ( $serial->_dHandle );exit;
- if(is_resource($serial->_dHandle) AND !feof($serial->_dHandle))
- {
- print_r(stream_get_meta_data($serial->_dHandle));
- $stdin = fopen('php://stdin', 'r');
- $res = stream_get_contents($stdin, -1, 10);
- //var_dump(fread($stdin,8));
- var_dump($res);
- //print_r(stream_get_meta_data($stdin));
- }else{
- echo "no response";
- }
- $serial->deviceClose();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement