Shop OBEX P1 Docs P2 Docs Learn Events
Stamp to internet through PHP? — Parallax Forums

Stamp to internet through PHP?

ArchiverArchiver Posts: 46,084
edited 2002-10-05 20:20 in General Discussion
I have Al Williams book and it talks about accessing the stamp
through web pages. This is cool and all but, I'd rather stay away
from VB/VC. I do have (and love) PHP, which I use for online
database stuff. Does anyone know where I can find information about
how to access the serial port though PHP (under windows)? Checked
the PHP manual and searched the web but couldn't find anything about
it - if its even possible...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-10-04 23:22
    My web site contains tutorials and code that makes it easy to monitor bit
    and numbers over time using a RS232 connection. Simply send XML encoded
    data out the serial port once per second. Frontier Data System software
    can capture the data, store it into a database, then search the data to
    deliver dynamic reports to your browser.

    Uses Linux, Apache, MySQL and PHP to provide a 100% open source solution.

    The XML RS232 output looks something like this. The idea is to hard code
    the XML tags and have the data values as variables.

    *<w,0,2>552</w,0,2><w,0,1>37846</w,0,1><w,0,0>32771</w,0,0><n,0,0>3200</n,0,0><n\
    ,0,1>502</n,0,1>$

    The string is sent to the client PC once per second. When the string
    changes records are created.

    Encoding Scheme

    *<Data Type,Station,Element>Value</Data Type,Station,Element>$

    Data Types

    b - Bit bit using 0 or 1
    w - Word encodes 16 bits using integer values between 0 and 65535
    n - Number Number (float)

    Station

    0 to 255

    Element

    Bit 0 to 240
    Word 0 to 15
    Number 0 to 255

    Value

    Bit 0 to 1
    Word 0 to 65535
    Number -3.4E+38 to 3.4E+38

    For the rest of the description check out the online tutorials at
    frontietech.ca.

    ****************************************************************
    www.frontiertech.ca
    Free Open Source Software for Data Aquisition and Data Mining.
    ****************************************************************

    On Fri, 4 Oct 2002, ghidera2000 wrote:

    > I have Al Williams book and it talks about accessing the stamp
    > through web pages. This is cool and all but, I'd rather stay away
    > from VB/VC. I do have (and love) PHP, which I use for online
    > database stuff. Does anyone know where I can find information about
    > how to access the serial port though PHP (under windows)? Checked
    > the PHP manual and searched the web but couldn't find anything about
    > it - if its even possible...
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-04 23:27
    From my understanding of php, it is a scripting language only. You will
    have to write a program in VB/VC and call that.

    Brian G.
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-05 02:27
    --- In basicstamps@y..., Brian Gracia <bgracia@b...> wrote:
    > From my understanding of php, it is a scripting language only.
    You will
    > have to write a program in VB/VC and call that.
    >
    > Brian G.

    Actually its a lot more than that. Its pretty well a full blown
    language.

    Anyway, I found what I was looking for in the annotated docs.

    // Use this code to write directly to the COM1 serial port
    // First, you want to set the mode of the port. You need to set
    // it only once; it will remain the same until you reboot.
    // Note: the backticks on the following line will execute the
    // DOS 'mode' command from within PHP
    `mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
    $fp = fopen ("COM1:", "w+");
    if (!$fp) {
    echo "Uh-oh. Port not opened.";
    } else {
    $e = chr(27);
    $string = $e . "A" . $e . "H300";
    $string .= $e . "V100" . $e . "XL1SATO";
    $string .= $e . "Q1" . $e . "Z";
    echo $string;
    fputs ($fp, $string );
    fclose ($fp);
    }

    Its a lot simpler than I was thinking which is probably why I didn't
    spot it the first time around [noparse]:D[/noparse]
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-05 13:36
    There are several ways you could go (all assuming you are running PHP on
    Windows):

    1) Use the COM functions to talk to a COM control like MSCOMM32. There
    should be some others out there (see http://www.lvr.com).

    2) Use Java. PHP integrates with Java nicely
    (http://www.php.net/manual/en/ref.java.php).

    3) Use fopen() to open serial port.

    4) use dio_open (assuming dio is enabled).

    5) Use a serial proxy: http://www.lspace.nildram.co.uk/freeware.html and
    http://www.trios.org/php/serialport/.

    6) Use Netporter (http://www.al-williams.com/netporter.htm) to handle
    all the communications and generate web pages. You could put it on an
    odd port number and have PHP read the generated pages, modify them, and
    serve them. There are lots of examples around on how to read a Web page
    from PHP and a nice class at:
    http://lwest.free.fr/doc/php/lib/index.php3?page=net_http_client&lang=en

    As you can tell, I like PHP too....


    Al Williams
    AWC
    * NEW: PAK-VIa - Read PS/2 keyboards or mice -- double the buffer, lower
    current consumption.
    http://www.al-williams.com/awce/pak6.htm





    >
    Original Message
    > From: ghidera2000 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=xefYX5ET_v2A4oB-3dDv6PsTJKN8YakmzqKB4ngrKxeeDmxb_GeNoNHYMRwS0HFmmtM5TlADmXf_OdfklPHxYg]ghidera2000@y...[/url
    > Sent: Friday, October 04, 2002 4:45 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]JUNK] [noparse][[/noparse]basicstamps] Stamp to internet through PHP?
    >
    >
    > I have Al Williams book and it talks about accessing the stamp
    > through web pages. This is cool and all but, I'd rather stay away
    > from VB/VC. I do have (and love) PHP, which I use for online
    > database stuff. Does anyone know where I can find information about
    > how to access the serial port though PHP (under windows)? Checked
    > the PHP manual and searched the web but couldn't find anything about
    > it - if its even possible...
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-05 20:13
    Cool, thanks for the links - I'll have to look at them!

    Your book is *BAD* for me... Way too many cool things in there! Just
    had to go out and buy an LCD (LM044L), wasn't planning on it but
    after reading the LCD section of your book, I just *had* to have
    one.

    You're a cruel, cruel man Mr. Williams [noparse]:D[/noparse]

    P.S. I'm constructing a mental block, willfully ignoring the fact
    that there is a robot section in the book. Wonder how long I can
    hold out...


    --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:
    > There are several ways you could go (all assuming you are running
    PHP on
    > Windows):
    >
    > 1) Use the COM functions to talk to a COM control like MSCOMM32.
    There
    > should be some others out there (see http://www.lvr.com).
    >
    > 2) Use Java. PHP integrates with Java nicely
    > (http://www.php.net/manual/en/ref.java.php).
    >
    > 3) Use fopen() to open serial port.
    >
    > 4) use dio_open (assuming dio is enabled).
    >
    > 5) Use a serial proxy:
    http://www.lspace.nildram.co.uk/freeware.html and
    > http://www.trios.org/php/serialport/.
    >
    > 6) Use Netporter (http://www.al-williams.com/netporter.htm) to
    handle
    > all the communications and generate web pages. You could put it on
    an
    > odd port number and have PHP read the generated pages, modify
    them, and
    > serve them. There are lots of examples around on how to read a Web
    page
    > from PHP and a nice class at:
    > http://lwest.free.fr/doc/php/lib/index.php3?
    page=net_http_client&lang=en
    >
    > As you can tell, I like PHP too....
    >
    >
    > Al Williams
    > AWC
    > * NEW: PAK-VIa - Read PS/2 keyboards or mice -- double the buffer,
    lower
    > current consumption.
    > http://www.al-williams.com/awce/pak6.htm
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-05 20:20
    Thanks. You should see the stuff on my to do wish list. So little
    time....

    Cruelly,

    Al Williams
    AWC
    * Floating point A/D
    http://www.al-williams.com/awce/pak9.htm



    >
    > Your book is *BAD* for me... Way too many cool things in there! Just
    > had to go out and buy an LCD (LM044L), wasn't planning on it but
    > after reading the LCD section of your book, I just *had* to have
    > one.
    >
    > You're a cruel, cruel man Mr. Williams [noparse]:D[/noparse]
    >
    > P.S. I'm constructing a mental block, willfully ignoring the fact
    > that there is a robot section in the book. Wonder how long I can
    > hold out...
    >
Sign In or Register to comment.