sphero_pwn 0.0.0 → 0.0.1

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/sphero_diagnostics.rb +71 -0
  4. data/bin/sphero_map_flash.rb +82 -0
  5. data/bin/sphero_save_flash_block.rb +47 -0
  6. data/bin/sphero_set_flag.rb +38 -0
  7. data/bin/sphero_soft_reboot.rb +33 -0
  8. data/bin/sphero_toggle_user_hack.rb +36 -0
  9. data/lib/sphero_pwn.rb +24 -14
  10. data/lib/sphero_pwn/asyncs/flash_block.rb +26 -0
  11. data/lib/sphero_pwn/channel.rb +72 -29
  12. data/lib/sphero_pwn/commands/boot_main_app.rb +17 -0
  13. data/lib/sphero_pwn/commands/enter_bootloader.rb +15 -0
  14. data/lib/sphero_pwn/commands/get_device_mode.rb +35 -0
  15. data/lib/sphero_pwn/commands/get_flash_block.rb +34 -0
  16. data/lib/sphero_pwn/commands/get_permanent_flags.rb +44 -0
  17. data/lib/sphero_pwn/commands/get_versions.rb +12 -10
  18. data/lib/sphero_pwn/commands/is_page_blank.rb +36 -0
  19. data/lib/sphero_pwn/commands/l1_diagnostics.rb +0 -1
  20. data/lib/sphero_pwn/commands/l2_diagnostics.rb +50 -0
  21. data/lib/sphero_pwn/commands/set_device_mode.rb +25 -0
  22. data/lib/sphero_pwn/commands/set_permanent_flags.rb +29 -0
  23. data/lib/sphero_pwn/session.rb +12 -4
  24. data/sphero_pwn.gemspec +130 -0
  25. data/test/command_test.rb +10 -0
  26. data/test/commands/boot_main_app_test.rb +11 -0
  27. data/test/commands/enter_bootloader_test.rb +33 -0
  28. data/test/commands/get_device_mode_test.rb +40 -0
  29. data/test/commands/get_flash_block_test.rb +101 -0
  30. data/test/commands/get_permanent_flags_test.rb +48 -0
  31. data/test/commands/get_versions_test.rb +10 -1
  32. data/test/commands/is_page_blank_test.rb +65 -0
  33. data/test/commands/l2_diagnostics_test.rb +58 -0
  34. data/test/commands/set_device_mode_test.rb +56 -0
  35. data/test/commands/set_permanent_flags_test.rb +55 -0
  36. data/test/data/enter_bootloader.txt +4 -0
  37. data/test/data/get_device_mode.txt +2 -0
  38. data/test/data/get_factory_config.txt +2 -0
  39. data/test/data/get_permanent_flags.txt +2 -0
  40. data/test/data/get_soul.txt +2 -0
  41. data/test/data/get_version.txt +2 -2
  42. data/test/data/is_page_blank.txt +6 -0
  43. data/test/data/l2_diagnostics.txt +8 -0
  44. data/test/data/ping.txt +2 -2
  45. data/test/data/set_device_mode.txt +12 -0
  46. data/test/data/set_permanent_flags.txt +8 -0
  47. metadata +44 -3
