Skip to content

Commit

Permalink
Make the flasher close the serial connection on error
Browse files Browse the repository at this point in the history
  • Loading branch information
loucass003 committed Oct 7, 2023
1 parent 01e6577 commit e4fd25e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/kotlin/Flasher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,21 @@ class Flasher(
// TODO add checks if binaries are overlapping

serialInterface.openSerial(port);
try {
begin();

begin();
if (binsToFlash.isEmpty())
error("No binary added to the flasher")

if (binsToFlash.isEmpty())
error("No binary added to the flasher")
binsToFlash.sortedBy { it.first }.forEach { pair ->
writeBinToFlash(pair.second, pair.first);
}

binsToFlash.sortedBy { it.first }.forEach { pair ->
writeBinToFlash(pair.second, pair.first);
end();
} finally {
serialInterface.closeSerial();
flashing = false;
}

end();

serialInterface.closeSerial();

flashing = false;
}

private fun flashBegin(size: Int, offset: Int) {
Expand Down

0 comments on commit e4fd25e

Please sign in to comment.