-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathloop.cpp
More file actions
42 lines (38 loc) · 1.03 KB
/
loop.cpp
File metadata and controls
42 lines (38 loc) · 1.03 KB
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
42
// SPDX-License-Identifier: GPL-3.0-only
#include <cstdlib>
#include <unistd.h>
#include <fstream>
#include <iostream>
//何回ループさせるか
#define count 10
//青信号の時間
#define TIME_LIMIT_BLUE 10
//黄信号の時間
#define TIME_LIMIT_YELLOW 1
//赤信号の時間(青と黄の合計)
#define TIME_LIMIT_RED TIME_LIMIT_BLUE + TIME_LIMIT_YELLOW
int main()
{
//実行前にディレクトリの掃除
std::system("sudo rmmod myled.ko");
std::system("make clean");
//実行
std::system("make");
std::system("sudo insmod myled.ko");
std::system("sudo chmod 666 /dev/myled0");
for (int i = 0; i < count; i++)
{
//青
std::system("echo 1 > /dev/myled0");
//黄
sleep(TIME_LIMIT_BLUE);
std::system("echo 2 > /dev/myled0");
sleep(TIME_LIMIT_YELLOW);
//赤
std::system("echo 3 > /dev/myled0");
sleep(TIME_LIMIT_RED);
}
std::system("echo 0 > /dev/myled0");
std::system("sudo rmmod myled.ko");
std::system("make clean");
}