mptools 0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/mp-upload +54 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25dab59b2c886231d4e7522328652d4e5b87bca5
4
+ data.tar.gz: 2c1a1c6c3459aa2c670d55331f1a8c105d36484d
5
+ SHA512:
6
+ metadata.gz: 81eac79562fd2bb456a440d889c5d088b6a1b78d8f3b8c2c0942081cb68f6970783b8a804404a28e16c73982819d67f3a92779ab186ff055a326e83c6eb0e85a
7
+ data.tar.gz: 16e20aebdd1dd634e423212250ead79dccf4268224d8f267fcac4679b0ac6aee0df2315471d24e11f0a10542f404579feecb41b2abd6f59bb16f1a12efab8b50
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby
2
+
3
+ ARGV.length!=3&&(puts("USAGE: mp-upload <PORT> <LOCAL FILENAME> <MICROPYTHON FILENAME>");exit(1))
4
+ require 'serialport'
5
+ require 'timeout'
6
+
7
+ port, f_local, f_mc = ARGV
8
+ f_content = File.read(f_local)
9
+
10
+ print "Opening serial port..."
11
+ begin
12
+ s = SerialPort.new(port)
13
+ rescue Errno::ENOENT
14
+ puts "FAIL"
15
+ puts "Could not open serial port to `#{port}`!"
16
+ exit(1)
17
+ end
18
+ puts "ok"
19
+ print "Interrupting program..."
20
+ s.write("\u0003\r\n\r\n")
21
+ ostr = ""
22
+ read_until_off = lambda do
23
+ loop do
24
+ begin
25
+ Timeout.timeout(0.1) do
26
+ ostr << s.read(1)
27
+ end
28
+ rescue Timeout::Error
29
+ break
30
+ end
31
+ end
32
+ end
33
+
34
+ read_until_off.call
35
+
36
+ unless ostr.reverse[0,4].reverse==">>> "
37
+ puts "FAIL"
38
+ puts "It is highly recommended that you plug out your"
39
+ puts "device and plug it back in and try running"
40
+ puts "this script again."
41
+ s.close
42
+ exit(1)
43
+ end
44
+ puts "ok"
45
+ print "Uploading `#{f_local}` as `#{f_mc}`..."
46
+ s.write(%Q(f=open(#{f_mc.inspect},"rw+");f.write(#{f_content.inspect});f.close()\r\n\r\n))
47
+ ostr << s.read(1)
48
+ read_until_off.call
49
+ puts "ok"
50
+ print "Restarting..."
51
+ s.write("\u0004\r\n")
52
+ puts "ok"
53
+ s.close
54
+ puts "All done!"
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mptools
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - sesshomariu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A variety of tools for your Micro Python
14
+ email:
15
+ executables:
16
+ - mp-upload
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/mp-upload
21
+ homepage:
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.6.8
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: MicroPythonTools!
44
+ test_files: []