connorrigby / elixir-fwup Goto Github PK
View Code? Open in Web Editor NEWWrapper around FWUP for Elixir
License: Other
Wrapper around FWUP for Elixir
License: Other
There's a race condition between Erlang processing the exit code and it processing the messages that get sent to it. For example, fwup
can fail and send an error message up. fwup
will exit after it does this, but Erlang may handle the process exit first and lose the error message. That's not helpful.
The fix to this is to pass the --exit-handshake
option to fwup
. If this is done, then after fwup
reports OK
or ER
, it will sent a CTRL+Z character (this part doesn't matter with framing), and then it will call read()
and wait for Erlang to send something back to it. That's the handshake. All Erlang needs to do is send a byte (anything works) back to fwup
after it gets an OK
or ER
. Then fwup
will exit knowing that Erlang safely got the error or success message.
To summarize, the change is:
--exit-handshake
when calling fwup
OK
or ER
After sending the character, it's ok to finish up completely. I don't think there's a need to wait for fwup
to exit since you'll know that the exit code is 0 if the last message is OK
or 1 if ER
. Also, closing the port will also satisfy the handshake from fwup
's point of view.
Another note is that it would be really bad for fwup
to exit without sending an OK
or ER
. That would be a bad bug in fwup if that ever happens, so it's worth adding an ugly log message blaming fwup.
Since fwup can process a file path directly, it would be nice to use that rather than asking users to do something like:
{:ok, fwup} = Fwup.stream(self(), args)
new_firmwmare_path
|> File.stream!([:bytes], 4096)
|> Stream.map(fn chunk ->
Fwup.send_chunk(fwup, chunk)
end)
|> Stream.run()
This should also be faster.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.