nabaztag_hack_kit 0.0.2 → 0.0.3
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.
- data/README.md +5 -5
- data/bytecode/main.mtl +1 -1
- data/ext/bytecode/Docs.md +31 -31
- data/lib/nabaztag_hack_kit/message/api.rb +1 -1
- data/lib/nabaztag_hack_kit/message/helper.rb +19 -0
- data/lib/nabaztag_hack_kit/version.rb +1 -1
- metadata +8 -8
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Nabaztag Hack Kit
|
2
2
|
|
3
|
-
Everything you need to hack the Rabbit: a sinatra server including simple api framework to run custom bytecode on Nabaztag v1/v2.
|
3
|
+
Everything you need to hack the Rabbit: a sinatra server including simple api framework to run custom bytecode on Nabaztag v1/v2. Includes original compiler sources for linux.
|
4
4
|
|
5
5
|

|
6
6
|
|
@@ -25,7 +25,7 @@ Runs a `*.mtl` file. It calls `mtl_merge` before, and fallbacks to remote simula
|
|
25
25
|
|
26
26
|
### Understanding the Bytecode
|
27
27
|
|
28
|
-
The bytecode is written in a custom language by Sylvain Huet.
|
28
|
+
The bytecode is written in a custom language by Sylvain Huet. It is referenced as _Metal_ and files end with `.mtl`. Unfortunately documentation is very poor (and in french). Check directory `ext/bytecode/` which contains a basic overview & documentaion as well as a list of (common) commands. A good reference is the original bytecode, included in the directory as well. Major parts got extracted into seperate files, found in `lib/` directory and ready to be included in your code.
|
29
29
|
|
30
30
|
### Testing
|
31
31
|
|
@@ -39,8 +39,8 @@ The kit includes a simple test framework to test custom bytecode. See `test/byte
|
|
39
39
|
0);
|
40
40
|
```
|
41
41
|
|
42
|
-
The framework offers assertions similar to ruby
|
43
|
-
explicit.
|
42
|
+
The framework offers assertions similar to [Ruby Test::Unit](http://ruby-doc.org/stdlib-1.9.3/libdoc/test/unit/rdoc/Test/Unit.html) style. Mind that the variable type has to be given
|
43
|
+
explicit. Convention is:
|
44
44
|
|
45
45
|
* I = interger
|
46
46
|
* S = string
|
@@ -93,7 +93,7 @@ Buffers 10 - 13, where 10 & 11 are used for onetime, and 12 & 13 for loop playba
|
|
93
93
|
|
94
94
|
## Disclamer
|
95
95
|
|
96
|
-
The server
|
96
|
+
The server part was heavily inspired by [Trudy.rb](https://github.com/quimarche/trudy/blob/master/trudy.rb), compiler code copied from OpenJabNab.
|
97
97
|
Thanks!
|
98
98
|
|
99
99
|
|
data/bytecode/main.mtl
CHANGED
data/ext/bytecode/Docs.md
CHANGED
@@ -435,16 +435,15 @@ Random notes of stuff I came accross while developing
|
|
435
435
|
### Leds
|
436
436
|
Thank god it's RGB: Led 0 - 4, Color RGB
|
437
437
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
```
|
438
|
+
led 0 0x000000; //black
|
439
|
+
led 0 0x0000FF; //blue
|
440
|
+
led 0 0x00FF00; //green
|
441
|
+
led 0 0xFF0000; //red
|
442
|
+
led 0 0xFFFF00; //yellow
|
443
|
+
led 0 0xFF00FF; //lila
|
444
|
+
led 0 0x00FFFF; //cyan
|
445
|
+
led 0 0xFFFFFF; //white
|
446
|
+
|
448
447
|
|
449
448
|
### Ears
|
450
449
|
|
@@ -457,32 +456,33 @@ Thank god it's RGB: Led 0 - 4, Color RGB
|
|
457
456
|
`proto main 0;;` needs to be declared on top
|
458
457
|
|
459
458
|
Minimal func:
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
459
|
+
|
460
|
+
|
461
|
+
fun main=
|
462
|
+
confInit;
|
463
|
+
wifiInit 0;
|
464
|
+
loopcb #loop; // 20 p. second
|
465
|
+
|
466
|
+
netstart;
|
467
|
+
srand time_ms;
|
468
|
+
0
|
469
|
+
;;
|
470
|
+
|
471
471
|
|
472
472
|
### Metal Examples
|
473
|
+
|
473
474
|
Example:
|
474
475
|
|
475
|
-
|
476
|
-
|
476
|
+
type MySum= Zero | Const _ | Add _ | Mul _ ;;
|
477
|
+
|
478
|
+
fun eval z=
|
479
|
+
match z with
|
480
|
+
( Zero -> 0)
|
481
|
+
|( Const a -> a)
|
482
|
+
|( Add [x y] -> (eval x)+(eval y))
|
483
|
+
|( Mul [x y] -> (eval x)*(eval y)) ;;
|
477
484
|
|
478
|
-
|
479
|
-
match z with
|
480
|
-
( Zero -> 0)
|
481
|
-
|( Const a -> a)
|
482
|
-
|( Add [x y] -> (eval x)+(eval y))
|
483
|
-
|( Mul [x y] -> (eval x)*(eval y)) ;;
|
485
|
+
Iecholn eval Add [Const 1 Mul [Const 2 Const 3]]; // -> 1 + 2 * 3 -> 7
|
484
486
|
|
485
|
-
Iecholn eval Add [Const 1 Mul [Const 2 Const 3]]; // -> 1 + 2 * 3 -> 7
|
486
|
-
```
|
487
487
|
|
488
488
|
See test for more.
|
@@ -34,6 +34,25 @@ module NabaztagHackKit
|
|
34
34
|
(led3+10) => [0,0,0] + [0,0,0] + data
|
35
35
|
}
|
36
36
|
end
|
37
|
+
|
38
|
+
def stop
|
39
|
+
{
|
40
|
+
LED_0 => 0,
|
41
|
+
LED_1 => 0,
|
42
|
+
LED_2 => 0,
|
43
|
+
LED_3 => 0,
|
44
|
+
LED_4 => 0,
|
45
|
+
LED_L0 => 0,
|
46
|
+
LED_L1 => 0,
|
47
|
+
LED_L2 => 0,
|
48
|
+
LED_L3 => 0,
|
49
|
+
LED_L4 => 0,
|
50
|
+
EAR_L => 0,
|
51
|
+
EAR_R => 0,
|
52
|
+
EAR_LL => 0,
|
53
|
+
EAR_LR => 0,
|
54
|
+
}
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
39
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nabaztag_hack_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70260847353020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70260847353020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70260847352500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70260847352500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70260847376360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70260847376360
|
47
47
|
description: Sinatra server api framework to run custom bytecode on Nabaztag v1/v2.
|
48
48
|
Sources + Compiler included (linux only)
|
49
49
|
email:
|