Skip to content

Instantly share code, notes, and snippets.

@Manawyrm
Created April 12, 2022 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Manawyrm/09487eceeeaa28255eda7d32edf059dd to your computer and use it in GitHub Desktop.
Save Manawyrm/09487eceeeaa28255eda7d32edf059dd to your computer and use it in GitHub Desktop.
PHP script to accompany esp32_spirecovery.ino
<?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