Program not exiting flash function after successfully uploading hex file
See original GitHub issueDescription
I use macOS Catalina and was looking for an easy way to flash games on my Arduboy and came across your (awesome!) library. I’d like to use it to develop a new app to manage my game library, which is a bunch of hex files.
As a start, I installed the NPM package in a folder and added this index.js
which I adapted from your README:
var Avrgirl = require('avrgirl-arduino');
var avrgirl = new Avrgirl({
board: 'leonardo',
debug: true
});
avrgirl.flash('pong.hex', function (error) {
if (error) {
console.error(error);
} else {
console.info('done.');
}
});
The hex file is attached as a zip, just because lol. While the script successfully flashes the hex file, the node program does not quit. This is the output I see in my console:
marcussanatan@Marcuss-MacBook-Pro arduboy-upload % node index.js
resetting board...
found port on /dev/tty.usbmodem14201
reset complete.
connected
flashing, please wait...
flash complete.
done.
^C
marcussanatan@Marcuss-MacBook-Pro arduboy-upload %
Note the ^C
as I have to manually interrupt the program to get back to my shell. The “done” messaged was logged to the screen, further confirmation that the flashing did not encounter an error. However, it seems as though the script is “stuck” in the callback.
I was curious if this occurred in earlier versions. I deleted node_modules
and package-lock.json
and installed version 4.2.1. When I ran my script again, it just works:
marcussanatan@Marcuss-MacBook-Pro arduboy-upload % node index.js
resetting board...
found port on /dev/tty.usbmodem14201
reset complete.
connected
flashing, please wait...
flash complete.
done.
marcussanatan@Marcuss-MacBook-Pro arduboy-upload %
I’ll try to deep dive when I have more time this week, but I took a look at the differences between 4.2.1 and 4.2.2. Most of it involves web serial updates except for d2287d87bbc6ba94040e4330a52cc867f684bf53 which is a patch for issue #193. Time permitting I’ll confirm in the next couple of days but it feels like the culprit.
Expected behaviour
I expected the Node.js program to quit after the hex file was flashed
Actual behaviour
The Node.js program is blocked when I call the flash()
function.
Operating system and version
Linux and Unix based systems
Darwin Marcuss-MacBook-Pro.local 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
Haven’t confirmed on other OSes.
Avrgirl Arduino version
avrgirl-arduino@4.2.2
NodeJS version
v13.3.0
Arduino Board being used
Arduboy (leonardo)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@msanatan thank you so much for your kind words about this project, despite it being a little bit buggy for you 😅
I would love any PRs in general even if they’re not related to this problem. I just moved house last week so I’m still trying to get back on top of my open source work 📦
I should be able to get to this issue in particular pretty soon 🤞
Hi @msanatan, Thanks for flagging this, as I was interested in whether or not this is something that affects how people use the library for their projects.
Just for history, this library has always had this bug until 4.2.1 as you were able to track down, as you mentioned due to #193. Given that this bug is still going to be a thing going forward for certain operating systems, I need to work in a more sophisticated fix. In the meantime, I would recommend just using v 4.2.1 for now especially if everything else in that version is working as expected.
Stay tuned for a proper fix soon, likely in a version 4.2.3?
BTW it’s really cool to see that you’re using this for the Arduboy! I love that board a lot and am happy to hear that people are still using it. It’s always kinda needed an easy ROM loader, so I’m glad you worked on a solution that works for you 😄
Thanks again for your kind words and generosity towards this project! 💯