0 Star 0 Fork 1

百十七 / 树莓派3B+_4B_ssd1306_亚博智能温度控制风扇驱动

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.c 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
百十七 提交于 2022-03-31 22:53 . init
#include "head.h"
int main(int argc,char * argv[])
{
if(argc != 2)
{
printf("Usage: tempc <command>\n");
printf("command:\n");
printf(" start (start daemon)\n");
printf(" stop (stop daemon)\n");
printf(" lon (turn on led lights)\n");
printf(" loff (turn off led lights)\n");
printf("To disbale led light, create /root/light_off file\n");
return 0;
}
else if(argc ==2)
{
if(strcmp(argv[1],"start") == 0)
{
if(access(PID_FILE,F_OK) == 0)
{
printf("The program has already started\n");
return -1;
}
system("/bin/tempcd");
return 0;
}
if(access(PID_FILE,F_OK) != 0)
{
printf("The program may not start\n");
return -1;
}
int fd_pid = open(PID_FILE,O_RDONLY);
char buf[MAX_SIZE];
read(fd_pid,buf,MAX_SIZE);
long int pid = atoi(buf);
if(strcmp(argv[1],"stop") == 0)
kill(pid,SIGINT);
if(strcmp(argv[1],"loff") == 0)
kill(pid,SIGUSR1);
if(strcmp(argv[1],"lon") == 0)
kill(pid,SIGUSR2);
return 0;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Einc/raspi_tempc.git
git@gitee.com:Einc/raspi_tempc.git
Einc
raspi_tempc
树莓派3B+_4B_ssd1306_亚博智能温度控制风扇驱动
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891