nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -2
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -2
  5. data/CHANGELOG.md +17 -2
  6. data/LICENSE +21 -0
  7. data/README.md +115 -44
  8. data/Rakefile +2 -6
  9. data/bytecode/{Commands.md → _docs/commands.md} +0 -0
  10. data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
  11. data/bytecode/_docs/grammar.pdf +0 -0
  12. data/bytecode/{src → _original}/README.md +0 -0
  13. data/bytecode/{src → _original}/lib/arp.mtl +0 -0
  14. data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
  15. data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
  16. data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
  17. data/bytecode/{src → _original}/lib/dns.mtl +0 -0
  18. data/bytecode/{src → _original}/lib/http.mtl +0 -0
  19. data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
  20. data/bytecode/{src → _original}/lib/udp.mtl +0 -0
  21. data/bytecode/{src → _original}/lib/util.mtl +0 -0
  22. data/bytecode/{src → _original}/lib/var.mtl +0 -0
  23. data/bytecode/{src → _original}/lib/wav.mtl +0 -0
  24. data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
  25. data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
  26. data/bytecode/main.mtl +11 -11
  27. data/bytecode/test/test.mtl +8 -8
  28. data/examples/basic/Gemfile +1 -3
  29. data/examples/basic/config.ru +14 -4
  30. data/examples/record/Gemfile +0 -5
  31. data/examples/record/{config.ru.example → config.ru} +2 -2
  32. data/examples/record/server.rb +0 -2
  33. data/ext/Makefile +10 -0
  34. data/ext/bin/mtl_comp +29 -0
  35. data/{bytecode → ext}/bin/mtl_merge +0 -0
  36. data/ext/bin/mtl_simu +29 -0
  37. data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
  38. data/ext/mtl_linux/.gitignore +7 -0
  39. data/ext/mtl_linux/LICENSE +21 -0
  40. data/ext/mtl_linux/Makefile +116 -0
  41. data/ext/mtl_linux/MetalC.project +196 -0
  42. data/ext/mtl_linux/conf.bin +0 -0
  43. data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
  44. data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
  45. data/ext/mtl_linux/inc/log.h +21 -0
  46. data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
  47. data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
  48. data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
  49. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
  50. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
  51. data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
  52. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
  53. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
  54. data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
  55. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
  56. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
  57. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
  58. data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
  59. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
  60. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
  61. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
  62. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
  63. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
  64. data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
  65. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
  66. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
  67. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
  68. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
  69. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
  70. data/ext/mtl_linux/nominal.mtl +3959 -0
  71. data/ext/mtl_linux/src/comp/main.cpp +123 -0
  72. data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
  73. data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
  74. data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
  75. data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
  76. data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
  77. data/ext/mtl_linux/src/simu/log.c +340 -0
  78. data/ext/mtl_linux/src/simu/properties.c +368 -0
  79. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
  80. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
  81. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
  82. data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
  83. data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
  84. data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
  85. data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
  86. data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
  87. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
  88. data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
  89. data/ext/mtl_linux/src/simu/win/simu.c +819 -0
  90. data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
  91. data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
  92. data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
  93. data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
  94. data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
  95. data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
  96. data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
  97. data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
  98. data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
  99. data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
  100. data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
  101. data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
  102. data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
  103. data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
  104. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
  105. data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
  106. data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
  107. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
  108. data/ext/mtl_linux/src/vm/vaudio.c +830 -0
  109. data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
  110. data/ext/mtl_linux/src/vm/vloader.c +139 -0
  111. data/ext/mtl_linux/src/vm/vlog.c +782 -0
  112. data/ext/mtl_linux/src/vm/vmem.c +461 -0
  113. data/ext/mtl_linux/src/vm/vnet.c +298 -0
  114. data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
  115. data/lib/nabaztag_hack_kit/server.rb +4 -7
  116. data/lib/nabaztag_hack_kit/version.rb +1 -1
  117. data/lib/nabaztag_hack_kit.rb +2 -2
  118. data/nabaztag_hack_kit.gemspec +10 -11
  119. data/spec/integration/server_spec.rb +3 -3
  120. data/spec/spec_helper.rb +2 -0
  121. data/spec/unit/message_spec.rb +12 -18
  122. data/spec/unit/server_spec.rb +13 -10
  123. metadata +145 -137
  124. data/bytecode/bin/mtl_comp +0 -50
  125. data/bytecode/bin/mtl_simu +0 -49
  126. data/bytecode/src/mtl/Makefile +0 -42
  127. data/bytecode/src/mtl/README.md +0 -13
  128. data/bytecode/src/mtl/bc.cpp +0 -1891
  129. data/bytecode/src/mtl/dumpbc.c +0 -2566
  130. data/bytecode/src/mtl/linux_simu.c +0 -271
  131. data/bytecode/src/mtl/linux_simuaudio.c +0 -16
  132. data/bytecode/src/mtl/linux_simunet.c +0 -620
  133. data/bytecode/src/mtl/log.c +0 -297
  134. data/bytecode/src/mtl/log.h +0 -20
  135. data/bytecode/src/mtl/main_compiler.cpp +0 -104
  136. data/bytecode/src/mtl/main_simu.cpp +0 -221
  137. data/bytecode/src/mtl/mp3/common.c +0 -265
  138. data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
  139. data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
  140. data/bytecode/src/mtl/mp3/huffman.h +0 -332
  141. data/bytecode/src/mtl/mp3/interface.c +0 -258
  142. data/bytecode/src/mtl/mp3/mpglib.h +0 -44
  143. data/bytecode/src/mtl/properties.c +0 -293
  144. data/bytecode/src/mtl/simu.c +0 -750
  145. data/bytecode/src/mtl/simuaudio.c +0 -662
  146. data/bytecode/src/mtl/simunet.c +0 -400
  147. data/bytecode/src/mtl/vaudio.c +0 -677
  148. data/bytecode/src/mtl/vbc_str.h +0 -166
  149. data/bytecode/src/mtl/vcomp/Makefile +0 -29
  150. data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
  151. data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
  152. data/bytecode/src/mtl/vcomp/compiler.h +0 -200
  153. data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
  154. data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
  155. data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
  156. data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
  157. data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
  158. data/bytecode/src/mtl/vcomp/file.cpp +0 -79
  159. data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
  160. data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
  161. data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
  162. data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
  163. data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
  164. data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
  165. data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
  166. data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
  167. data/bytecode/src/mtl/vinterp.c +0 -1349
  168. data/bytecode/src/mtl/vloader.c +0 -127
  169. data/bytecode/src/mtl/vlog.c +0 -589
  170. data/bytecode/src/mtl/vmem.c +0 -424
  171. data/bytecode/src/mtl/vnet.c +0 -255
  172. data/examples/basic/Procfile +0 -2
  173. data/examples/basic/server.rb +0 -14
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd395348ad5c455b3587202f9fbf9782259cf829
4
+ data.tar.gz: e23d930933234912c081a5425003577a0db51fd2
5
+ SHA512:
6
+ metadata.gz: 896a8d1f950033dfa49494747a982a3c58fa4ac92565e44725effbaecdce2c39ac46b73a12a8975eeab9f0c7f34df1550577e69705cdcbdc8c43eb953e6643be
7
+ data.tar.gz: 14abe18bd4b1502a7682aa5b5c24c579dfc51b36bcdc3d3bd290bd500407fb80fa686bfc47d4ee8d2beb2631b725d7b6af039c7b75e9bcf47a970721eb023c19
data/.gitignore CHANGED
@@ -5,5 +5,10 @@ pkg/*
5
5
  .rvmrc
6
6
  *.bin
7
7
  *.o
8
- examples/record/config.ru
9
- .mtlrc
8
+ .mtlrc
9
+ examples/*/vendor/
10
+ compiler/osx/mtl_comp
11
+ compiler/osx/mtl_simu
12
+ vendor/bundle
13
+ compiler/osx/vcomp
14
+ dumpbc.c
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "ext/mtl_linux"]
2
+ path = ext/mtl_linux
3
+ url = https://github.com/rngtng/mtl_linux.git
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  rvm:
2
- - 1.9.2
3
- script: "bundle exec rake spec"
2
+ - 2.2.2
3
+ script: "bundle exec rspec"
data/CHANGELOG.md CHANGED
@@ -1,10 +1,25 @@
1
1
  # Changes
