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
f15881ac
Commit
f15881ac
authored
Dec 17, 2024
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
241217
parent
fd9662ba
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
34 deletions
+36
-34
log.txt
log/log.txt
+0
-0
main
main
+0
-0
main.c
main.c
+8
-6
mqtt.c
mqtt.c
+28
-28
No files found.
log/log.txt
View file @
f15881ac
This source diff could not be displayed because it is too large. You can
view the blob
instead.
main
View file @
f15881ac
No preview for this file type
main.c
View file @
f15881ac
...
...
@@ -2,7 +2,7 @@
#include "ip.h"
#include "mqtt.h"
#include "serial.h"
#include "delay.h"
void
*
serial_usart1
(
void
*
arg
)
...
...
@@ -19,16 +19,18 @@ void *AppExit(void *arg)
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
0x01
,
0x00
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
0x02
,
0x00
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
0x03
,
0x00
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
0x04
,
0x00
};
while
(
1
)
{
Delay_Ms
(
0
,
150
);
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
1
,
0
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
2
,
0
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
3
,
0
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
4
,
0
};
Delay_Ms
(
0
,
100
);
gPwmCount
++
;
printf
(
"%d
\n
"
,
gtypeTemp
);
if
(
gPwmCount
>
20
)
{
//printf( "%d\n",gtypeTemp);
gPwmCount
=
21
;
serial_Write
(
bufpwm1
);
serial_Write
(
bufpwm2
);
...
...
mqtt.c
View file @
f15881ac
...
...
@@ -9,10 +9,10 @@ int rc=0;
struct
mosquitto
*
mosq
;
unsigned
char
gmodeT
me
p
=
0
;
unsigned
char
gmodeT
em
p
=
0
;
unsigned
char
gtypeTemp
=
0
;
unsigned
char
gpinTemp
=
0
;
unsigned
char
gval
t
emp
=
0
;
unsigned
char
gval
T
emp
=
0
;
unsigned
char
gvalt
[
4
];
...
...
@@ -88,39 +88,39 @@ void message_0()//message_type为0时候要改变的值
switch
(
i
)
{
case
1
:
gvalt
[
0
]
=
gmodeTme
p
;
gvalt
[
0
]
=
gtypeTem
p
;
gvalt
[
1
]
=
1
;
gvalt
[
2
]
=
0
;
printf
(
"g
modeTme
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
typ
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
t
emp:%d
\n
"
,
gvalt
[
2
]);
printf
(
"g
typeTem
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
mod
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
T
emp:%d
\n
"
,
gvalt
[
2
]);
serial_Write
(
gvalt
);
break
;
case
2
:
gvalt
[
0
]
=
gmodeTme
p
;
gvalt
[
0
]
=
gtypeTem
p
;
gvalt
[
1
]
=
2
;
gvalt
[
2
]
=
0
;
printf
(
"g
modeTme
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
typ
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
t
emp:%d
\n
"
,
gvalt
[
2
]);
printf
(
"g
typeTem
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
mod
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
T
emp:%d
\n
"
,
gvalt
[
2
]);
serial_Write
(
gvalt
);
break
;
case
3
:
gvalt
[
0
]
=
gmodeTme
p
;
gvalt
[
0
]
=
gtypeTem
p
;
gvalt
[
1
]
=
3
;
gvalt
[
2
]
=
0
;
printf
(
"g
modeTme
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
typ
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
t
emp:%d
\n
"
,
gvalt
[
2
]);
printf
(
"g
typeTem
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
mod
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
T
emp:%d
\n
"
,
gvalt
[
2
]);
serial_Write
(
gvalt
);
break
;
case
4
:
gvalt
[
0
]
=
gmodeTme
p
;
gvalt
[
0
]
=
gtypeTem
p
;
gvalt
[
1
]
=
4
;
gvalt
[
2
]
=
0
;
printf
(
"g
modeTme
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
typ
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
t
emp:%d
\n
"
,
gvalt
[
2
]);
printf
(
"g
typeTem
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
mod
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
T
emp:%d
\n
"
,
gvalt
[
2
]);
serial_Write
(
gvalt
);
break
;
default:
...
...
@@ -144,17 +144,17 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
cJSON
*
mode
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"mode"
);
//mode=1 速度,mode=2 转向(unsigned char)
cJSON
*
type
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"type"
);
cJSON
*
val
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"val"
);
//val为pwm的值 0~100(unsigned char)(unsigned char)
gmodeT
me
p
=
mode
->
valueint
;
gmodeT
em
p
=
mode
->
valueint
;
gtypeTemp
=
type
->
valueint
;
gval
temp
=
val
->
valueint
/
2
+
30
;
gval
Temp
=
val
->
valueint
*
3
/
4
;
gvalt
[
0
]
=
gtypeTemp
;
gvalt
[
1
]
=
gmodeT
me
p
;
gvalt
[
2
]
=
gval
t
emp
;
gvalt
[
1
]
=
gmodeT
em
p
;
gvalt
[
2
]
=
gval
T
emp
;
gPwmCount
=
0
;
printf
(
"g
modeTme
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
typ
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
t
emp:%d
\n
"
,
gvalt
[
2
]);
printf
(
"g
typeTem
p:%d
\n
"
,
gvalt
[
0
]);
printf
(
"g
mod
eTemp:%d
\n
"
,
gvalt
[
1
]);
printf
(
"gval
T
emp:%d
\n
"
,
gvalt
[
2
]);
serial_Write
(
gvalt
);
}
...
...
@@ -168,13 +168,13 @@ void message_4(cJSON *body, cJSON *pin_setctrl)
cJSON
*
pin
=
cJSON_GetObjectItem
(
pin_setctrl
,
"pin"
);
cJSON
*
val
=
cJSON_GetObjectItem
(
pin_setctrl
,
"val"
);
//val为pwm的值 0~100(unsigned char)(unsigned char)
gpinTemp
=
pin
->
valueint
;
gval
t
emp
=
val
->
valueint
;
gval
T
emp
=
val
->
valueint
;
gPwmCount
=
0
;
gvalt
[
0
]
=
0
;
gvalt
[
1
]
=
gpinTemp
;
gvalt
[
2
]
=
gval
t
emp
;
gvalt
[
2
]
=
gval
T
emp
;
printf
(
"gpinTemp:%d
\n
"
,
gpinTemp
);
printf
(
"gvalTemp:%d
\n
"
,
gval
t
emp
);
printf
(
"gvalTemp:%d
\n
"
,
gval
T
emp
);
serial_Write
(
gvalt
);
}
...
...
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