pid_ioctl()


int/string pid_ioctl ( int $pid, string $req, [ , string $arg, … ] )

Description

pid_ioctl() manipulates the device’s parameters

※ available F/W version : all

Parameters

Return values

Returns an integer or a string on success, PHP error occurs on fail

Example

<?php
$pid = pid_open("/mmap/uart0");      // open UART0
// set the device to 115200bps, no parity, 8 databit, 1stop bit
pid_ioctl($pid, "set baud 115200");
pid_ioctl($pid, "set parity 0");
pid_ioctl($pid, "set data 8");
pid_ioctl($pid, "set stop 1");
pid_ioctl($pid, "set flowctrl 0");

$rbuf = "";
while(1)
{
    $rxlen = pid_ioctl($pid, "get rxlen");  // get received data from the uart0
    if($rxlen >= 8)
    {
        $rlen = pid_read($pid, $rbuf, 8);
        if($rlen > 0 )
        {
            $wlen = pid_write($pid, $rbuf, $rlen);
            echo "$rlen bytes receviced and echoed\r\n";
        }
    }
}
?>

See also

pid_open() / pid_close() / pid_read() / pid_write() / pid_recv() / pid_send()

Remarks

Refer to the device programming guide for more information for each devices.

The pid_ioctl() function supports another function format. The words starting with ‘%’ followed by a number in the string are replaced by parameters. For example, the following two functions are exactly the same.

pid_ioctl($pid, "set baud 115200");

$baudrate_name = "baud";
$baudrate = "115200";
pid_ioctl($pid, "set %1 %2", $baudrate_name, $baudrate);