Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:44:04+00:00 2026-05-30T07:44:04+00:00

The following is a library for serial communications via PHP: http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html . The problem

  • 0

The following is a library for serial communications via PHP: http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html. The problem is that the method readPort is not fully implemented. It can read in a *nix environment, but apparently not in a Windows environment. The method:

/**
 * Reads the port until no new datas are availible, then return the content.
 *
 * @pararm int $count number of characters to be read (will stop before
 *  if less characters are in the buffer)
 * @return string
 */
function readPort ($count = 0)
{
    if ($this->_dState !== SERIAL_DEVICE_OPENED)
    {
        trigger_error("Device must be opened to read it", E_USER_WARNING);
        return false;
    }

    if ($this->_os === "linux")
    {
        $content = ""; $i = 0;

        if ($count !== 0)
        {
            do {
                if ($i > $count) $content .= fread($this->_dHandle, ($count - $i));
                else $content .= fread($this->_dHandle, 128);
            } while (($i += 128) === strlen($content));
        }
        else
        {
            do {
                $content .= fread($this->_dHandle, 128);
            } while (($i += 128) === strlen($content));
        }

        return $content;
    }
    elseif ($this->_os === "windows")
    {
        /* Do nohting : not implented yet */
    }

    trigger_error("Reading serial port is not implemented for Windows", E_USER_WARNING);
    return false;
}

The author states:

==> /!\ WARNING /!\ : it’s working with linux for r/w, but with windows i’ve only been able to make write working. If you’re a windows
user, try to access the serial port through network with serproxy
instead.

The limitation of the PHP class library has been mentioned in SO several times already. I haven’t found a decent solution. Reading is imperative for my application.

Does anyone here know what to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:44:05+00:00Added an answer on May 30, 2026 at 7:44 am

    If you can guarantee that you’re on Windows, I might recommend an interesting approach: Use either COM (as in, Microsoft’s COM, not serial port) or .NET.

    There’s a free .NET class that I regularly use called CommStudio Express. I’ve found it to be very reliable, but you can always use the standard SerialPort class built into .NET if you don’t need to worry about a USB-to-serial adapter getting unplugged randomly.

    In any case, it’s easy enough to get at a .NET class in PHP with the DOTNET class:

    $serial = new DOTNET('system', 'System.IO.Ports.SerialPort');
    $serial->PortName = 'COM3';
    $serial->Open();
    

    I haven’t tested this code (not on Windows at the moment), but something like that should work just fine. You can then proceed to use all of the regular .NET methods within PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok guys, I am using the following library: http://www.codeproject.com/KB/recipes/AdvancedMatrixLibrary.aspx And I wish to calculate
Ok, so i've downloaded the following library: http://www.lag.net/paramiko/ and i can't seem to figure
I want to develop a library for communicating with a circuit via serial port.
The following C++ library was successfully compiled in VS2008 http://sourceforge.net/projects/xmlrpcc4win/files/xmlrpcc4win/XmlRpcC4Win1.0.8.zip/download When I open it
I've found following javascript library for client-side validation: http://livevalidation.com/ The examples on the website
I have created the following C library for reading an image: typedef struct {
I have created a static library following this link . But I am facing
I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
Following my question regarding a .NET YAML Library ... as there doesn't seem to
Following this question: Good crash reporting library in c# Is there any library like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.