@@ -0,0 +1,55 @@
1
+ require_relative '../helper.rb'
2
+
3
+ describe SpheroPwn::Commands::SetPermanentFlags do
4
+ it 'stringifies correctly' do
5
+ set_flags = SpheroPwn::Commands::SetPermanentFlags.new(
6
+ no_sleep_while_charging: false, vector_drive: true,
7
+ tail_led_always_on: true, motion_timeouts: true,
8
+ light_double_tap: true, heavy_double_tap: false,
9
+ gyro_max_async: true)
10
+ sequence = 0x52
11
+
12
+ assert_equal [0xFF, 0xFF, 0x02, 0x35, 0x52, 0x05, 0x00, 0x00, 0x01, 0x5A,
13
+ 0x16], set_flags.to_bytes(sequence).unpack('C*')
14
+ end
15
+
16
+ describe 'when sent to the robot' do
17
+ before do
18
+ @session = new_test_session :set_permanent_flags
19
+ @session.send_command SpheroPwn::Commands::GetPermanentFlags.new
20
+ response = @session.recv_until_response
21
+ unless response.code == :ok
22
+ raise RuntimeError, 'Could not get original permanent flags'
23
+ end
24
+ @old_flags = response.flags
25
+ end
26
+ after do
27
+ @session.send_command(
28
+ SpheroPwn::Commands::SetPermanentFlags.new(@old_flags))
29
+ response = @session.recv_until_response
30
+ unless response.code == :ok
31
+ raise RuntimeError, 'Could not restore original permanent flags'
32
+ end
33
+
34
+ @session.close
35
+ end
36
+
37
+ it 'changes the result of the get permanent flags command' do
38
+ new_flags = @old_flags.dup
39
+ new_flags[:vector_drive] = !new_flags[:vector_drive]
40
+
41
+ @session.send_command(
42
+ SpheroPwn::Commands::SetPermanentFlags.new(new_flags))
43
+ response = @session.recv_until_response
44
+ assert_kind_of SpheroPwn::Commands::SetPermanentFlags::Response,
45
+ response
46
+ assert_equal :ok, response.code
47
+
48
+ @session.send_command SpheroPwn::Commands::GetPermanentFlags.new
49
+ response = @session.recv_until_response
50
+ assert_equal :ok, response.code
51
+ assert_equal new_flags, response.flags
52
+ refute_equal @old_flags, response.flags
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,4 @@
1
+ > FF FF 00 30 01 01 CD
2
+ < FF FF 00 01 01 FD
3
+ > FF FF 01 04 02 01 F7
4
+ < FF FF 00 02 01 FC
@@ -0,0 +1,2 @@
1
+ > FF FF 02 44 01 01 B7
2
+ < FF FF 00 01 02 00 FC
@@ -0,0 +1,2 @@
1
+ > FF FF 02 40 01 02 00 BA
2
+ < FF FF 00 01 01 FD FF FE 04 04 01 D3 00 BC 02 8A 02 00 00 00 00 05 00 A6 D2 EC 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 02 00 00 00 00 00 00 9A 99 19 3F 04 00 00 00 00 00 B4 42 CD CC 4C 3D 00 00 96 44 00 00 F0 41 CD CC 4C 3E 00 00 48 42 00 00 A8 41 9A 99 99 3E 00 00 48 42 48 47 E0 3F 4F 5B FD BF 04 39 46 3F 4F 02 7A 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 11 28 7B 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 09 78 7B 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 57 F6 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D A6 04 7B 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 57 7D 7B 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D 23 DB 79 3D AE 07 FF 7F FF 7F FF 7F FF 7F FF 7F A6 07 FF 7F FF 7F FF 7F FF 7F FF 7F A2 07 FF 7F FF 7F FF 7F FF 7F FF 7F 51 F8 00 80 00 80 00 80 00 80 00 80 5A F8 00 80 00 80 00 80 00 80 00 80 5D F8 00 80 00 80 00 80 00 80 00 80 ED FA 7F 3F 8D 2C F4 BB 25 5A 72 BB 74 82 11 3C 3C FB 7F 3F 3C 52 D8 39 FE 3F 73 3B 51 B6 ED B9 DE FE 7F 3F 55 65 84 3B D8 6D 06 BC E8 4A A9 B9 55 F0 80 3B 9D F8 45 38 1C A6 C7 B7 A3 B8 99 B8 81 23 81 3B 19 5C 4E 37 86 1B 95 B8 97 64 53 37 51 39 81 3B 3B F2 99 3C 20 EA E4 BB 3F 11 35 BD 01 00 00 00 66 02 00 00 9B 02 00 00 02 00 00 00 D7 02 00 00 01 00 00 00 E3 64 A4 3F 7A 51 03 40 8B 2D 05 40 B2 CB E3 3F 92 A7 D9 3F 63 FD 62 40 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 0C 00 00 00 06 00 01 36 38 38 36 65 37 30 36 31 32 33 34 00 00 00 00 00 01 00 00 00 00 11 A5 3C E2 E5 98 3B FF 07 02 00 03 00 01 00 01 00 00 53 70 68 65 72 6F 2D 59 52 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 42 54 3A 20 30 38 4A 75 6C 32 30 31 35 20 20 00 00 00 06 03 0D 00 00 00 64 00 42 75 69 6C 64 20 31 33 30 38 31 32 41 20 49 44 50 53 00 00 00 00 00 00 00 00 14 00 00 00 02 00 00 00 00 00 03 0F 1E 00 00 00 00 80 BB 44 05 0F 00 00 00 00 20 40 00 00 A0 42 00 00 00 00 00 00 00 00 9A 99 19 BF 4B FE 84 43 00 00 00 00 9A 99 69 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 55 74 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 0F 54 07 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF 83
@@ -0,0 +1,2 @@
1
+ > FF FF 02 36 01 01 C5
2
+ < FF FF 00 01 05 00 00 00 12 E7
@@ -0,0 +1,2 @@
1
+ > FF FF 02 46 01 01 B5
2
+ < FF FF 00 01 01 FD FF FE 0D 04 01 04 00 40 00 BF 02 00 00 E4 06 00 00 00 01 00 04 00 08 00 00 04 00 03 00 00 00 00 00 00 00 00 00 03 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 24 00 20 00 00 00 00 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A5 A5 14 00 64 00 90 01 C8 00 C8 00 C8 00 C8 00 C8 00 C8 00 80 81 82 83 84 85 86 87 FD 84 03 25 FF 00 1E FF 14 00 00 00 00 64 0B 00 64 14 00 00 00 00 64 0B 00 64 14 AD AD AD 00 64 0B 00 64 1F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C8 00 2C 01 98 08 9A 09 D0 07 B3 02 03 05 07 0A 0D 12 00 00 6E 8B A8 C5 E2 FF 00 00 5A 66 73 8C B3 E6 00 00 03 00 05 00 08 00 0D 00 12 00 18 00 00 00 00 00 01 01 02 03 03 00 00 00 01 01 01 01 01 01 02 02 02 02 02 02 02 03 03 03 03 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 96 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22
@@ -1,2 +1,2 @@
1
- > ff ff 00 02 01 01 fb
2
- < ff ff 00 01 09 01 03 01 00 00 33 00 00 bd
1
+ > FF FF 00 02 01 01 FB
2
+ < FF FF 00 01 09 01 03 01 00 00 33 00 00 BD
@@ -0,0 +1,6 @@
1
+ > FF FF 00 30 01 01 CD
2
+ < FF FF 00 01 01 FD
3
+ > FF FF 01 05 02 02 10 E5
4
+ < FF FF 00 02 02 00 FB
5
+ > FF FF 01 04 03 01 F6
6
+ < FF FF 00 03 01 FB
@@ -0,0 +1,8 @@
1
+ > FF FF 02 44 01 01 B7
2
+ < FF FF 00 01 02 01 FB
3
+ > FF FF 02 42 02 02 01 B6
4
+ < FF FF 00 02 01 FC
5
+ > FF FF 00 41 03 01 BA
6
+ < FF FF 04 03 01 F7
7
+ > FF FF 02 42 04 02 01 B4
8
+ < FF FF 00 04 01 FA
@@ -1,2 +1,2 @@
1
- > ff ff 00 01 01 01 fc
2
- < ff ff 00 01 01 fd
1
+ > FF FF 00 01 01 01 FC
2
+ < FF FF 00 01 01 FD
@@ -0,0 +1,12 @@
1
+ > FF FF 02 44 01 01 B7
2
+ < FF FF 00 01 02 00 FC
3
+ > FF FF 02 42 02 02 00 B7
4
+ < FF FF 00 02 01 FC
5
+ > FF FF 02 44 03 01 B5
6
+ < FF FF 00 03 02 00 FA
7
+ > FF FF 02 42 04 02 01 B4
8
+ < FF FF 00 04 01 FA
9
+ > FF FF 02 44 05 01 B3
10
+ < FF FF 00 05 02 01 F7
11
+ > FF FF 02 42 06 02 00 B3
12
+ < FF FF 00 06 01 F8
@@ -0,0 +1,8 @@
1
+ > FF FF 02 36 01 01 C5
2
+ < FF FF 00 01 05 00 00 00 12 E7
3
+ > FF FF 02 35 02 05 00 00 00 10 B1
4
+ < FF FF 00 02 01 FC
5
+ > FF FF 02 36 03 01 C3
6
+ < FF FF 00 03 05 00 00 00 10 E7
7
+ > FF FF 02 35 04 05 00 00 00 12 AD
8
+ < FF FF 00 04 01 FA
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sphero_pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-12 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyserial
@@ -112,7 +112,13 @@ description: |-
112
112
  This library is currently focused on reverse-engineering
