From: Tobias Krieger on
Hi,

I've recently written an eMail regarding I2C and PHP - since I haven't
found a nice solution yet, I'm considering writting the I2C part
(opening device, writing, reading,...) in C (that's simple) and to
recieve (and returning) the values through PHP and Javascript.

E.g. Website (PHP/Javascript) -> set a new motorspeed -> PHP passes
the new speed to C Application -> C AP opens and writes the new speed
onto the I2C Bus -> Motor executes -> returns ack ->----

Is this somehow, and not complicated possible?

Thanks,

Tobias

From: Nathan Nobbe on
On Sun, Jun 21, 2009 at 3:25 PM, Tobias Krieger <
tobias.krieger(a)teamfrednet.org> wrote:

> Hi,
>
> I've recently written an eMail regarding I2C and PHP - since I haven't
> found a nice solution yet, I'm considering writting the I2C part (opening
> device, writing, reading,...) in C (that's simple) and to recieve (and
> returning) the values through PHP and Javascript.
>
> E.g. Website (PHP/Javascript) -> set a new motorspeed -> PHP passes the new
> speed to C Application -> C AP opens and writes the new speed onto the I2C
> Bus -> Motor executes -> returns ack ->----
>
> Is this somehow, and not complicated possible?


if the C program is written such that it can start and stop on every request
rather than as a daemon, its as simple as shell_exec().

write your C app to take args over the cli and then pass them in through the
call:

<?php
$result = shell_exec('myI2C -speed 50');
?>

something of that nature.

-nathan
From: Tobias Krieger on

Am 21.06.2009 um 23:31 schrieb Nathan Nobbe:

> On Sun, Jun 21, 2009 at 3:25 PM, Tobias Krieger <tobias.krieger(a)teamfrednet.org
> > wrote:
> Hi,
>
> I've recently written an eMail regarding I2C and PHP - since I
> haven't found a nice solution yet, I'm considering writting the I2C
> part (opening device, writing, reading,...) in C (that's simple) and
> to recieve (and returning) the values through PHP and Javascript.
>
> E.g. Website (PHP/Javascript) -> set a new motorspeed -> PHP passes
> the new speed to C Application -> C AP opens and writes the new
> speed onto the I2C Bus -> Motor executes -> returns ack ->----
>
> Is this somehow, and not complicated possible?
>
> if the C program is written such that it can start and stop on every
> request rather than as a daemon, its as simple as shell_exec().
>
> write your C app to take args over the cli and then pass them in
> through the call:
>
> <?php
> $result = shell_exec('myI2C -speed 50');
> ?>
>
> something of that nature.
>
> -nathan
>
This would be a nice and fast solution, but unfortunatelly, it's like
that the C programm needs to surveilance the hardware all the time
(controlling values,...) hence, it would run more as a "daemon".

thx,

tobias
From: Nathan Nobbe on
On Sun, Jun 21, 2009 at 3:44 PM, Tobias Krieger <
tobias.krieger(a)teamfrednet.org> wrote:

> This would be a nice and fast solution, but unfortunatelly, it's like that
> the C programm needs to surveilance the hardware all the time (controlling
> values,...) hence, it would run more as a "daemon".
>

then you will have to make the C app accept socket connections; or maybe try
unix signals handlers in the C app w/ shared memory betwen both processes;
maybe there are easier ways to do it..

-nathan
From: "bruce" on
if memory serves...

you can look into using a shared memory block, or pipes to communicate
between the php/c app....


-----Original Message-----
From: Tobias Krieger [mailto:tobias.krieger(a)teamfrednet.org]
Sent: Sunday, June 21, 2009 2:44 PM
To: Nathan Nobbe
Cc: php-general(a)lists.php.net
Subject: Re: [PHP] Passing Values between C App and PHP



Am 21.06.2009 um 23:31 schrieb Nathan Nobbe:

> On Sun, Jun 21, 2009 at 3:25 PM, Tobias Krieger
<tobias.krieger(a)teamfrednet.org
> > wrote:
> Hi,
>
> I've recently written an eMail regarding I2C and PHP - since I
> haven't found a nice solution yet, I'm considering writting the I2C
> part (opening device, writing, reading,...) in C (that's simple) and
> to recieve (and returning) the values through PHP and Javascript.
>
> E.g. Website (PHP/Javascript) -> set a new motorspeed -> PHP passes
> the new speed to C Application -> C AP opens and writes the new
> speed onto the I2C Bus -> Motor executes -> returns ack ->----
>
> Is this somehow, and not complicated possible?
>
> if the C program is written such that it can start and stop on every
> request rather than as a daemon, its as simple as shell_exec().
>
> write your C app to take args over the cli and then pass them in
> through the call:
>
> <?php
> $result = shell_exec('myI2C -speed 50');
> ?>
>
> something of that nature.
>
> -nathan
>
This would be a nice and fast solution, but unfortunatelly, it's like
that the C programm needs to surveilance the hardware all the time
(controlling values,...) hence, it would run more as a "daemon".

thx,

tobias