pid_open()


int pid_open ( string $path [ , int $flags ] )

Description

pid_open() opens the specified file/port/peripheral

※ available F/W version : all

Parameters

Return values

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)
{
    // read upto 10 bytes from the $pid into $rbuf
    $rlen = pid_read($pid, $rbuf, 10);
    // write $rlen bytes of the $rbuf to the $pid   
    if($rlen > 0) $wlen = pid_write($pid, $rbuf, $rlen); 
}

pid_close($pid);
?>

See also

pid_close() / pid_ioctl() / pid_read() / pid_write() / pid_recv() / pid_send() / pid_connect()

Remarks

Refer to the product’s manual for the paths for each product.