Page 1 of 1

Serial port modem programming!

Posted: Fri Apr 16, 2004 1:18 pm
by steve2004
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

Posted: Fri Apr 16, 2004 1:27 pm
by PrObLeM
you can talk to modems using php.?!??!?! sweet

Posted: Fri Apr 16, 2004 1:29 pm
by Weirdan
Does your

Code: Select all

//...
 $buffer = fread($fp, 1024);
 echo $buffer; 
 //...
return anything?

Posted: Fri Apr 16, 2004 1:32 pm
by steve2004
no does not return anything

Posted: Fri Apr 16, 2004 1:35 pm
by magicrobotmonkey
Man that's hot! What do you use this script for?

Posted: Fri Apr 16, 2004 1:42 pm
by steve2004
Nothing at the moment but have a few idea's Id like to try for future web developments, like I said in previous posting just can't seem to get back any modem response codes which you need if your going to do anything serious.

Posted: Fri Apr 16, 2004 2:50 pm
by Weirdan
Unfortunately I have no serial port hardware at hand. So, good luck in your quest. =)

Posted: Fri Apr 16, 2004 2:55 pm
by phice
dial numbers, ie: war dialer ;)

Posted: Fri Apr 16, 2004 2:56 pm
by steve2004
Weirdan

thanks anyway.

Best regards
steve

Posted: Fri Apr 16, 2004 3:05 pm
by steve2004
Not looking to use as a cracking tool want to send AT commands direct to modem using fopen in php get back status codes from modem that sort of stuff

Posted: Fri Apr 16, 2004 8:19 pm
by steve2004
still think interesting thread to move on any ideas?