-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-sample1.rb
41 lines (40 loc) · 1.23 KB
/
task-sample1.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
PORT_ID = 1
logger = Nucleo::Serial.new(PORT_ID)
logger.syslog("###-- task#{Nucleo::TASK_NO} active\r\n")
loop = Nucleo::Sample1.new()
que = Nucleo::DataQue.new(Nucleo::DATA_QUE_ID)
counter = 0
command = 0
while true
counter += 1
command = que.receive_polling
logger.syslog("task#{Nucleo::TASK_NO} is running #{counter} : #{command}. |")
loop.consume_time_task_loop
if command
case command
when 101 #e
logger.syslog("task#{Nucleo::TASK_NO}:e ext_tsk")
Nucleo::Task.exit()
when 115 #s
logger.syslog("task#{Nucleo::TASK_NO}:s slp_tsk")
Nucleo::Task.sleep()
when 83 #S
logger.syslog("task#{Nucleo::TASK_NO}:S tslp_tsk(10000000)")
Nucleo::Task.sleep(10000)
when 100 #d 10sは長いので5sにする
logger.syslog("task#{Nucleo::TASK_NO}:d dly_tsk(5000000)")
Nucleo::Task.delay(5000)
when 121 #y
logger.syslog("task#{Nucleo::TASK_NO}:y dis_ter")
Nucleo::Task.disable_terminate()
when 89 #Y
logger.syslog("task#{Nucleo::TASK_NO}:Y ena_ter")
# ena_ter
Nucleo::Task.enable_terminate()
else
#NucleoではCPUEXXC1未定義のためz,Zもなし
logger.syslog("Unknown task#{Nucleo::TASK_NO}: #{command}")
end
end
GC.start
end