nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8

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 (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
@@ -1,271 +0,0 @@
1
- #define PROTORABBIT
2
- //#define PROTODAL
3
-
4
- // commenter la ligne suivante pour la version windows
5
- //#define VMICROCHIP
6
-
7
- typedef unsigned char uchar;
8
- typedef unsigned long ulong;
9
-
10
- #define vub unsigned char
11
- #define vsb signed char
12
-
13
- #define vuw unsigned short int
14
- #define vsw signed short int
15
-
16
- #define vud unsigned long
17
- #define vsd signed long
18
-
19
-
20
- void checkAllEvents(void);
21
-
22
-
23
- #ifdef PROTORABBIT
24
- #define VLISP_HARDWARE "NAB2"
25
- #define NBLED 15
26
- #define VL_MOTORS
27
- #define VL_MUSIC
28
- #define VL_3STATE
29
- #define NBMOTOR 2
30
- #endif
31
-
32
- #ifdef PROTODAL
33
- #define VLISP_HARDWARE "4"
34
- #define NBLED 27
35
- #define VL_PRESS
36
- #endif
37
-
38
- #ifdef VMICROCHIP
39
- int simuInit(){ return 0;}
40
- int simuDoLoop(){ return 0;}
41
- void simuSetLed(vub i,vub val){}
42
- void simuSetMotor(vub i,vub val){}
43
-
44
- #else
45
- #include<stdio.h>
46
- #include<stdlib.h>
47
- #include<string.h>
48
- #include<time.h>
49
-
50
- #include "linux_simuaudio.h"
51
- #include "linux_simunet.h"
52
- #include "log.h"
53
-
54
- // définition de l'échelle d'affichage de la simulation
55
- #define SCALE 2
56
-
57
- #define NBHOLES 20
58
- #define MASKEDHOLES 3
59
- // MAXMOTORVAL doit être inférieur à 256
60
- #define MAXMOTORVAL 100
61
-
62
- int motorwheel[256];
63
-
64
- // gestion des couleurs
65
- // ---------------------
66
- uchar coloradd[256*256];
67
- uchar colormul[256*256];
68
-
69
- #define COLORADD(x,y) (coloradd[(x)+((y)<<8)])
70
- #define COLORMUL(x,y) (colormul[(x)+((y)<<8)])
71
-
72
- #define RGBTOINT(r,g,b) (( (((int)r)&255)<<16)+((((int)g)&255)<<8)+(((int)b)&255))
73
- #define INTTOR(c) ((c>>16)&255)
74
- #define INTTOG(c) ((c>>8)&255)
75
- #define INTTOB(c) (c&255)
76
-
77
- // initialisation des tables de couleur
78
- void colortabInit()
79
- {
80
- int i,j,k;
81
-
82
- for(i=0;i<256;i++)
83
- for(j=0;j<256;j++)
84
- {
85
- k=i+j;
86
- coloradd[i+(j<<8)]=(k<=255)?k:255;
87
-
88
- k=i*j/255;
89
- colormul[i+(j<<8)]=k;
90
- }
91
- }
92
-
93
- // définition physique des leds
94
-
95
- // en fait il y a NBLED/3 leds, mais on en met 3 fois plus pour
96
- // pouvoir séparer chacune des composantes rgb de la couleur de chaque
97
- // led
98
- int diodeval[NBLED];
99
- #ifdef VL_MOTORS
100
- int motorval[NBMOTOR];
101
- int motorcount[NBMOTOR];
102
- int motordir[NBMOTOR];
103
- #endif
104
-
105
- int xclicsimu=-1;
106
- int yclicsimu=-1;
107
- int rclicsimu=0;
108
- int movesimu=0;
109
-
110
- int lastmovex=0;
111
- int lastmovey=0;
112
-
113
- #ifdef PROTORABBIT
114
- int diodex[NBLED]={80,80,80,40,40,40,80,80,80,120,120,120,80,80,80};
115
- int diodey[NBLED]={40,40,40,90,90,90,90,90,90,90,90,90,130,130,130};
116
- int diodergb[NBLED]=
117
- {0x0000ff,0x00ff00,0xff0000,
118
- 0x0000ff,0x00ff00,0xff0000,
119
- 0x0000ff,0x00ff00,0xff0000,
120
- 0x0000ff,0x00ff00,0xff0000,
121
- 0x0000ff,0x00ff00,0xff0000
122
- };
123
- #endif
124
-
125
- #ifdef PROTODAL
126
- int diodex[NBLED]={40,40,40,80,80,80,120,120,120,40,40,40,80,80,80,120,120,120,40,40,40,80,80,80,120,120,120};
127
- int diodey[NBLED]={40,40,40,40,40,40,40,40,40,80,80,80,80,80,80,80,80,80,120,120,120,120,120,120,120,120,120};
128
- int diodergb[NBLED]=
129
- {0x0000ff,0x00ff00,0xff0000,
130
- 0x0000ff,0x00ff00,0xff0000,
131
- 0x0000ff,0x00ff00,0xff0000,
132
- 0x0000ff,0x00ff00,0xff0000,
133
- 0x0000ff,0x00ff00,0xff0000,
134
- 0x0000ff,0x00ff00,0xff0000,
135
- 0x0000ff,0x00ff00,0xff0000,
136
- 0x0000ff,0x00ff00,0xff0000,
137
- 0x0000ff,0x00ff00,0xff0000
138
- };
139
- #endif
140
-
141
-
142
- // TODO
143
- int getButton() { return 0; }
144
-
145
- // fonction d'affichage des diodes
146
- int simuDisplay(int* intensity)
147
- {
148
- // TODO afficher l'état du lapin
149
- return 0;
150
- }
151
-
152
-
153
- // initialisation du simulateur
154
- vsd simuInit()
155
- {
156
- int i;
157
- colortabInit();
158
-
159
- for(i=0;i<NBLED;i++) diodeval[i]=255;
160
- srand(clock());
161
- #ifdef VL_MOTORS
162
- for(i=0;i<NBMOTOR;i++)
163
- {
164
- motorval[i]=60;//(rand()&255)*MAXMOTORVAL/256;
165
- motorcount[i]=motordir[i]=0;
166
- }
167
- for(i=0;i<256;i++) motorwheel[i]=0;
168
- for(i=0;i<MAXMOTORVAL;i++)
169
- {
170
- if ((i*2*NBHOLES/MAXMOTORVAL)&1) motorwheel[i]=1;
171
- if (i*NBHOLES/MAXMOTORVAL>=NBHOLES-MASKEDHOLES) motorwheel[i]=1;
172
- }
173
- #endif
174
- // setButton(1);
175
- simuaudioinit();
176
- simunetinit();
177
- return 0;
178
- }
179
-
180
-
181
-
182
- // fonction à appeler régulièrement, pour traiter les messages de la fenêtre du simulateur
183
- vsd simuDoLoop()
184
- {
185
- #ifdef VL_MOTORS
186
- int i,last;
187
- #endif
188
-
189
- checkAllEvents();
190
-
191
- #ifdef VL_MOTORS
192
- for(i=0;i<NBMOTOR;i++)
193
- {
194
- last=motorwheel[motorval[i]];
195
- if (1) motorval[i]+=motordir[i];
196
- if (motorval[i]<0) motorval[i]+=MAXMOTORVAL;
197
- if (motorval[i]>=MAXMOTORVAL) motorval[i]-=MAXMOTORVAL;
198
- if (last<motorwheel[motorval[i]]) motorcount[i]++;
199
- }
200
- #endif
201
- simuDisplay(diodeval);
202
- return 0;
203
- }
204
-
205
-
206
- /**
207
- Vérifie tous les évènements et fait les actions appropriées
208
- */
209
- void checkAllEvents(void)
210
- {
211
- checkNetworkEvents();
212
- }
213
-
214
-
215
- // réglagle d'une led
216
- void simuSetLed(int i,int val)
217
- {
218
- i*=3;
219
- if ((i<0)||(i>=NBLED)) return;
220
- diodeval[i]=(val>>16)&255;
221
- diodeval[i+1]=(val>>8)&255;
222
- diodeval[i+2]=(val)&255;
223
-
224
- my_printf(LOG_SIMULEDS, "Setting led %d: [%d %d %d]\n", i/3, diodeval[i], diodeval[i+1], diodeval[i+2]);
225
- my_printf(LOG_SIMULEDS, "All leds state:", i/3, diodeval[i], diodeval[i+1], diodeval[i+2]);
226
- for (i=0; i<NBLED/3; ++i)
227
- {
228
- my_printf(LOG_SIMULEDS, " [%3d %3d %3d]", diodeval[3*i], diodeval[3*i+1], diodeval[3*i+2]);
229
- }
230
- my_printf(LOG_SIMULEDS, "\n");
231
- }
232
-
233
- #ifdef VL_MOTORS
234
- // réglagle d'un moteur
235
- void set_motor_dir(int num_motor, int sens)
236
- {
237
- int tmp_num, tmp_sens;
238
- tmp_num = num_motor?1:0;
239
- tmp_sens = (sens==0)?0:((sens==1)?1:-1);
240
- motordir[tmp_num]=tmp_sens;
241
-
242
- my_printf(LOG_SIMUMOTORS, "Setting motor %d, direction %d (pos: %d)\n", tmp_num, tmp_sens);
243
- }
244
-
245
- int get_motor_val(int i)
246
- {
247
- int tmp_num = i?1:0;
248
- my_printf(LOG_SIMUMOTORS, "Getting value for motor %d: %d\n", tmp_num, motorcount[tmp_num]);
249
- return motorcount[tmp_num];
250
- }
251
- #else
252
- int get_motor_val(int i)
253
- {
254
- return 128;
255
- }
256
- #endif
257
-
258
- int get_button3()
259
- {
260
- // TODO
261
- return 0;
262
- }
263
-
264
- char buf_rfid[256];
265
-
266
- char* get_rfid()
267
- {
268
- // TODO
269
- return NULL;
270
- }
271
- #endif
@@ -1,16 +0,0 @@
1
- #include <stdio.h>
2
-
3
- #include "log.h"
4
-
5
- #define A() my_printf(LOG_SIMUAUDIO, "[[%s]]\n", __func__);
6
-
7
- int simuaudioinit() { A(); return 0; }
8
-
9
- int PlayStart() { A(); return 0; }
10
- int PlayStop() { A(); return 0; }
11
- int PlayEof() { A(); return 0; }
12
-
13
- int RecStart(int rate,int ChannelSize,int nbBuffers) { A(); return 0; }
14
- int RecStop() { A(); return 0; }
15
-
16
- void audioSetVolume(int vol) { A(); return ; }