Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading data from com port not full #20

Open
GoogleCodeExporter opened this issue Dec 1, 2015 · 0 comments
Open

Reading data from com port not full #20

GoogleCodeExporter opened this issue Dec 1, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant