prremote 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/VERSION +1 -0
- data/lib/prremote/cli.rb +12 -5
- data/lib/prremote/commands/deploy.rb +1 -0
- data/lib/prremote/commands/install.rb +1 -1
- data/lib/prremote/commands/run.rb +1 -0
- data/lib/prremote/mrbc.rb +39 -6
- data/lib/prremote/version.rb +1 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46762e433d6de80bfe8f614bbdd3ee25fdbf976a235d69b3aecfe2039bd180f8
|
|
4
|
+
data.tar.gz: bcff6b310ed0056d0298a6511cdefe9ffb77aadbcbf0522a379b62d6e3fcc872
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ad10419ea1caafefbdbbeaf803dc80d2a39caf148d0ad545f069661acd46010ba45eecba4c1325235b06d0e43d8cc695bc042e03906d48a820fd6c14b658f53
|
|
7
|
+
data.tar.gz: 40ba90421406056fdde9b2849b46a849bd6d642c00784c14f03b62ce12e09724d343b61d89eb97d6d9a035350f1dbd445b253cefe602a5faacc56698df36ff4c
|
data/README.md
CHANGED
|
@@ -6,15 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
Inspired by [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) for MicroPython.
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
[](https://rubygems.org/gems/prremote)
|
|
11
|
+
[](https://github.com/lumbermill/prremote/actions/workflows/ci.yml)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
[](https://github.com/lumbermill/prremote)
|
|
14
|
+
|
|
9
15
|
---
|
|
10
16
|
|
|
11
17
|
## Requirements
|
|
12
18
|
|
|
13
|
-
- Ruby 3.
|
|
19
|
+
- Ruby 3.4 or later
|
|
14
20
|
- Raspberry Pi Pico W
|
|
15
|
-
- `mrbc`
|
|
21
|
+
- `mrbc` (mruby 4.x) for `run`, `deploy`, and `eval`
|
|
16
22
|
- macOS: `brew install mruby`
|
|
17
|
-
-
|
|
23
|
+
- Linux: build from source — [github.com/mruby/mruby/releases](https://github.com/mruby/mruby/releases)
|
|
24
|
+
(`sudo apt install mruby` installs mruby 3.x which is **not compatible**)
|
|
25
|
+
- If `mrbc` is not on your PATH, set the `MRBC` environment variable:
|
|
26
|
+
`MRBC=/path/to/mrbc prremote run app.rb`
|
|
18
27
|
|
|
19
28
|
---
|
|
20
29
|
|
|
@@ -71,6 +80,8 @@ prremote run blink.rb --port /dev/tty.usbmodem101
|
|
|
71
80
|
|
|
72
81
|
The device responds with `RUNNING`, streams any output, then `DONE`.
|
|
73
82
|
|
|
83
|
+
You can find some examples in [test/samples](test/samples/).
|
|
84
|
+
|
|
74
85
|
---
|
|
75
86
|
|
|
76
87
|
### `deploy FILE`
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.4
|
data/lib/prremote/cli.rb
CHANGED
|
@@ -20,11 +20,13 @@ module Prremote
|
|
|
20
20
|
true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
remove_command :tree
|
|
24
|
+
|
|
23
25
|
desc 'install', 'Flash prremote runtime firmware to Pico W or Pico'
|
|
24
|
-
option :version, type: :string, desc: "Firmware version to install (default: #{
|
|
26
|
+
option :version, type: :string, desc: "Firmware version to install (default: #{VERSION})"
|
|
25
27
|
option :board, type: :string, desc: 'Board type: pico or picow (default: picow)'
|
|
26
28
|
def install
|
|
27
|
-
version = options[:version] ||
|
|
29
|
+
version = options[:version] || VERSION
|
|
28
30
|
board = options[:board] || 'picow'
|
|
29
31
|
unless RuntimeManager::BOARDS.include?(board)
|
|
30
32
|
raise Thor::Error, "Unknown board '#{board}'. Valid values: #{RuntimeManager::BOARDS.join(', ')}"
|
|
@@ -102,14 +104,19 @@ module Prremote
|
|
|
102
104
|
desc 'version', 'Show prremote, mrbc, and device firmware version'
|
|
103
105
|
def version
|
|
104
106
|
puts "prremote: #{VERSION}"
|
|
107
|
+
puts "runtime: #{fetch_runtime_version}"
|
|
105
108
|
|
|
106
109
|
begin
|
|
107
|
-
|
|
110
|
+
major = Mrbc.major_version
|
|
111
|
+
puts "mrbc: #{Mrbc.version} (#{Mrbc.bin})"
|
|
112
|
+
unless major && major >= Mrbc::REQUIRED_MAJOR
|
|
113
|
+
puts " ** mrbc is too old (need #{Mrbc::REQUIRED_MAJOR}.x) **"
|
|
114
|
+
puts " Hint: the path can be set via MRBC environment variable."
|
|
115
|
+
end
|
|
108
116
|
rescue StandardError => e
|
|
109
117
|
puts "mrbc: (#{e.message})"
|
|
110
118
|
end
|
|
111
119
|
|
|
112
|
-
puts "runtime: #{fetch_runtime_version}"
|
|
113
120
|
end
|
|
114
121
|
|
|
115
122
|
private
|
|
@@ -153,7 +160,7 @@ module Prremote
|
|
|
153
160
|
next
|
|
154
161
|
end
|
|
155
162
|
|
|
156
|
-
return ::Regexp.last_match(1) if buf =~ %r{READY prremote-runtime/([\d.]+)}
|
|
163
|
+
return "#{::Regexp.last_match(1)} (#{port})" if buf =~ %r{READY prremote-runtime/([\d.]+)}
|
|
157
164
|
return '(not responding)' if Time.now > deadline
|
|
158
165
|
|
|
159
166
|
sleep 0.05
|
data/lib/prremote/mrbc.rb
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
require 'open3'
|
|
2
2
|
|
|
3
3
|
module Prremote
|
|
4
|
+
# mrbc lookup order:
|
|
5
|
+
# 1. MRBC env var if set (use this to point at a non-PATH binary)
|
|
6
|
+
# 2. PATH entries, excluding rbenv shims — shims delegate to the project's
|
|
7
|
+
# .ruby-version (typically CRuby) and do not work as a standalone mrbc
|
|
8
|
+
# 3. rbenv direct installs (~/.rbenv/versions/mruby-*/bin/mrbc)
|
|
9
|
+
# The first candidate wins; version compatibility is checked in check_version!.
|
|
4
10
|
module Mrbc
|
|
5
11
|
SHIMS_RE = %r{\.rbenv/shims}
|
|
12
|
+
REQUIRED_MAJOR = 4
|
|
6
13
|
|
|
7
14
|
def self.bin
|
|
8
15
|
return ENV['MRBC'] if ENV['MRBC'] && File.executable?(ENV['MRBC'])
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.map { |d| File.join(d, 'mrbc') }
|
|
13
|
-
.find { |f| File.executable?(f) }
|
|
14
|
-
|
|
15
|
-
found || raise('mrbc not found. Install mruby: brew install mruby')
|
|
17
|
+
(path_candidates + rbenv_candidates).first ||
|
|
18
|
+
raise('mrbc not found. Install mruby 4.x: brew install mruby')
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def self.version
|
|
@@ -21,5 +24,35 @@ module Prremote
|
|
|
21
24
|
rescue RuntimeError
|
|
22
25
|
'(mrbc not found)'
|
|
23
26
|
end
|
|
27
|
+
|
|
28
|
+
def self.major_version
|
|
29
|
+
version[/\bmruby (\d+)\./, 1]&.to_i
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.check_version!
|
|
33
|
+
return if @version_ok
|
|
34
|
+
|
|
35
|
+
major = major_version
|
|
36
|
+
unless major && major >= REQUIRED_MAJOR
|
|
37
|
+
raise "mrbc is mruby #{major || '?'}.x but mruby #{REQUIRED_MAJOR}.x or newer is required.\n" \
|
|
38
|
+
"Installed: #{version}\n" \
|
|
39
|
+
"Install mruby 4.x: brew install mruby\n" \
|
|
40
|
+
"On Linux: build from source (https://github.com/mruby/mruby/releases)"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
@version_ok = true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private_class_method def self.path_candidates
|
|
47
|
+
ENV['PATH'].split(File::PATH_SEPARATOR)
|
|
48
|
+
.grep_v(SHIMS_RE)
|
|
49
|
+
.map { |d| File.join(d, 'mrbc') }
|
|
50
|
+
.select { |f| File.executable?(f) }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private_class_method def self.rbenv_candidates
|
|
54
|
+
Dir.glob(File.expand_path('~/.rbenv/versions/mruby-*/bin/mrbc'))
|
|
55
|
+
.select { |f| File.executable?(f) }
|
|
56
|
+
end
|
|
24
57
|
end
|
|
25
58
|
end
|
data/lib/prremote/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prremote
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ITO Yosei
|
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
|
103
103
|
files:
|
|
104
104
|
- LICENSE
|
|
105
105
|
- README.md
|
|
106
|
+
- VERSION
|
|
106
107
|
- bin/prremote
|
|
107
108
|
- lib/prremote.rb
|
|
108
109
|
- lib/prremote/cli.rb
|