Serial port modem programming!
Posted: Fri Apr 16, 2004 1:18 pm
Hi just wondering if any one has any sample scripts/URLs or can help!, trying to send AT commands to modem on com3. Can send AT commands OK and dial numbers but just can't get back a modem response code any ideas how?.
Sample code:
<?
`mode com3: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
$fp = fopen ("COM3:", "w+");
if (!$fp) {
echo "Port not opened.";
} else {
//AT command here
$cmdstr = "AT".chr(13);
echo "$cmdstr<br>";
//write to com port 3 or what ever modem on
fwrite ($fp, $cmdstr);
//Delay
sleep(3);
//When using this goes on for ever the leaves port open needs
//reboot to restore
#while(!feof($fp)) {
#$buffer = fread($fp, 1024);
#echo $buffer;
#}
//Close com port
fclose ($fp);
}
best regards
steve
Sample code:
<?
`mode com3: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
$fp = fopen ("COM3:", "w+");
if (!$fp) {
echo "Port not opened.";
} else {
//AT command here
$cmdstr = "AT".chr(13);
echo "$cmdstr<br>";
//write to com port 3 or what ever modem on
fwrite ($fp, $cmdstr);
//Delay
sleep(3);
//When using this goes on for ever the leaves port open needs
//reboot to restore
#while(!feof($fp)) {
#$buffer = fread($fp, 1024);
#echo $buffer;
#}
//Close com port
fclose ($fp);
}
best regards
steve