flok 0.0.87 → 0.0.88
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.
- checksums.yaml +4 -4
- data/app/drivers/chrome/config.yml +2 -0
- data/app/drivers/chrome/src/rtc.js +9 -0
- data/app/drivers/chrome/src/timer.js +1 -1
- data/app/kern/mod/rtc.js +5 -0
- data/app/kern/time.js +4 -0
- data/docs/kernel_api.md +3 -0
- data/docs/mod/rtc.md +10 -0
- data/docs/mod/speech.md +1 -1
- data/docs/mod/timer.md +2 -1
- data/lib/flok/version.rb +1 -1
- data/spec/iface/driver/rtc_spec.rb +45 -0
- data/spec/iface/driver/timer_spec.rb +1 -1
- data/spec/kern/rtc_spec.rb +26 -0
- data/spec/lib/rspec_extensions.rb +15 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f7c1d58d114b65944fe9b7c0b93cf3f1add02ab
|
4
|
+
data.tar.gz: 3b56e5c4a6e7e99fbb8a6dc08100890141cbe934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8df5aa50fea837620349c56c9910bd63b12bf66a823a7fbf80c24b8a71371c34c681effb071971d7ba421b1f11d28475a8665222f1c40b8491dc337835c1b56
|
7
|
+
data.tar.gz: 28957c4505e8e45fb166c0e1975c299e2469cdb18d5c07daff402f411b3cc63343bea482e5f8e1c3f82dfc93c539f4a525bd94fa03ebdb6f07257c702ac2266a
|
data/app/kern/mod/rtc.js
ADDED
data/app/kern/time.js
ADDED
data/docs/kernel_api.md
CHANGED
@@ -42,6 +42,9 @@ instead.
|
|
42
42
|
##Timers
|
43
43
|
* See [./callout.md](Callout) for how to register a timer
|
44
44
|
|
45
|
+
##Time
|
46
|
+
* `time()` - Returns the time in seconds since 1970 (unix epoch). Must have a compatible module, [`rtc`]
|
47
|
+
|
45
48
|
##Things that are compiled into the kernel from user given data
|
46
49
|
`MODS` - A list of modules that was specified in `./app/drivers/$PLATFORM/config.yml`
|
47
50
|
`PLATFORM` - The platform that this kernel was compiled with
|
data/docs/mod/rtc.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#Real Time Clock (rtc.js)
|
2
|
+
|
3
|
+
###Driver
|
4
|
+
`if_rtc_init()` - Initialize the RTC module.
|
5
|
+
|
6
|
+
###Interrupts
|
7
|
+
`int_rtc(epoch)` - Called every second to indicate that a second has passed.
|
8
|
+
|
9
|
+
###Helper functions
|
10
|
+
`time()` - Retrieves the time as an integer based on the unix epoch (Seconds since 1970)
|
data/docs/mod/speech.md
CHANGED
@@ -9,4 +9,4 @@ There is a software-simulation of the `speech` module. To enable it, put `speech
|
|
9
9
|
`int_speech_cancelled()` - The speech was cancelled
|
10
10
|
`int_speech_finished()` - The speech completed succesfully
|
11
11
|
`int_speech_started()` - The speech has started
|
12
|
-
`int_will_speak_range(offset, count)` - The speech is in the process of talking over a range of the text
|
12
|
+
`int_will_speak_range(offset, count)` - The speech is in the process of talking over a range of the text
|
data/docs/mod/timer.md
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
`if_timer_init(tps)` - Initiate a timer that calls `int_timer` N `tps` (ticsk per second). This is always called via the cpu scheduling class (3)
|
5
5
|
|
6
6
|
###Interrupts
|
7
|
-
`int_timer` - Called by the device at the rate described in `tps`. This function lives inside the `timer` service's initialization portion.
|
7
|
+
`int_timer()` - Called by the device at the rate described in `tps`. This function lives inside the `timer` service's initialization portion.
|
8
|
+
A. Requires the timer module.
|
8
9
|
|
9
10
|
###Callout
|
10
11
|
The kernel's `int_timer` function gets sent to `callout_wakeup()` located in `callout.js`.
|
data/lib/flok/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
Dir.chdir File.join File.dirname(__FILE__), '../../../'
|
2
|
+
require './spec/env/iface.rb'
|
3
|
+
require './spec/lib/helpers.rb'
|
4
|
+
require './spec/lib/io_extensions.rb'
|
5
|
+
require './spec/lib/rspec_extensions.rb'
|
6
|
+
|
7
|
+
RSpec.describe "iface:driver:rtc" do
|
8
|
+
module_dep "rtc"
|
9
|
+
include_context "iface:driver"
|
10
|
+
|
11
|
+
it "Does update epoch every second" do
|
12
|
+
#Wait for response
|
13
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
14
|
+
|
15
|
+
@pipe.puts [[0, 1, "if_rtc_init"]].to_json
|
16
|
+
|
17
|
+
#Wait to start until after the 1st event fires to make sure timer started up
|
18
|
+
@pipe.readline
|
19
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_rtc", Fixnum], 5.seconds)
|
20
|
+
start_time = Time.now.to_i
|
21
|
+
5.times do
|
22
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_rtc", Fixnum], 2.seconds)
|
23
|
+
end
|
24
|
+
end_time = Time.now.to_i
|
25
|
+
|
26
|
+
#Just leave some room for connection latency, etc.
|
27
|
+
expect(end_time - start_time).to be < 7
|
28
|
+
expect(end_time - start_time).to be > 4
|
29
|
+
|
30
|
+
#Now let's compare one-to-three 'ticks'
|
31
|
+
a = JSON.parse(@pipe.readline_timeout)
|
32
|
+
sleep 1
|
33
|
+
b = JSON.parse(@pipe.readline_timeout)
|
34
|
+
|
35
|
+
#They should be at least 1 second apart and not more than 3
|
36
|
+
a_timestamp = a[2]
|
37
|
+
b_timestamp = b[2]
|
38
|
+
expect(b_timestamp - a_timestamp).to be > 0
|
39
|
+
expect(b_timestamp - a_timestamp).to be < 4
|
40
|
+
|
41
|
+
#Should match the current epoch within 1 minute
|
42
|
+
current_epoch = Time.now.to_i
|
43
|
+
expect((b_timestamp - current_epoch).abs).to be < 60
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
2
|
+
require './spec/env/kern.rb'
|
3
|
+
require './spec/lib/helpers.rb'
|
4
|
+
require './spec/lib/io_extensions.rb'
|
5
|
+
require './spec/lib/rspec_extensions.rb'
|
6
|
+
|
7
|
+
RSpec.describe "kern:rtc_spec" do
|
8
|
+
include_context "kern"
|
9
|
+
|
10
|
+
it "Does update the epoch when receiving the int_rtc message" do
|
11
|
+
#Compile the controller
|
12
|
+
ctx = flok_new_user File.read('./spec/kern/assets/blank.rb')
|
13
|
+
|
14
|
+
@driver.int("int_rtc", [555])
|
15
|
+
dump = ctx.evald %{
|
16
|
+
dump.time = time()
|
17
|
+
}
|
18
|
+
expect(dump["time"]).to eq(555)
|
19
|
+
|
20
|
+
@driver.int("int_rtc", [556])
|
21
|
+
dump = ctx.evald %{
|
22
|
+
dump.time = time()
|
23
|
+
}
|
24
|
+
expect(dump["time"]).to eq(556)
|
25
|
+
end
|
26
|
+
end
|
@@ -97,7 +97,21 @@ RSpec::Matchers.define :readline_and_equal_json_x_within_y_seconds do |json, sec
|
|
97
97
|
begin
|
98
98
|
Timeout::timeout(seconds) do
|
99
99
|
@res = JSON.parse(pipe.readline.strip)
|
100
|
-
|
100
|
+
|
101
|
+
if json.class != Array
|
102
|
+
return true if @res == json
|
103
|
+
else
|
104
|
+
expect(@res.length).to eq(json.length)
|
105
|
+
@res.each_with_index do |r, i|
|
106
|
+
if json[i] == Fixnum
|
107
|
+
expect(r.class).to eq(Fixnum)
|
108
|
+
else
|
109
|
+
expect(r).to eq(json[i])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
return true
|
113
|
+
end
|
114
|
+
|
101
115
|
end
|
102
116
|
rescue Timeout::Error #Time out
|
103
117
|
rescue EOFError #Couldn't read pipe
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.88
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
@@ -285,6 +285,7 @@ files:
|
|
285
285
|
- app/drivers/chrome/src/helpers.js
|
286
286
|
- app/drivers/chrome/src/net.js
|
287
287
|
- app/drivers/chrome/src/persist.js
|
288
|
+
- app/drivers/chrome/src/rtc.js
|
288
289
|
- app/drivers/chrome/src/segue.js
|
289
290
|
- app/drivers/chrome/src/sockio.js
|
290
291
|
- app/drivers/chrome/src/timer.js
|
@@ -304,6 +305,7 @@ files:
|
|
304
305
|
- app/kern/mod/event.js
|
305
306
|
- app/kern/mod/net.js
|
306
307
|
- app/kern/mod/persist.js
|
308
|
+
- app/kern/mod/rtc.js
|
307
309
|
- app/kern/mod/segue.js
|
308
310
|
- app/kern/mod/sockio.js
|
309
311
|
- app/kern/mod/timer.js
|
@@ -319,6 +321,7 @@ files:
|
|
319
321
|
- app/kern/services/vm.rb
|
320
322
|
- app/kern/spec_helper.js
|
321
323
|
- app/kern/tel.js
|
324
|
+
- app/kern/time.js
|
322
325
|
- bin/flok
|
323
326
|
- docs/architecture.md
|
324
327
|
- docs/branches.md
|
@@ -345,6 +348,7 @@ files:
|
|
345
348
|
- docs/mod/intercept.md
|
346
349
|
- docs/mod/net.md
|
347
350
|
- docs/mod/persist.md
|
351
|
+
- docs/mod/rtc.md
|
348
352
|
- docs/mod/sockio.md
|
349
353
|
- docs/mod/speech.md
|
350
354
|
- docs/mod/timer.md
|
@@ -1130,6 +1134,7 @@ files:
|
|
1130
1134
|
- spec/iface/driver/persist_spec.rb
|
1131
1135
|
- spec/iface/driver/ping_spec.rb
|
1132
1136
|
- spec/iface/driver/pipe_spec.rb
|
1137
|
+
- spec/iface/driver/rtc_spec.rb
|
1133
1138
|
- spec/iface/driver/sockio_spec.rb
|
1134
1139
|
- spec/iface/driver/timer_spec.rb
|
1135
1140
|
- spec/iface/driver/ui_spec.rb
|
@@ -1303,6 +1308,7 @@ files:
|
|
1303
1308
|
- spec/kern/functions_spec.rb
|
1304
1309
|
- spec/kern/global_functions_spec.rb
|
1305
1310
|
- spec/kern/rest_service_spec.rb
|
1311
|
+
- spec/kern/rtc_spec.rb
|
1306
1312
|
- spec/kern/service_controller_spec.rb
|
1307
1313
|
- spec/kern/test_service_spec.rb
|
1308
1314
|
- spec/kern/vm_service_functional_spec.rb
|
@@ -2086,6 +2092,7 @@ test_files:
|
|
2086
2092
|
- spec/iface/driver/persist_spec.rb
|
2087
2093
|
- spec/iface/driver/ping_spec.rb
|
2088
2094
|
- spec/iface/driver/pipe_spec.rb
|
2095
|
+
- spec/iface/driver/rtc_spec.rb
|
2089
2096
|
- spec/iface/driver/sockio_spec.rb
|
2090
2097
|
- spec/iface/driver/timer_spec.rb
|
2091
2098
|
- spec/iface/driver/ui_spec.rb
|
@@ -2259,6 +2266,7 @@ test_files:
|
|
2259
2266
|
- spec/kern/functions_spec.rb
|
2260
2267
|
- spec/kern/global_functions_spec.rb
|
2261
2268
|
- spec/kern/rest_service_spec.rb
|
2269
|
+
- spec/kern/rtc_spec.rb
|
2262
2270
|
- spec/kern/service_controller_spec.rb
|
2263
2271
|
- spec/kern/test_service_spec.rb
|
2264
2272
|
- spec/kern/vm_service_functional_spec.rb
|