note 41628 deleted from function.fopen by nlopess

From: Date: Sat, 17 Apr 2004 13:44:08 +0000
Subject: note 41628 deleted from function.fopen by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-68248@lists.php.net to get a copy of this message
Note Submitter: steve2004 ---- Interesting example posted by “jared at dctkc dot com” Serial port programming. I was curious to know whether you could indeed handshake with a modem using the AT command set. 1. Example to dial out ATDT123456789<cr> <? 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 followed by carrage return. $cmdstr = "ATDT123456789".chr(13); #Output AT command to screen. echo "$cmdstr<br>"; fwrite ($fp, $cmdstr); #Added sleep to slow script down to allow dial tone sleep(3); #[WHILE LOOP HERE] fclose ($fp); } Hi presto opened port and dialed number cool… 2. Next example check modem for a response code Command AT<cr> Added while loop to above code #Results back from modem while(!feof($fp)) { $buffer = fread($fp, 1024); echo $buffer; } What should be in the buffer is OK but what really happened was the script just hung around, Had to terminate script this renders the port unusable you then need to reboot the machine to restore. So what went wrong beats me, any ideas?

« previous php.notes (#68248) next »