apalis-imx6, linux armv7 , TorizonCore
IM trying to read the serial data using php function dio_read(). But not getting the data which is sent. dio_write works. Here is my php code
$portName = ‘/dev/apalis-uart2’;
$baudRate = 115200;
$bits = 8;
$spotBit = 1;
$bbSerialPort = dio_open($portName, O_RDWR | O_NOCTTY | O_NONBLOCK );
dio_fcntl($bbSerialPort, F_SETFL, O_SYNC);
//we’re on 'nix configure com from php direct io function
dio_tcsetattr($bbSerialPort, array(
‘baud’ => $baudRate,
‘bits’ => $bits,
‘stop’ => $spotBit,
‘parity’ => 0
));
$dataToSend = “HELLO WORLD!”;
echoFlush( “Writing to serial port data: "{$dataToSend}"” );
$bytesSent = dio_write($bbSerialPort, $dataToSend );
echoFlush( “Sent: {$bytesSent} bytes
” );
$data = dio_read($bbSerialPort, 1); //this is a blocking call
if ($data) {
echoFlush( "Data Recieved: ". $data ."<br>");
}
dio_close($bbSerialPort);
I also tried using the php EXEC command to run thro shell commands
exec(‘stty -F /dev/tty 9600 -echo’, $output, $retval);
echo “
Returned with status $retval and output:\n”;
print_r($output);
unset($output);
exec(‘cat < /dev/tty &’, $output, $retval);
echo “
Returned with status $retval and output:\n”;
print_r($output);
unset($output);
exec(‘echo “Testing UART” > /dev/tty’, $output, $retval);
echo “
Returned with status $retval and output:\n”;
print_r($output);
unset($output);
But works on terminal using the following command
stty -F /dev/ttymxc1 115200 -echo
cat < /dev/ttymxc1 &
echo “Testing UART” > /dev/ttymxc1
Testing UART