2
2
 
3
+ ## v0.2.1 - 18-09-2016
4
+
5
+ * pulled in mac os x support by @ztalbot2000 28-06-2014
6
+ * fixed all compile warnings
7
+ * Added -m32 compile option
8
+ * fixed segfault when running mtl_comp with invalid args
9
+ * Changed output so size is CAPITAL hex value to make absolutely no
10
+ differences when comparing compiled .mtl file and original bc.jsp file
11
+
12
+ ## v0.1.1 - 17-09-2016
13
+
14
+ * file cleanup fix spelling
15
+ * update readme on how to use/run examples
16
+ * proper usage of bundler
17
+
3
18
  ## v0.1.0 - xx-09-2012
4
19
 
5
- * files restructured, speration byte & ruby code
20
+ * files restructured, separation byte & ruby code
6
21
  * update server for generic structure, added callback
7
- * mtl binaires respect defaults from local `.mtlrc` file
22
+ * mtl binaries respect defaults from local `.mtlrc` file
8
23
 
9
24
  ## v0.0.2 - 29-01-2012
10
25
 
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tobias Bielohlawek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,53 +1,112 @@
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. Includes original compiler sources for linux.
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 and a modified mac os x version.
4
4
 
5
- ![](http://travis-ci.org/rngtng/NabaztagHackKit.png)
5
+ ![](http://github.com/rngtng/NabaztagHackKit.png)
6
6
 
7
7
  ## Getting Started
8
8
 
9
- ### Compile & Run
9
+ ### Installation
10
10
 
11
- The kit comes with violet sources and binaries to compile custom Nabaztag bytecode. On a linux machine those binaries are compiled on instalation of the gem. Following three binaries are available:
11
+ The Hack Kit is distributed as a ruby gem. It comes with a simple web server (based on sinatra) which runs out-of-the for connecting you rabbit and distributing the nabaztag bytecode. In addition it includes sinatra helpers/modules to communicate with the rabbit easily. Lastly it provides binaries to compile your own Nabaztag bytecode (see **Binaries** below).
12
12
 
13
- #### mtl_merge
13
+ ### Simple Server
14
14
 
15
- Merges multiple `*.mtl` files into one. Files are included like in C: `#include "<relative path to file>"`. Output is temporary file `.tmp.mtl`.
15
+ The Server is the communication endpoint for the rabbit. Its two main purposes are:
16
+
17
+ 1. serving the bytecode on bootup
18
+ 2. receive and respond to HTTP requests in a defined format.
19
+
20
+ ### Setup
21
+
22
+ 1. Install dependencies first:
23
+
24
+ ```
25
+ gem install nabaztag_hack_kit
26
+ ```
27
+
28
+ or if you have a `Gemfile`
29
+
30
+ ```
31
+ bundle install --path=vendor/bundle
32
+ ```
33
+
34
+ 2. Then, create a `config.ru` file
35
+
36
+ ```ruby
37
+ require 'nabaztag_hack_kit/server'
38
+
39
+ run NabaztagHackKit::Server.new
40
+ ```
41
+
42
+ 3. Finally, to start and run the server, execute:
43
+
44
+ ```
45
+ bundle exec rackup -p <portnumer>
46
+ ```
47
+
48
+ See `examples/` folder for more sophisticated usage.
49
+
50
+ ### Binaries
51
+
52
+ The kit comes with violet sources and binaries to compile custom Nabaztag bytecode. See folder `compiler/`. The linux sources are (more or less) the original ones by violet, the mac osx version was created by @ztalbot2000.
53
+ The compiler binaries are compiled on installation of the gem.
54
+
55
+ Following three binaries are available:
16
56
 
17
57
  #### mtl_comp
18
58
 
19
- Compiles a `*.mtl` file. It calls `mtl_merge` before, and fallbacks to remote compiler in case binary is not found and `HOST` is given.
59
+ A wrapper around `mtl_comp`. Compiles a `*.mtl` file. It calls `mtl_merge` before
20
60
 
21
61
  #### mtl_simu
22
62
 
23
- Runs a `*.mtl` file. It calls `mtl_merge` before, and fallbacks to remote simulator in case binary is not found and `HOST` is given.
63
+ A wrapper around `mtl_simu`. Runs a `*.mtl` file. It calls `mtl_merge` before
64
+
65
+ #### mtl_merge
24
66
 
67
+ Merges multiple `*.mtl` files into one. Files are included like in C: `#include "<relative path to file>"`. Output is temporary file `.tmp.mtl`.
25
68
 
26
- ### Understanding the Bytecode
69
+ ## Development
27
70
 
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.
71
+ Be sure to checkout `mtl_linux` submodule first:
72
+
73
+ ```
74
+ git submodule update
75
+ ```
76
+
77
+ To update the kit run:
78
+
79
+ ```
80
+ bundle exec rake build && bundle exec gem install -V pkg/nabaztag_hack_kit-0.1.0.beta6.gem
81
+ ```
82
+
83
+ ## Understanding the Bytecode
84
+
85
+ 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 `bytecode/_original` which contains a basic overview & documentation 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 `bytecode/lib/` directory and ready to be included in your code.
86
+
87
+ Grammar: https://docs.google.com/document/d/1KMg2wSyMKTmsilCpOByi_59uk5dD8XMfGAu20W63kZE/edit?hl=en_US
29
88
 
30
89
  ### Testing
31
90
 
32
- The kit includes a simple test framework to test custom bytecode. See `test/bytecode/test.mtl`. A typical test looks like this:
91
+ The kit includes a simple test framework to test custom bytecode. See `bytecode/test/test.mtl`. A typical test looks like this:
33
92
 
34
93
  ```c
35
- let test "<test name>" -> t in
94
+ let test "math operations" -> t in
36
95
  (
37
96
  //assertions
38
- assert_equalI 0 10 - (2* 5);
97
+ assert_equalI 0 10 - (2 * 5);
39
98
  0);
40
99
  ```
41
100
 
42
101
  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
102
  explicit. Convention is:
44
103
 
45
- * I = interger
104
+ * I = integer
46
105
  * S = string
47
106
  * L = list
48
- * T = tab
107
+ * T = table
49
108
 
50
- Following assertions are available:
109
+ Following assertions are available (see bytecode/test/helper.mtl)
51
110
 
52
111
  * assert_equalI I I
53
112
  * assert_equalI S S
@@ -56,32 +115,21 @@ Following assertions are available:
56
115
  * assert_equalSL
57
116
  * assert_equalTL
58
117
 
59
-
60
- ## Server
61
-
62
- The Server is the communication endpoint for the rabbit. Its two main purposes are:
63
-
64
- 1. serving the bytecode on bootup
65
- 2. receive and respond to HTTP requests in a defined format.
66
-
67
- To start the server, run shortcut `rake run` or, as it's based on rack, `rackup -p <portnumer>`.
68
-
69
-
70
118
  ## API
71
- As example and for my own purposes I implemented a simple API to deal with RFID, LEDS, BUTTON and EARS easily.
119
+ As example and for my own purposes I implemented a simple API to deal with RFID, LEDS, BUTTON and EARS easily. (see bytecode/main.mtl)
72
120
 
73
121
  ### Input Devices
74
122
 
75
123
  #### RFID
76
- NabaztagInjector
124
+ see my other project *NabaztagInjector*
77
125
 
78
126
 
79
127
  #### BUTTON
80
128
  Current Button has very basic functionality: a short press send HTTP Request of type `Log` to server, a long
81
- press foreces the bunny to restart.
129
+ press forces the bunny to restart.
82
130
 
83
131
  ### Output Devices
84
- Data for all output devices are stored in buffers. Each device has two: one for ontime, imediate playback, another for permanet loops.
132
+ Data for all output devices are stored in buffers. Each device has two: one for onetime, imediate playback, another for permanent loops.
85
133
 
86
134
  #### LEDS
87
135
  Buffers 0 - 9, where 0-4 are used for onetime, and 5-9 for loop playback.
@@ -90,30 +138,53 @@ Buffers 0 - 9, where 0-4 are used for onetime, and 5-9 for loop playback.
90
138
  Buffers 10 - 13, where 10 & 11 are used for onetime, and 12 & 13 for loop playback.
91
139
 
92
140
 
93
-
94
141
  ## Disclamer
95
142
 
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
- Thanks!
143
+ The server part was heavily inspired by [Trudy.rb](https://github.com/quimarche/trudy/blob/master/trudy.rb), compiler code copied from [OpenJabNab](https://github.com/OpenJabNab/OpenJabNab). Thanks!
144
+
145
+
146
+ ## Nabaztag Background
147
+ Read following posting for more background on Nabaztag Hacking (uses google translate:)
98
148
 
149
+ * [First class info from the creator himself](http://www.sylvain-huet.com/?lang=en#nabv2)
150
+ * [A good nabaztag Blog](https://www.journaldulapin.com/tag/nabaztag/)
151
+ * [A good introduction to understand Nabaztag Protocol](http://www.sis.uta.fi/~spi/jnabserver/documentation/index.html)
152
+ * [Les source bytecode et compilateur](http://translate.googleusercontent.com/translate_c?hl=en&rurl=translate.google.com&sl=fr&tl=en&twu=1&u=http://nabaztag.forumactif.fr/t13241p30-les-sources-bytecode-et-compilateur&usg=ALkJrhjLTbx1GMfSUgwhdjES1LzlE07HZQ#338060)
153
+ * [Mindscape donne une seconde vie a nabaztag](http://translate.google.com/translate?hl=en&sl=fr&tl=en&u=http%3A%2F%2Fwww.planete-domotique.com%2Fblog%2F2011%2F08%2F07%2Fmindscape-donne-une-seconde-vie-a-nabaztag%2F)
99
154
 
100
- ### Protocol
101
- A good introduction to understand Nabaztag Protocol:
155
+ ## Related Projects
102
156
 
103
- * http://www.cs.uta.fi/hci/spi/jnabserver/documentation/index.html
157
+ New firmware with WPA2
158
+ 1. https://github.com/ccarlo64/firmware_nabaztag
159
+ (see http://nabaztag.forumactif.fr/t15323-firmware-for-wpa-wpa2-test)
104
160
 
161
+ 2. https://github.com/RedoXyde/nabgcc
162
+ https://github.com/RedoXyde/mtl_linux
163
+ (see http://nabaztag.forumactif.fr/t15280p25-nabaztagtag-en-wpa2)
105
164
 
106
- ### Nabaztag Background
107
- Read following posting for more backgorund on Nabaztag Hacking (uses google translate:)
165
+ ServerlessNabaztag
166
+ -> https://github.com/andreax79/ServerlessNabaztag
108
167
 
109
- * [Les source bytecode et compilateur](http://translate.googleusercontent.com/translate_c?hl=en&rurl=translate.google.com&sl=fr&tl=en&twu=1&u=http://nabaztag.forumactif.fr/t13241p30-les-sources-bytecode-et-compilateur&usg=ALkJrhjLTbx1GMfSUgwhdjES1LzlE07HZQ#338060)
110
- * [Mindscape donne une seconde vie a nabaztag](http://translate.google.com/translate?hl=en&sl=fr&tl=en&u=http%3A%2F%2Fwww.planete-domotique.com%2Fblog%2F2011%2F08%2F07%2Fmindscape-donne-une-seconde-vie-a-nabaztag%2F)
168
+ CloudServer replace: http://nabaztaglives.com/
111
169
 
170
+ Rebuild Nabaztag:
171
+ - https://www.hackster.io/bastiaan-slee/nabaztag-gets-a-new-life-with-google-aiy-e9f2c8
112
172
 
113
- ### Future
173
+
174
+ ## Websocket
175
+
176
+ Websocket HowTo:
177
+ - https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers
178
+
179
+ - http://blog.honeybadger.io/building-a-simple-websockets-server-from-scratch-in-ruby/
180
+ - https://github.com/pusher/websockets-from-scratch-tutorial
181
+
182
+
183
+ ## Future
114
184
  I'd like to hack the Violet mir:ror too. Some starting points:
115
185
 
116
186
  * https://github.com/leh/ruby-mirror
117
187
  * http://reflektor.sourceforge.net/
118
-
119
-
188
+ * http://www.instructables.com/id/Kids-check-in-and-check-out-with-hacked-Mirror-an/
189
+ * http://svay.com/blog/hacking-rfid-with-nodejs/
190
+ * http://arduino-projects4u.com/violet-mirror/
data/Rakefile CHANGED
@@ -1,6 +1,2 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
File without changes
File without changes
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/bytecode/main.mtl CHANGED
@@ -4,17 +4,17 @@ proto main 0;;
4
4
  proto earsInit 0;;
5
5
  proto evalTrame 1;;
6
6
 
7
- #include "src/lib/var"
8
- #include "src/lib/util"
9
- #include "src/lib/cfg"
10
- #include "src/lib/arp"
11
- #include "src/lib/udp"
12
- #include "src/lib/tcp"
13
- #include "src/lib/dns"
14
- #include "src/lib/http"
15
- #include "src/lib/dhcp"
16
- #include "src/lib/wav"
17
- #include "src/lib/wifi"
7
+ #include "_original/lib/var"
8
+ #include "_original/lib/util"
9
+ #include "_original/lib/cfg"
10
+ #include "_original/lib/arp"
11
+ #include "_original/lib/udp"
12
+ #include "_original/lib/tcp"
13
+ #include "_original/lib/dns"
14
+ #include "_original/lib/http"
15
+ #include "_original/lib/dhcp"
16
+ #include "_original/lib/wav"
17
+ #include "_original/lib/wifi"
18
18
 
19
19
  #include "lib/data_helper"
20
20
 
@@ -1,6 +1,6 @@
1
1
  proto main 0;;
2
2
 
3
- #include "../src/lib/util"
3
+ #include "../_original/lib/util"
4
4
  #include "../lib/data_helper"
5
5
  #include "../lib/buffer"
6
6
 
@@ -209,13 +209,13 @@ fun main=
209
209
  assert_equalI 0xFFFFFF bufferRead 0;
210
210
  0);
211
211
 
212
- let test "log" -> t in
213
- (
214
- log "test" {1};
215
- assert_equalS "test,0,1,|" logs;
216
- log "test" {56 67 90};
217
- assert_equalS "test,0,1,|test,0,56,67,90,|" logs;
218
- 0);
212
+ //let test "log" -> t in
213
+ //(
214
+ // log "test" {1};
215
+ // assert_equalS "test,0,1,|" logs;
216
+ // log "test" {56 67 90};
217
+ // assert_equalS "test,0,1,|test,0,56,67,90,|" logs;
218
+ //0);
219
219
 
220
220
  exit;
221
221
  0;;
@@ -1,6 +1,4 @@
1
1
  # A sample Gemfile
2
2
  source "http://rubygems.org"
3
3
 
4
- gem "nabaztag_hack_kit", {
5
- :path => "../../"
6
- }
4
+ gem "nabaztag_hack_kit", path:"../../"
@@ -1,10 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
4
- require './server'
5
-
6
3
  $stdout.sync = true
7
4
 
8
- use Rack::Reloader, 0
5
+ require 'bundler/setup'
6
+ require 'nabaztag_hack_kit/server'
7
+ require 'nabaztag_hack_kit/mods/callback'
8
+ # require 'nabaztag_hack_kit/mods/logger'
9
+ require 'nabaztag_hack_kit/mods/playground'
10
+
11
+ module Basic
12
+ class Server < NabaztagHackKit::Server
13
+ register NabaztagHackKit::Mods::Callback
14
+ # register Mods::Logger
15
+ register NabaztagHackKit::Mods::Playground
16
+ end
17
+ end
9
18
 
19
+ # use Rack::Reloader, 0
10
20
  run Basic::Server.new
@@ -3,8 +3,3 @@ source "http://rubygems.org"
3
3
 
4
4
  gem "nabaztag_hack_kit"
5
5
  gem "ruby-echonest"
6
-
7
- group :development do
8
- gem "heroku"
9
- gem "foreman"
10
- end
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
3
+ require 'bundler/setup'
4
4
  require './server'
5
5
 
6
- use Rack::Reloader, 0
6
+ # use Rack::Reloader, 0
7
7
 
8
8
  ECHONEST_CFG = {
9
9
  :key => "",
@@ -1,4 +1,3 @@
1
-
2
1
  require "nabaztag_hack_kit/server"
3
2
  require "soundcloud"
4
3
  require "echonest"
@@ -107,4 +106,3 @@ class Server < NabaztagHackKit::Server
107
106
  end
108
107
  end
109
108
  end
110
-
data/ext/Makefile ADDED
@@ -0,0 +1,10 @@
1
+ all:
2
+ echo "all"
3
+ cd mtl_linux && make
4
+
5
+ install:
6
+ echo "install"
7
+
8
+ clean:
9
+ echo "clean"
10
+ cd mtl_linux && make clean
data/ext/bin/mtl_comp ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ BIN_NAME = 'mtl_compiler'
4
+ BIN_PATH = File.dirname(__FILE__)
5
+ BIN = File.join(File.expand_path("../mtl_linux", BIN_PATH), BIN_NAME)
6
+ FILE = ARGV.first
7
+
8
+ FILTER = ENV['FILTER'] || "| grep -v 'bytes' | grep -e'[a-z]'"
9
+ MERGE = File.join(BIN_PATH, 'mtl_merge')
10
+ TMP = ENV['TMP'] || '.tmp.mtl'
11
+ OUT = ENV['OUT'] || "bytecode.bin"
12
+
13
+ unless FILE
14
+ puts "usage: #{File.basename(__FILE__)} [filename]"
15
+ abort
16
+ end
17
+
18
+ # merge
19
+ `TMP='#{TMP}' #{MERGE} #{FILE}`
20
+
21
+ # compile
22
+ out = if File.exists?(BIN)
23
+ `#{BIN} -s #{TMP} #{OUT} 2>&1 #{FILTER}`
24
+ else
25
+ "local binary not found: #{BIN}"
26
+ end
27
+
28
+ puts out
29
+ `rm #{TMP}`
File without changes
data/ext/bin/mtl_simu ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ BIN_NAME = File.basename(__FILE__)
4
+ BIN_PATH = File.dirname(__FILE__)
5
+ BIN = File.join(File.expand_path("../mtl_linux", BIN_PATH), BIN_NAME)
6
+ FILE = ARGV.first
7
+
8
+ FILTER = ENV['FILTER'] || "| grep -v 'bytes' | grep -e'[a-z]'"
9
+ MERGE = File.join(BIN_PATH, 'mtl_merge')
10
+ TMP = ENV['TMP'] || '.tmp.mtl'
11
+ OUT = ENV['OUT'] || "bytecode.bin"
12
+
13
+ unless FILE
14
+ puts "usage: #{File.basename(__FILE__)} [filename]"
15
+ abort
16
+ end
17
+
18
+ # merge
19
+ `TMP='#{TMP}' #{MERGE} #{FILE}`
20
+
21
+ # simu
22
+ out = if File.exists?(BIN)
23
+ `#{BIN} --source #{TMP}`
24
+ else
25
+ "local binary not found: #{BIN}"
26
+ end
27
+
28
+ puts out
29
+ `rm #{TMP}`
File without changes
@@ -0,0 +1,7 @@
1
+ obj/
2
+ mtl_simu
3
+ mtl_compiler
4
+ libvcomp.a
5
+ *.bin
6
+ *.mtl
7
+ dumpbc.c
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.