113
113
  the undocumented parts of Sphero
114
114
  email: victor@costan.us
115
- executables: []
115
+ executables:
116
+ - sphero_diagnostics.rb
117
+ - sphero_map_flash.rb
118
+ - sphero_save_flash_block.rb
119
+ - sphero_set_flag.rb
120
+ - sphero_soft_reboot.rb
121
+ - sphero_toggle_user_hack.rb
116
122
  extensions: []
117
123
  extra_rdoc_files:
118
124
  - LICENSE.txt
@@ -126,29 +132,64 @@ files:
126
132
  - README.markdown
127
133
  - Rakefile
128
134
  - VERSION
135
+ - bin/sphero_diagnostics.rb
136
+ - bin/sphero_map_flash.rb
137
+ - bin/sphero_save_flash_block.rb
138
+ - bin/sphero_set_flag.rb
139
+ - bin/sphero_soft_reboot.rb
140
+ - bin/sphero_toggle_user_hack.rb
129
141
  - lib/sphero_pwn.rb
130
142
  - lib/sphero_pwn/async.rb
131
143
  - lib/sphero_pwn/asyncs.rb
144
+ - lib/sphero_pwn/asyncs/flash_block.rb
132
145
  - lib/sphero_pwn/asyncs/l1_diagnostics.rb
