Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-controlserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenzhongjian
car-controlserver
Commits
98fb2c44
Commit
98fb2c44
authored
Dec 25, 2024
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update main.c
parent
3d5b2c74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
122 deletions
+122
-122
main.c
main.c
+122
-122
No files found.
main.c
View file @
98fb2c44
#include "main.h"
#include "main.h"
#include "ip.h"
#include "ip.h"
#include "mqtt.h"
#include "mqtt.h"
#include "serial.h"
#include "serial.h"
#include "delay.h"
#include "delay.h"
#include "opensh.h"
#include "opensh.h"
//#include "mac.h"
//#include "mac.h"
void
*
serial_usart1
(
void
*
arg
)
void
*
serial_usart1
(
void
*
arg
)
{
{
printf
(
"serial_usart 1 start
\n
"
);
printf
(
"serial_usart 1 start
\n
"
);
serial_Receive_1
();
//串口接收1,用于以后读取引脚高低电平
serial_Receive_1
();
//串口接收1,用于以后读取引脚高低电平
return
NULL
;
return
NULL
;
}
}
void
*
AppExit
(
void
*
arg
)
//2s程序,出现意外2s自动停止
void
*
AppExit
(
void
*
arg
)
//2s程序,出现意外2s自动停止
{
{
while
(
1
)
while
(
1
)
{
{
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
1
,
0
};
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
1
,
0
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
2
,
0
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
2
,
0
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
3
,
0
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
3
,
0
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
4
,
0
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
4
,
0
};
//unsigned char bufpwm5[3]={gtypeTemp,5,15};
//unsigned char bufpwm5[3]={gtypeTemp,5,15};
Delay_Ms
(
0
,
100
);
Delay_Ms
(
0
,
100
);
gPwmCount
++
;
gPwmCount
++
;
//printf( "%d\n",gtypeTemp);
//printf( "%d\n",gtypeTemp);
if
(
gPwmCount
>
20
)
if
(
gPwmCount
>
20
)
{
{
//printf( "%d\n",gtypeTemp);
//printf( "%d\n",gtypeTemp);
gPwmCount
=
21
;
gPwmCount
=
21
;
//serial_Write(bufpwm5);
//serial_Write(bufpwm5);
serial_Write
(
bufpwm1
);
serial_Write
(
bufpwm1
);
serial_Write
(
bufpwm2
);
serial_Write
(
bufpwm2
);
serial_Write
(
bufpwm3
);
serial_Write
(
bufpwm3
);
serial_Write
(
bufpwm4
);
serial_Write
(
bufpwm4
);
}
}
}
}
return
NULL
;
return
NULL
;
}
}
void
*
Mqttbeat
(
void
*
arg
)
void
*
Mqttbeat
(
void
*
arg
)
{
{
printf
(
"Mqttbeat start
\n
"
);
printf
(
"Mqttbeat start
\n
"
);
Delay_Ms
(
5
,
0
);
Delay_Ms
(
5
,
0
);
while
(
1
)
while
(
1
)
{
{
mqtt_wirte
();
//心跳,3s一个
mqtt_wirte
();
//心跳,3s一个
Delay_Ms
(
3
,
0
);
Delay_Ms
(
3
,
0
);
}
}
return
NULL
;
return
NULL
;
}
}
void
*
opensh
(
void
*
arg
)
void
*
opensh
(
void
*
arg
)
{
{
Delay_Ms
(
10
,
0
);
Delay_Ms
(
10
,
0
);
printf
(
"open cam
\n
"
);
printf
(
"open cam
\n
"
);
opencamsh
();
//10s后打开火狐游览器并且进入网址
opencamsh
();
//10s后打开火狐游览器并且进入网址
return
NULL
;
return
NULL
;
}
}
void
*
serial_usart2
(
void
*
arg
)
void
*
serial_usart2
(
void
*
arg
)
{
{
printf
(
"serial_usart 2 start
\n
"
);
printf
(
"serial_usart 2 start
\n
"
);
serial_Receive_2
();
//启动串口二
serial_Receive_2
();
//启动串口二
return
NULL
;
return
NULL
;
}
}
void
*
Mqtt_onnect
(
void
*
arg
)
void
*
Mqtt_onnect
(
void
*
arg
)
{
{
Delay_Ms
(
5
,
0
);
Delay_Ms
(
5
,
0
);
mqtt_init
();
//mqtt初始化
mqtt_init
();
//mqtt初始化
mqtt_create
(
mosq
);
//创建mqtt客户端
mqtt_create
(
mosq
);
//创建mqtt客户端
mqtt_create
(
mosq
);
//mqtt_wirte();//mqtt心跳首次发送
//mqtt_wirte();//mqtt心跳首次发送
while
(
1
)
while
(
1
)
{
{
if
(
mqtt_create
(
mosq
)
!=-
1
)
if
(
mqtt_create
(
mosq
)
!=-
1
)
{
{
mqtt_cycle
(
mosq
);
mqtt_cycle
(
mosq
);
}
}
}
}
mqtt_clean
(
mosq
);
mqtt_clean
(
mosq
);
return
NULL
;
return
NULL
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
gStart
=
time
(
NULL
);
//开始时间戳
gStart
=
time
(
NULL
);
//开始时间戳
serial_Init
();
//串口初始化
serial_Init
();
//串口初始化
// get_mac_address("eth0");//获取mac地址
// get_mac_address("eth0");//获取mac地址
ipaddr
();
//获取ip
ipaddr
();
//获取ip
//mosquitto_publish(mosq, NULL, "macmqtt", strlen(TOPIC), TOPIC, 0, false);
//mosquitto_publish(mosq, NULL, "macmqtt", strlen(TOPIC), TOPIC, 0, false);
thread_start
(
serial_usart1
,
AppExit
,
Mqttbeat
,
serial_usart2
,
opensh
,
Mqtt_onnect
);
thread_start
(
serial_usart1
,
AppExit
,
Mqttbeat
,
serial_usart2
,
opensh
,
Mqtt_onnect
);
//mqtt_cycle(mosq);
//mqtt_cycle(mosq);
thread_end
();
thread_end
();
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment