-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcar_bbloctask.c
More file actions
96 lines (75 loc) · 1.91 KB
/
car_bbloctask.c
File metadata and controls
96 lines (75 loc) · 1.91 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "carplate_main.h"
stBBAUFile BBUpInfo[AU_FILE_NUM];
static void* LocTaskThread(void* arg);
static void* LocWorkThread(void* arg);
void BB_LocTaskStart(void) {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_t thLoc;
pthread_create(&thLoc, &attr, LocTaskThread, NULL);
pthread_t thWork;
pthread_create(&thWork, &attr, LocWorkThread, NULL);
}
static void* LocWorkThread(void* arg) {
static int locWorkTime = 0;
uint8 last_alarmflag = 0;
while (1) {
if (netStatus == FALSE) {
printf("netStatus: %d\n", netStatus);
sleep(1);
continue;
}
if (netAuthen == FALSE) {
printf("netAuthen: %d\n", netAuthen);
sleep(1);
continue;
}
locWorkTime = (locWorkTime + 1) % 0xFFFF;
if (locWorkTime % LOCATION_INTVERVAL == 0 || last_alarmflag != alarmflag) {
if(last_alarmflag != alarmflag)
{
//printf(">>>>>>>>>>>>>Trigger activation code failure alarm\n");
pGpsInfo->extraA5Msg[0] = 0xA5;
pGpsInfo->extraA5Msg[1] = 0x06;
pGpsInfo->extraA5Msg[4] &= 0x00;
pGpsInfo->extraA5Msg[4] |= alarmflag;
last_alarmflag = alarmflag;
}
BB_LocMsgReply(NULL, NULL);
}
sleep(1);
}
}
static void* LocTaskThread(void* arg) {
while (TRUE) {
if (netStatus == FALSE) {
usleep(200000);
continue;
}
if (netAuthen == FALSE) {
usleep(200000);
continue;
}
usleep(500000);
}
return NULL;
}
void BB_LocMsgReply(uint8* uSeri, stGpsInformat* stGpsInfo)
{
//printf("Bubiao location upload\n");
stBBCommMsg sBBMsg;
sBBMsg.headFlag = 0;
if (stGpsInfo == NULL) {
stGpsInfo = pGpsInfo;
}
sBBMsg.msgID[0] = 0x02;
sBBMsg.msgID[1] = 0x00;
sBBMsg.dataLen = 28 + 8;
memset(sBBMsg.data, 0, 1024);
memcpy(sBBMsg.data, stGpsInfo, sizeof(stGpsInformat));
// PRINT("location upload: ", "02 00 ");
// showArray("", sBBMsg.data, sBBMsg.dataLen);
PRINT("", "location upload\n");
BB_SendCommMsg(&sBBMsg);
}