PHP script to accompany esp32_spirecovery.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("vendor/autoload.php"); | |
use lepiaf\SerialPort\SerialPort; | |
use lepiaf\SerialPort\Parser\SeparatorParser; | |
use lepiaf\SerialPort\Configure\TTYConfigure; | |
$bios = fopen("bios.bin", "r"); | |
$configure = new TTYConfigure(); | |
$configure->removeOption("9600"); | |
$configure->setOption("115200"); | |
$block = 0; | |
$serialPort = new SerialPort(new SeparatorParser(), $configure); | |
$serialPort->open("/dev/ttyUSB0"); | |
while (true) | |
{ | |
$data = $serialPort->read(); | |
echo $data."\n"; | |
if ($data === "W") { | |
echo "write block " . $block . "\n"; | |
$block++; | |
$data = fread($bios, 4096); | |
if ($data === false) | |
{ | |
echo "done!\n"; | |
exit(); | |
} | |
$serialPort->write($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment