You have to remove it from comment and place it before opening the com
port. Otherwise cannot set port parameters while port is open!

Also please replace the ticks (') with backticks (`). This is clearly
speciffied in the manual of PHP.

imho the script should look like this:

<?php
$number="+123456789";
$message="Hello World";
$port="com1:";
# Port setup
`mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;

if ($fh=fopen("com1:","w+")) {
/* 'mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off'; */
  fputs($fh,"rATZr");
  sleep(1);
  fputs($fh,"AT+CMGF=1r");
  sleep(1);
  fputs($fh,"AT+CMGS="+{$number}"r");
  sleep(1);
  fputs($fh,"{$message}x1Ar");
  fclose($fh);
  } else {
  echo "Failed to open port.";
  }
?>

Cheers,
Radu

Gabor Hojtsy wrote:

> Could you please open a documentation bug report, so we will not forget 
> about this?

> Thanks,
> Gabor Hojtsy

> Steve Rapaport írta:
> > Hello all!
> > 
> > Greatest respect for PHP, it just keeps performing where other languages 
> > let me down.
> > 
> > Recently searched for a way to communicate on the serial port through 
> > PHP and found
> > the example below  from the fopen() manual page.
> > 
> > |This is great stuff, obviously.   But the com1: option to fopen does not
> > appear anywhere in the documentation.  Also, I'm wondering how Andrew 
> > set the
> > mode on the serial port as he mentions in the comment!
> > 
> > Any help or just a manual addition, much appreciated...
> > Steve|
> > 
> > *andrewra at NOSPAM dot webmail dot co dot za*
> > 12-Jul-2004 03:32
> > |A simple little script to send SMS messages through a GSM phone 
> > connected to a serial communications port (win32). Tested on a Nokia 6310i:
> > 
> > <?php
> > $number="+123456789";
> > $message="Hello World";
> > $port="com1:";
> > 
> > if ($fh=fopen("com1:","w+")) {
> >   /* 'mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off'; */
> >   fputs($fh,"rATZr");
> >   sleep(1);
> >   fputs($fh,"AT+CMGF=1r");
> >   sleep(1);
> >   fputs($fh,"AT+CMGS="+{$number}"r");
> >   sleep(1);
> >   fputs($fh,"{$message}x1Ar");
> >   fclose($fh);
> > } else {
> >   echo "Failed to open port.";
> > }
> > ?>
> > 
> > 
> > |
> > 
> > -- 
> > _________________________________________________
> > 
> > * SEAMLESS DISTRIBUTION   ***www.seamless.se* 
> > <mailto:[EMAIL PROTECTED]>*
> > *  - The electronic solution  *
> > 
> > **
> > 
> > **
> > 
> > *Steve Rapaport -- Key Account Manager
> > *Dalagatan 100, 8 tr, 113 43 Stockholm
> > Phone: +46 (0)8 564 878 00, Fax: +46 (0)8 564 878 23
> > Direct: +46 (0)8 564 878 29, Mobile: +46 70 643 9944
> > E-mail: [EMAIL PROTECTED] 
> > <mailto:[EMAIL PROTECTED]>*
> > 
> > * <mailto:[EMAIL PROTECTED]>** 
> > <mailto:[EMAIL PROTECTED]>
> >

Reply via email to