133
146
  - lib/sphero_pwn/channel.rb
134
147
  - lib/sphero_pwn/channel_recorder.rb
135
148
  - lib/sphero_pwn/command.rb
136
149
  - lib/sphero_pwn/commands.rb
150
+ - lib/sphero_pwn/commands/boot_main_app.rb
151
+ - lib/sphero_pwn/commands/enter_bootloader.rb
152
+ - lib/sphero_pwn/commands/get_device_mode.rb
153
+ - lib/sphero_pwn/commands/get_flash_block.rb
154
+ - lib/sphero_pwn/commands/get_permanent_flags.rb
137
155
  - lib/sphero_pwn/commands/get_versions.rb
156
+ - lib/sphero_pwn/commands/is_page_blank.rb
138
157
  - lib/sphero_pwn/commands/l1_diagnostics.rb
158
+ - lib/sphero_pwn/commands/l2_diagnostics.rb
139
159
  - lib/sphero_pwn/commands/ping.rb
160
+ - lib/sphero_pwn/commands/set_device_mode.rb
161
+ - lib/sphero_pwn/commands/set_permanent_flags.rb
140
162
  - lib/sphero_pwn/replay_channel.rb
141
163
  - lib/sphero_pwn/response.rb
142
164
  - lib/sphero_pwn/session.rb
143
165
  - lib/sphero_pwn/test_channel.rb
166
+ - sphero_pwn.gemspec
144
167
  - test/channel_recorder_test.rb
145
168
  - test/command_test.rb
169
+ - test/commands/boot_main_app_test.rb
170
+ - test/commands/enter_bootloader_test.rb
171
+ - test/commands/get_device_mode_test.rb
172
+ - test/commands/get_flash_block_test.rb
173
+ - test/commands/get_permanent_flags_test.rb
146
174
  - test/commands/get_versions_test.rb
175
+ - test/commands/is_page_blank_test.rb
147
176
  - test/commands/l1_diagnostics_test.rb
177
+ - test/commands/l2_diagnostics_test.rb
148
178
  - test/commands/ping_test.rb
179
+ - test/commands/set_device_mode_test.rb
180
+ - test/commands/set_permanent_flags_test.rb
181
+ - test/data/enter_bootloader.txt
182
+ - test/data/get_device_mode.txt
183
+ - test/data/get_factory_config.txt
184
+ - test/data/get_permanent_flags.txt
185
+ - test/data/get_soul.txt
149
186
  - test/data/get_version.txt
187
+ - test/data/is_page_blank.txt
150
188
  - test/data/l1_diagnostics.txt
189
+ - test/data/l2_diagnostics.txt
151
190
  - test/data/ping.txt
191
+ - test/data/set_device_mode.txt
192
+ - test/data/set_permanent_flags.txt
152
193
  - test/helper.rb
153
194
  - test/replay_channel_test.rb
154
195
  - test/response_test.rb