Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friend,
I am writing following code for send sms via dongle in php but it is not work propery they give com port set error.how can i set port in window to set sms via dongle in php on window OS.
Code:
PHP
<?php


require("php_serial.class.php");


$serial = new phpSerial;

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM13");


// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

// Then we need to open it
$serial->deviceOpen();  



// To write into
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+919428784012\"\n\r");
$serial->sendMessage("Hi, This is the sms that I sent to you using PHP script with serial Port communication with my phone as serial device!! GN - VKSALIAN \n\r");
$serial->sendMessage(chr(26));

//wait for modem to send message
sleep(7);


// Or to read from
$read = $serial->readPort();
echo $read;
// If you want to change the configuration, the device must be closed
$serial->deviceClose();

?>


Result Error:
VB
Warning: Specified serial port is not valid in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 141

Warning: Unable to set the baud rate : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 234

Warning: Unable to set parity : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 288

Warning: Unable to set length of a character : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 336

Warning: Unable to set the length of a stop bit : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 377

Warning: Unable to set flow control mode : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 422

Warning: The device must be set before to be open in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 167

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened to read it in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 522
Posted
Comments
Kornfeld Eliyahu Peter 17-Jan-15 14:23pm    
It is must be very rare that a machine has up to 13 communication ports...Are you sure about COM13?!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900