serial port - php fopen works only first time
Get the solution ↓↓↓I'm writing on rs232 /dev/ttyUSB0 on debian but it will work only first or two time
This is my code
$fp = fopen('/dev/ttyUSB0', 'r+');
stream_set_blocking($fp,1);
fwrite($fp, $output);
// Set timeout to 500 ms
$timeout=microtime(true)+0.5;
// Set non blocking mode for reading
stream_set_blocking($fp,0);
do{
// Try to read one character from the device
$c=fgetc($fp);
// Wait for data to arive
if($c === false){
usleep(50000);
continue;
}
$line.=$c;
}while($c!="\n" && microtime(true)<$timeout);
fclose($fp);
I have also tried to set fopen on w+ with same result
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.