Serial port modem programming!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Serial port modem programming!

Post 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
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

you can talk to modems using php.?!??!?! sweet
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Does your

Code: Select all

//...
 $buffer = fread($fp, 1024);
 echo $buffer; 
 //...
return anything?
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post by steve2004 »

no does not return anything
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Man that's hot! What do you use this script for?
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Unfortunately I have no serial port hardware at hand. So, good luck in your quest. =)
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

dial numbers, ie: war dialer ;)
Image Image
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post by steve2004 »

Weirdan

thanks anyway.

Best regards
steve
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post 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
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post by steve2004 »

still think interesting thread to move on any ideas?
Post Reply