📄 main.c
字号:
#include <stdlib.h>#include <stdio.h>#include <unistd.h> /*Unix标准函数定义*/#include <sys/types.h> /**/#include <sys/stat.h> /**/#include <fcntl.h> /*文件控制定义*/#include <termios.h> /*PPSIX终端控制定义*/#include <errno.h> #include <pthread.h>#include "log.h"#include "watchdog.h"#include "gprsshortmessage.h"#define DEV "/dev/ttyS0"#define LOGPATH "/log"void *testthread(int* number){ while(1) { //printf("the first thread is runing,number=%d\n",*number); writelog("testthread is runing\n"); sleep(1); }}/***delete all shortmessage in the mobile card*return value:* -1:deleteallshortmessage() open com fail* 0:success*/int deleteallshortmessage(){ int fd; int shortmessageindex=1; if((fd=Open_Init_COM(DEV))==-1) { //exit(0); writelog("deleteallshortmessage() open com fail\n"); return -1; //continue; } while(shortmessageindex<40) Gprs_DeleteMessage(fd,shortmessageindex++); return 0;}int main(void){ FILE *confile,*checkfile; int tryNum=3; int returnVal,testdata; int watchdogfd; char cmd[256]; time_t nowT; struct tm *ptm = NULL; struct checkfiledata { struct tm *ptm; int rebootNum; } checkdata; pthread_t watchDogThread,waitTimerThread,shortMsgThread; int number; checkdata.ptm=(struct tm *)malloc(sizeof(struct tm)); /* init log subsystem */ returnVal = initlog(LOGPATH); if(returnVal < 0) { exit(1); } //deleteallshortmessage(); returnVal= pthread_create(&shortMsgThread, NULL, receiveshortmessagethread,NULL); if(returnVal < 0) { writelog("create short message receive thread failed!\n"); closelog(); //重启系统 sprintf(cmd,"reboot"); system(cmd); sleep(20); exit(1); } writelog("接收短信线程已经启动"); while(1); return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -