Minipush: Fix error in displaying number of pushed KiB

pull/44/head
Andre Richter 4 years ago
parent 0a609aa1a0
commit 37b4d8d51e
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -36,7 +36,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 7856 KiB =======================================🦀 100% 0 KiB/s Time: 00:00:00
[MP] ⏩ Pushing 7 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now
[0] Booting on: Raspberry Pi 3

@ -23,7 +23,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 13152 KiB ======================================🦀 100% 0 KiB/s Time: 00:00:00
[MP] ⏩ Pushing 12 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now
[ 0.585762] Booting on: Raspberry Pi 3

@ -164,7 +164,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 8232 KiB =======================================🦀 100% 0 KiB/s Time: 00:00:00
[MP] ⏩ Pushing 8 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now
[ 0.372110] Parking CPU core. Please connect over JTAG now.

@ -202,7 +202,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 15824 KiB ======================================🦀 100% 0 KiB/s Time: 00:00:00
[MP] ⏩ Pushing 15 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now
[ 0.702482] Booting on: Raspberry Pi 3

@ -256,7 +256,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 65568 KiB =====================================🦀 100% 32 KiB/s Time: 00:00:02
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now
[ 2.932547] Booting on: Raspberry Pi 3

@ -405,7 +405,7 @@ Minipush 1.0
Raspberry Pi 3
[ML] Requesting binary
[MP] ⏩ Pushing 65568 KiB =====================================🦀 100% 32 KiB/s Time: 00:00:02
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now
[ 2.913260] Booting on: Raspberry Pi 3

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 203 KiB

@ -170,6 +170,15 @@ class DevTool
clean
end
def ready_for_publish_no_rust
clean
misspell
rubocop
copyright
diff
clean
end
private
def tutorials

@ -12,6 +12,7 @@ require 'colorize'
require 'ruby-progressbar'
require 'serialport'
require 'timeout'
require_relative 'minipush/progressbar_patch'
class ConnectionError < StandardError; end
class ProtocolError < StandardError; end
@ -85,7 +86,7 @@ class MiniPush
def send_binary
pb = ProgressBar.create(
total: @binary_size,
format: '[MP] ⏩ Pushing %c KiB %b🦀%i %p%% %r KiB/s %a',
format: '[MP] ⏩ Pushing %k KiB %b🦀%i %p%% %r KiB/s %a',
rate_scale: ->(rate) { rate / 1024 },
length: 92
)

@ -0,0 +1,29 @@
# frozen_string_literal: true
# SPDX-License-Identifier: MIT OR Apache-2.0
#
# Copyright (c) 2020 Andre Richter <andre.o.richter@gmail.com>
# Monkey-patch ruby-progressbar so that it supports reporting the progress in KiB instead of Byte.
class ProgressBar
# Add kibi version of progress
class Progress
def progress_kibi
@progress / 1024
end
end
module Format
# Add new formatting option
class Molecule
MOLECULES_EXTENDED = MOLECULES.dup
MOLECULES_EXTENDED[:k] = %i[progressable progress_kibi]
def initialize(letter)
self.key = letter
self.method_name = MOLECULES_EXTENDED.fetch(key.to_sym)
end
end
end
end
Loading…
Cancel
Save