Serial Port Problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blaine HIlton

    #1

    Serial Port Problems

    I'm trying to send data over the serial port using PHP and Serproxy.
    I downloaded Serproxy from
    http://www.lspace.nildram.co.uk/freeware.html. From the manual page at
    http://www.php.net/function.fopen I was able to find sample code using
    Serproxy and directly opening the serial port. My application
    requires the use of multiple serial ports on other computers so I'm
    left with only Serproxy.

    The code I am using is"

    $fp = fsockopen ("192.168.0.20" , 5331, $errno, $errstr, 30);
    if (!$fp) {
    echo "$errstr ($errno)";
    } else {
    $e = chr(27);
    $string = 'string text here';
    echo $string;
    fputs ($fp, $string );
    fclose ($fp);
    }


    I am able to run the program fine and I see the connection being
    displayed on the Serproxy display, however then it fills the buffer on
    the RS232 link and the whole string is not transferred over. I
    believe what is missing is some type of code that sets the xon to on.
    For instance using fopens the line is:

    `mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
    $fp = fopen ("COM1:", "w+");

    Is there anyway to turn xon ON using PHP and Serproxy, or another
    solution?

    Another thought that just came to me is in the sample code they put $e
    throughout the string, which is an escape character, perhaps using
    that before the buffer fills up?

    --
    Thanks in advance
    Blaine Hilton
  • Blaine HIlton

    #2
    Re: Serial Port Problems

    Thanks for the idea. I would appreciate it if you could post your
    changes (or email them to me at blaineATblaineh ilton.com). I was
    reading the documentatiion and see that you can turn on or off
    hardware handshaking, but didn't see mention of software handshaking,
    which I require. Also does your version then interface with PHP? I
    didn't see mention of PHP in the docs.

    --
    Thanks again
    Blaine Hilton



    On Mon, 04 Aug 2003 08:08:36 +1200, Jochen Daum
    <jochen.daum@ca ns.co.nz> wrote:
    [color=blue]
    >On Fri, 01 Aug 2003 22:46:03 GMT, Blaine HIlton
    ><blaine.netmas terr@verizon.ne t> wrote:
    >[color=green]
    >>I'm trying to send data over the serial port using PHP and Serproxy.
    >>I downloaded Serproxy from
    >>http://www.lspace.nildram.co.uk/freeware.html. From the manual page at
    >>http://www.php.net/function.fopen I was able to find sample code using
    >>Serproxy and directly opening the serial port. My application
    >>requires the use of multiple serial ports on other computers so I'm
    >>left with only Serproxy.[/color]
    >
    >Hmm. I spent a lot of time with serproxy and fopen in the last two
    >weeks and I'm greatly dissappointed. I couldn't manage to let it run
    >in the background (which might be a lack of unix skills), but the main
    >problem were the php socket functions. They don't seem to be very
    >reliable (also have a look at bug reports) and there seems to be no
    >function, that polls the serial port and doesn't hang, if there's no
    >data. Ergo, you're buggered.
    >
    >Instead I stripped down SMSTools
    >
    >http://www.isis.de/members/~s.frings/
    >
    >to a tool that sends only an AT command to the serial port with a
    >timeout. That worked much better. I can post it to you, if you want.
    >
    >HTH, Jochen[/color]

    Comment

    • Jochen Daum

      #3
      Re: Serial Port Problems

      Hi Blaine!

      On Sun, 03 Aug 2003 22:20:20 GMT, Blaine HIlton
      <blaine.netmast err@verizon.net > wrote:
      [color=blue]
      >Thanks for the idea. I would appreciate it if you could post your
      >changes (or email them to me at blaineATblaineh ilton.com). I was
      >reading the documentatiion and see that you can turn on or off
      >hardware handshaking, but didn't see mention of software handshaking,
      >which I require. Also does your version then interface with PHP? I
      >didn't see mention of PHP in the docs.[/color]

      I just call the program I build with shell_exec(), works fine. I'll
      send the zip to you and anyone who's interested.

      Jochen

      --
      Jochen Daum - CANS Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      http://sourceforge.net/projects/phpdbedittk/

      Comment

      • byteworks
        New Member
        • Apr 2006
        • 1

        #4
        PHP serial extension

        Comment

        Working...