Dies ist eine Helferklasse für PHP-Ardeuino-Kommunikation unter Linux
Nach einer Woche mit Googeln und Tests baue ich diese Klasse so auf, dass sie über serielle USB von PHP auf Linux (Master) mit einem Arduino -Board kommuniziert.
Die maximale Länge der Master -Meldung beträgt 60 char (serielle Arduino RX -Puffergrenze), die Antwort (von Arduino) als keine Grenzen. Das ' n' char wird intern als Terminator verwendet. Das Protokoll verwendet CRC8, um die Korrektheit zu gewährleisten. Bei Fehler wird die Nachricht dreimal vor dem Ausgang des Fehlerzustands umgeleitet.
Mit einem Bash -Skript (Serialarduino.sh) wird nach dem Start oder der USB (RE) -Verbindung das USB -Gerät unter Linux eingerichtet. Die serielle Kommunikation ist für jede Nachricht geöffnet: Im Bash -Skript ist die DTR -PIN deaktiviert, um das ARDUINO -Auto -Reset zu vermeiden. (Siehe: https://playground.arduino.cc/main/disablingauToresetonSerialConnection)
FEHLERBEHEBUNG
AUFSTELLEN
Siehe Arduinolinuxserial.php -Datei.
Schlussfolgerungen
Now you can develop MySQL and web enabled Arduino applications only working on Arduino and PHP.
To keep ligth the Arduino Sketch, you can port all not realtime logic to PHP side.
At the end your application will works on MXQ+Arduino UNO even 24/7 with only 20 Watt AC power, and can
be controlled by smartphone via WiFi.
What more?
Enjoy.
Ich bin sehr daran interessiert, Fernsehbähne (wie MXQ) als dedizierte Webserver mit Arduino-Erweiterungen zu verwenden.
Using ArduinoLinuxSerial (https://github.com/msillano/ArduinoLinuxSerial) the Master is php, and you need the
serial driver (uses devices like /dev/ACMx or /dev/USBx). It is blocking the master and the php->Arduino message
is limited to 60 char. Fast and robust (CRC and repetions). Useful with simple and fast Arduino responses.
Using USBphpTunnel (https://github.com/msillano/USBphpTunnel) the master is Arduino, and the Android app uses
ports like /dev/bus/dev/00X/00Y, so you don't need the serial driver. It is blocking the master (arduino) and
it allows big messages. It works in background of the main php program. Useful for data logging and RT.
Using USBphpTunnel_Fifo (https://github.com/msillano/USBphpTunnel_fifo) the master is php. It is NOT blocking the
master, allows payload up to 4k, allows concurrence (many users via WIFI). Works in background, and it is no fast
(depending from polling Arduno frequence, 5-15 sec. plus processing time). Well placed for long Arduino processes
(like waiting user actions).