Esta é uma classe auxiliar para comunicações Php-Ardeino no Linux
Após uma semana de Google e testes, construo essa classe para me comunicar do PHP em execução no Linux (Master) a uma placa Arduino via serial USB.
O comprimento máximo da mensagem mestre é 60 char (serial Arduino RX Buffer Limit), a resposta (de Arduino) como sem limites. O char ' n' é usado internamente como terminador. O protocolo usa o CRC8 para garantir a correção. Em caso de erro, a mensagem é rendida 3 vezes antes da saída no estado de erro.
Um script bash (serialarduino.sh) é usado para configurar o dispositivo USB no Linux, após a conexão Startup ou USB (re). A comunicação serial está aberta para cada mensagem: no script Bash, o pino DTR está desativado para evitar a redefinição automática do Arduino. (Veja: https://playground.ardeino.cc/main/disablingautoretonserialConnection)
SOLUÇÃO DE PROBLEMAS
CONFIGURAR
Consulte Arquivo ArduinolinuxSerial.php.
Conclusões
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.
Estou muito interessado em usar caixas de TV (como o MXQ) como servidores da Web dedicados com extensões Arduino: SOBRE SOBRE (Linux + Android) -Duino Comunicação serial USB I Testei muitas soluções:
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).