ThomasWeinert / carica-firmata

Firmata client library for PHP.
52 stars 11 forks source link

Couldn't connect to Arduino #5

Open Curlenius opened 5 years ago

Curlenius commented 5 years ago

Hi,

I'm looking for a way to controlling Arduino from PHP. After several days of trial and failure to send a simple firmata message to Arduino, I finally found Carica Firmata a couple of days ago. But still unable to control my Arduino from PHP.

I want to run a simple sample (like led loop) to test this amazing library.

I compiled and installed StandardFirmata in my Arduino Mega. It seems there is no problem from Arduino as I can test and control my Arduino Mega by a computer app called "Firmata_test".

So I think problem is from PHP side.

I set configuratons like this:

define('CARICA_FIRMATA_MODE', 'serial');
define('CARICA_FIRMATA_SERIAL_DEVICE', '/dev/cu.usbmodem14201');

and then I run the OO blink script:

$board = require(__DIR__.'/bootstrap.php');
Carica\Io\Event\Loop\Factory::run($board->activate());
$board->pins[13]->mode = Carica\Firmata\Pin::MODE_OUTPUT;
while (TRUE) {
  $board->pins[13]->digital = !$board->pins[13]->digital;
  sleep(1);
}

All LEDs on my Arduino Mega immediately start to blink very fast (which I think it's because we are connecting to it), and after one or two seconds all of them stop blinking, only RX blinks for a short time after every 4 seconds or so. No message or error appears on terminal window by running this sample or other samples (like startup.php), only terminal's cursor blinks for ever (and the php app runs forever - which is because of while(true));

Is there any way to make it running or at least shows errors?

Thanks.

Curlenius commented 5 years ago

Hi @ThomasWeinert,

Is this project dead? No support at all?

ThomasWeinert commented 5 years ago

Here are several problems with the current PHP versions (both in Firmata as well in the IO library). I am working on it.

see https://github.com/ThomasWeinert/carica-io/commits/master

But it will take a little time to release a fixed version.

ThomasWeinert commented 5 years ago

Update: Still unfinished but the examples should work again on master with https://github.com/ThomasWeinert/carica-firmata/commit/508b5836bdcb743ab49854fe7672b9fede21a52d

I implemented a new (more robust) board activation that triggers process notifications. Example: https://github.com/ThomasWeinert/carica-firmata/blob/master/examples/startup.php#L25

Curlenius commented 5 years ago

Thank you @ThomasWeinert,

I'm in a trip right now, but I'll check it out in 2/3 days. Thank you again for the amazing work and your time.