Coder Social home page Coder Social logo

php-serial's People

Watchers

 avatar

php-serial's Issues

Windows : must specify all com port settings with one command

What steps will reproduce the problem?

1. Call multiple "confxxx" functions in script
2. Run script on command line
3. run "mode COM1" on command line


What is the expected output? What do you see instead?
I'm doing this

$baud_rate = 9600;
$serial->confBaudRate($baud_rate); 
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("rts/cts");

However, I found out only last call takes effect, and verified on command line 
that when calling mode, it only puts into effect flags specified with that 
command, all other settings put back to default.

I had too collect the settings and specify them with single mode command "mode 
COM1 BAUD=96 parity=n stop=1 data=8 xon=off octs=on rts=hs"

You wouldnt notice this if your default settings where what you wanted.  I only 
noticed because for some reason it kept defaulting to even parity and 7 data 
bits.

What version of the product are you using? On what operating system?
Latest from svn read only, Win7 64 bit

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 20 Apr 2011 at 9:05

stty --version check fails with Busybox

The test for stty is not working if we use Busybox. That one doesn't have a 
--version parameter. The solution is to check if the program is available 
without directly calling it. The following patch is working for me:

<pre>
--- php_serial.class.php.orig
+++ php_serial.class.php
@@ -49,7 +49,7 @@
        {
            $this->_os = "linux";

-           if($this->_exec("stty --version") === 0)
+           if($this->_exec("which stty", $output) === 0)
            {
                register_shutdown_function(array($this, "deviceClose"));
            }
</pre>

Original issue reported on code.google.com by [email protected] on 4 Oct 2012 at 11:36

php-serial is to read/write local PC serial port ?

Hi,

I am new in PHP. Understand that php is server script coding running on host 
server.

If i want to read and write data to local PC (not server) serial port, can this 
php-serial support ?

Thanks.

Regards
Gilbert

Original issue reported on code.google.com by [email protected] on 15 Sep 2011 at 7:58

missing data reading port

What steps will reproduce the problem?
1. connect serial port to insteon PLM
2. send PLM data from another script
3. sometimes retrieve incomplete data when watching serial port with following 
code:
require('php_serial.class.php');
$serial = new phpSerial();
$serial->deviceSet("/dev/ttyS0");
$serial->confBaudRate(19200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
do{
    $line = $serial->readPort();
    if($line){
        //unpack() gives me an array.  Then because it's hex, I need to typecast
        //it to string, otherwise I'll have a very big number!
        $hex = (string)join("", unpack("H*", $line));
        do{
            $match = 0;

            $pattern = '/^0262([0-9A-F]{6})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})06/i';
            if(preg_match($pattern, $hex, $matches)){
                $hex = preg_replace($pattern, "", $hex);
                print "PLM ACK'd SD command ${matches[3]} ${matches[4]} sent to ${matches[1]}\n";
                $match = 1;
            }

            $pattern = '/^0250([0-9A-F]{6})([0-9A-F]{6})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})/i';
            if(preg_match($pattern, $hex, $matches)){
                $hex = preg_replace($pattern, "", $hex);
                print "PLM received SD sent from: ${matches[1]} -> ${matches[2]}; Flag: ${matches[3]} Commands: ${matches[4]} ${matches[5]}\n";
                $match = 1;
            }
        }while($match);
        if($hex){
            print "Line: $hex\n";
        }
    }
    sleep(1);
}while(1);

What is the expected output? What do you see instead?
Expect the following two lines repeated as often as I send data:
PLM ACK'd SD command 13 00 sent to 111111
PLM received SD sent from: 111111 -> aaaaaa; Flag: 21 Commands: 13 00

Get (randomly) missing data:
PLM ACK'd SD command 13 00 sent to 111111
PLM received SD sent from: 111111 -> aaaaaa; Flag: 21 Commands: 13 00
PLM ACK'd SD command 13 00 sent to 111111
PLM ACK'd SD command 13 00 sent to 111111
PLM ACK'd SD command 13 00 sent to 111111
PLM received SD sent from: 111111 -> aaaaaa; Flag: 21 Commands: 13 00


What version of the product are you using? On what operating system?
latest source from this repository.
ClearOS 5.1 - 2.6.18-164.11.1.v5PAE #1 SMP

Please provide any additional information below.
Reading the serial port has improved; I first found an earlier version of this 
class, which was even more sporadic.  This version is much better, but still 
missing data.  I am confident the data should be there, but this class isn't 
capturing it from the port.  Perhaps my logic above is bad; I'd love it to be 
that easy!

Original issue reported on code.google.com by [email protected] on 14 Jun 2010 at 5:38

sms newline on Linux

On linux the \n\r will not execute the command on my modem. It is expecting to 
receive a carriage return that is not given in this way. Haven't tested it on 
Windows yet. Instead I replaced the \n\r with a chr(13) and that made it work.

\n\r result:

hans@debian:~/phpserial/trunk# php sms-example.php 
string(2) "AT"
string(25) "AT+CMGF=1

NO CARRIER

chr(13) result:

hans@debian:~/phpserial/trunk# php sms-example.php 
string(9) "AT
OK
"
string(16) "AT+CMGF=1
OK

Original issue reported on code.google.com by [email protected] on 26 Jan 2014 at 11:19

port not open

What steps will reproduce the problem?

Warning: Unable to open the device in 
D:\xampp\htdocs\sh\comp\php_serial.class.php on line 188

Warning: Device must be opened in D:\xampp\htdocs\sh\comp\php_serial.class.php 
on line 588

Warning: Device must be opened in D:\xampp\htdocs\sh\comp\php_serial.class.php 
on line 588

Warning: Device must be opened in D:\xampp\htdocs\sh\comp\php_serial.class.php 
on line 588

Warning: Device must be opened in D:\xampp\htdocs\sh\comp\php_serial.class.php 
on line 588

Warning: Device must be opened in D:\xampp\htdocs\sh\comp\php_serial.class.php 
on line 588

Warning: Device must be opened to read it in 
D:\xampp\htdocs\sh\comp\php_serial.class.php on line 511


What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Jan 2015 at 9:29

dtr and rts

Hi, how can I set dtr and rts after opening a serial port? I am using OSX. Many 
Thanks.

Original issue reported on code.google.com by [email protected] on 18 Nov 2011 at 5:29

Windows Unable to open the device in C:\xampp\htdocs\php_serial.class.php on line 186

What steps will reproduce the problem?
1. run xampp on windows
2. select COM13 (or com port you want)
3. run it with this script below.

<?php
include "php_serial.class.php";

echo "<html>
      <head><title>Test MySQL</title></head>
      <body>";


// Let's start the class
$serial = new phpSerial;

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM13");

$serial->confBaudRate(9600);

// Then we need to open it
$serial->deviceOpen();

// To write into
$serial->sendMessage("Hello !");

// Or to read from
$read = $serial->readPort();

echo "here it is";
echo $read;
echo "here it was";


sleep(1);

// If you want to change the configuration, the device must be closed
$serial->deviceClose();



// We can change the baud rate
//$serial->confBaudRate(2400);

// etc...
?>
</body></html>




Original issue reported on code.google.com by [email protected] on 3 Jan 2012 at 10:53

Was using your scripts and was having trouble connecting my Arduino

What steps will reproduce the problem?
1. Ubuntu
2. /dev/ttyACM0
3. not knowing how to script very well or at all in php

What is the expected output? What do you see instead?
Serial output from Arduino, tested in Ubuntu with serial monitor from the 
Arduino development software that runs on Java. 

What version of the product are you using? On what operating system?
Ubuntu 11.10 32-bit

Please provide any additional information below.

Serial port used is /dev/ttyACM0. I modified the class from /dev/ttyS to 
/dev/ttyS and also all the ttyS to ttyACM, to no avail.

Original issue reported on code.google.com by [email protected] on 4 Jan 2012 at 8:33

ttyACM* devices not supported...

What steps will reproduce the problem?
 1. Create a symbolic link to /dev/ttyACMx (or modify php-serial source to use /dev/ttyACMx) 
 2. Use new phpSerial, deviceSet("COMx"), deviceOpen('w+'), stream_set_timeout($serial->_dHandle, 10)... as required.
 3. Use sendMessage(... more than once to see garbled data out.

What version of the product are you using? On what operating system?

 * r12 on Linux

Please provide any additional information below.

 * I'm suggesting the addition of new function (see attachment)
  * The function could be better. Eg. OS detection

Original issue reported on code.google.com by [email protected] on 28 Feb 2012 at 11:23

Attachments:

Permiso denegado

What steps will reproduce the problem?

this is the output 

cmd stty --version
ret: stty (GNU coreutils) 8.12 Copyright (C) 2011 Free Software Foundation, 
Inc. Licencia GPLv3+: GPL de GNU versión 3 o posterior . Esto es software 
libre: usted es libre de cambiarlo y redistribuirlo. No hay NINGUNA GARANTÍA, 
hasta donde permite la ley. Escrito por David MacKenzie.
err:
cmd stty -F /dev/ttyS0
ret:
err: stty: /dev/ttyS0: Permiso denegado 

Original issue reported on code.google.com by [email protected] on 5 Oct 2012 at 11:01

Windows Read Serial Support

Hi,

I have got windows to read from my serial port using the following code in
place of the 'not implemented' comment:

------
        elseif ($this->_os === "windows")
        {
            $content = "";

            if ($count > 0)
            {
                $content = fread($this->_dHandle, $count);
            }

            return $content;
        }
-----

System: Vista 32bit with a Prolific USB to serial adapter cable.

I hope that it is of some help.

Cheers,

David

Original issue reported on code.google.com by [email protected] on 30 Dec 2009 at 8:47

how to store each raw data received from $serial->readPort()

Now, I am able to send and receive data serially from arduino to raspberry pi 
and vice versa. 
one more thing I notice is.
I am sending  [Carriage Return(CR) character(0x0D)] [LineFeed(LF) 
character(0x0A)] after the string as shown in attached pic(serialrawdata.png),
but it shows [0x0A][0x0A] in serialphp as shown in pic(phpoutput.png)

I am facing another problem.
I am sending raw data from arduino to raspberry pi.
all regular char ( A to Z , a to z , 0 to 9 ) can be received normally in $read 
= $serial->readPort();
problem is when arduino sends 0x7F , one char is being deleted from $read.
I need to store each raw data.
how to solve this problem..?

Original issue reported on code.google.com by [email protected] on 13 Mar 2013 at 5:00

Attachments:

50$ Serial characters arrive gibbrish

What steps will reproduce the problem?
1. $serial->confBaudRate(600); - lowest baudrate set to check
2. $serial->sendMessage("ABCDEFGHI");
3.

What is the expected output? What do you see instead?
I see on my terminal:
ABÃDÅÆGH 

What version of the product are you using? On what operating system?
Win7 64, apache2.4, php5.2

Please provide any additional information below.

I have tried different COM ports and different baudrates - all resulting in 
random character mismatch,
although there are always about 50% of correct characters, in the correct order.
So that is not total garbage i am receiving, however what could be the cause of 
the mismatch characters ?!
Thanks !

Original issue reported on code.google.com by [email protected] on 21 Sep 2013 at 9:43

Attachments:

Reading data from com port not full

Tested on Gentoo Linux, Centos linux
I have gprs modem works via ftdi....

0. connects
$serial = new phpSerial;
$serial->deviceSet("ttyUSB0");
$serial->confBaudRate(115200);
$serial->deviceOpen();
$recieved_sms=pdu_read_recieved_sms();
$serial->deviceClose();

1. echo at+cmgl=4 > /dev/ttyUSB0  && cat /dev/ttyUSB0
 if i reapeat this cmd, data loads full! this is fine
2. if i load data from php ver 5.5.10
function pdu_read_recieved_sms($waitForReply = 0.1){
    global $serial; $read='';
    $serial->sendMessage("AT+CMGL=4".PHP_EOL,$waitForReply);
// Wait and read from the port
//sleep(2);
$read .= $serial->readPort();
print $read;
if(!empty($read)){
    preg_match_all("/07[A-Z0-9]*/i", $read,$matches);
    if(is_array($matches) && sizeof($matches)>0){
        return $matches[0];
    }else{ 
        return false;
        }
    }else{ 
        return false;
    }
}
3. if i read
$timeout=microtime(true)+10;
do{ 
$c=fread($this->_dHandle,128);
$content.=$c;
}while(microtime(true)<$timeout);

full data reads in 80 percents

may be script issue?
please help to fix this problem

Original issue reported on code.google.com by [email protected] on 26 Mar 2014 at 1:27

Attachments:

Not receiving all character correctly

Hi,

I'm just testing this class as I need to transmit and receive data from a LED 
controller. But for now, I'm doing test with a null-modem cable plugged to COM7 
and COM8, via USB-to-serial adapter.
I'm trying some simple transmission but notice that all characters are note 
received well. Some needs to be uppercase, the other lowercase.
Here is the "good" spelling for having good transmission:
ABcDefGHijKlMNoPqrStUVwxYZ
If I send "a" instead of "A", I receive a "á". All "non-working" characters 
are with accents.
I check the receiving string with a Tera Term terminal connected on COM7, and 
my php script is connected on COM8.
All the transmission are good when using 2 terminals (1 on COM7, 1 on COM8), 
but not with the script

What steps will reproduce the problem?
1. using the example.php, just replace $serial->sendMessage("Hello !"); with 
$serial->sendMessage("Bazinga!");

What is the expected output? What do you see instead?
Expected result : Bazinga!
see instead: Báúiîçá!

What version of the product are you using? On what operating system?
Last version from SVN read only, on Win7 x64, with PHP 5.3.13

Please provide any additional information below.
Got the same result while using PHP-Cli, so Apache not involved

Thanks :)

Original issue reported on code.google.com by [email protected] on 6 Nov 2012 at 8:36

I cannot load the class and write

I am new to php. I just have an html class that has a post method which calls a 
php file called match.php. In the php file I include the class as follows

include "php_serial.class.php";

Then when I try to start the class by writing the follows I get an error

$serial = new phpSerial;

The error is as follows

Server error
The website encountered an error while retrieving http://localhost/match.php. 
It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered 
while the server was attempting to fulfill the request.

Original issue reported on code.google.com by [email protected] on 10 Feb 2013 at 3:10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.