Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiancetai
Project
Project
Details
Activity
Releases
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
陈家乐
jiancetai
Commits
30678992
Commit
30678992
authored
May 26, 2025
by
王佳伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:修改串口
parent
b7ced6a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
31 deletions
+46
-31
Barcode_Scanner.c
YueJin_test_bench/source/Appliciation/Barcode_Scanner.c
+45
-29
Barcode_Scanner.h
YueJin_test_bench/source/Appliciation/Barcode_Scanner.h
+1
-2
No files found.
YueJin_test_bench/source/Appliciation/Barcode_Scanner.c
View file @
30678992
...
...
@@ -48,7 +48,6 @@ uint8_t powerstdio = 0;
uint8_t
get_num_buf
[
34
];
uint8_t
comparestart
;
uint8_t
blename
[
5
];
uint8_t
firstpowerflag
=
0
;
uint16_t
lightnumber
=
0
;
void
get_key
(
void
)
{
...
...
@@ -65,6 +64,18 @@ void datacheck(void)
{
uint8_t
dataopenBuff
[
11
]
=
{
0x07
,
0x36
,
0xAD
,
0x0F
,
0x0F
,
0x11
,
0x01
,
0x02
,
0x03
,
0x04
,
0xE6
};
uint8_t
datacloseBuff
[
11
]
=
{
0x07
,
0x36
,
0x33
,
0x0F
,
0x0F
,
0x11
,
0x01
,
0x02
,
0x03
,
0x04
,
0x6C
};
// if(memcmp(BarCode,dataopenBuff,11) == 0)
// {
// POWER_CTRL_KL15 = 1;
// }
// else
// {
// if(memcmp(BarCode,datacloseBuff,11) == 0)
// {
// POWER_CTRL_KL15 = 0;
// }
// }
memset
(
BarCode
,
0
,
sizeof
(
BarCode
));
}
...
...
@@ -148,10 +159,6 @@ void UART_Put1(uint32_t Value)
// RS485_TX_finish = 0;
// LINE_OUT_NEG_09 = 1;
// RS485_TX_finish = 0;
if
(
firstpowerflag
!=
2
)
{
firstpowerflag
=
1
;
}
return
;
}
...
...
@@ -175,54 +182,63 @@ void UART_Put2(uint32_t Value)
RS485_send_time
=
0
;
return
;
}
#define min(a, b) (((a) < (b)) ? (a) : (b))
void
Recv_Byte
(
void
)
{
int
i
=
0
;
int
j
=
0
;
uint32_t
len
;
uint32_t
len
;
readNum
=
Protocol_UartRead
(
mDataBufPtr
+
mDataBufLen
,
1024
-
mDataBufLen
);
if
(
readNum
>
0
)
if
(
readNum
>
0
)
{
mDataBufLen
+=
readNum
;
while
(
mDataBufLen
)
{
for
(
i
=
0
;
i
<
mDataBufLen
;
i
++
)
// 查找帧头0x07
i
=
0
;
while
(
i
<
mDataBufLen
&&
mDataBufPtr
[
i
]
!=
0x07
)
i
++
;
// 如果没有找到帧头,处理全部剩余数据
if
(
i
>=
mDataBufLen
)
{
len
=
mDataBufLen
;
// 复制数据到BarCode(可选)
memset
(
BarCode
,
0
,
sizeof
(
BarCode
));
memcpy
(
BarCode
,
mDataBufPtr
,
min
(
len
,
sizeof
(
BarCode
)));
}
// 找到帧头但数据不足
else
if
(
i
+
11
>
mDataBufLen
)
{
// 数据不足,等待更多数据
break
;
}
// 找到帧头且数据足够
else
{
if
(
i
>
5
)
// 复制数据,确保不越界
memset
(
BarCode
,
0
,
sizeof
(
BarCode
));
for
(
j
=
0
;
j
<
mDataBufLen
;
j
++
)
{
if
((
mDataBufPtr
[
i
]
==
0x4A
)
&&
(
mDataBufPtr
[
i
+
1
]
==
0x4B
))
{
if
(
i
<
1
)
{
break
;
}
memset
(
BarCode
,
0
,
sizeof
(
BarCode
));
for
(
j
=
0
;
j
<
i
+
1
;
j
++
)
{
BarCode
[
j
]
=
mDataBufPtr
[
j
];
}
break
;
}
BarCode
[
j
]
=
mDataBufPtr
[
i
+
j
];
// 从帧头后一个位置开始复制
}
len
=
11
;
// 处理11个字节(帧头+10字节数据)
}
// 解析协议
len
=
i
+
1
;
if
(
(
len
>
0
)
&&
(
len
<
mDataBufLen
)
)
// 移动剩余数据
if
(
len
>
0
&&
len
<=
mDataBufLen
)
{
memcpy
(
mDataBufPtr
,
mDataBufPtr
+
len
,
mDataBufLen
-
len
);
}
mDataBufLen
-=
len
;
// 处理数据
datacheck
();
}
}
return
;
}
static
uint32_t
Protocol_UartRead
(
uint8_t
*
pData
,
uint32_t
len
)
...
...
YueJin_test_bench/source/Appliciation/Barcode_Scanner.h
View file @
30678992
...
...
@@ -34,7 +34,6 @@ extern uint8_t comparestart;
extern
uint8_t
connectbleFlag
;
extern
uint8_t
get_num_buf
[
34
];
extern
uint8_t
blename
[
5
];
extern
uint8_t
recvflag111
;
extern
uint8_t
firstpowerflag
;
//extern uint8_t recvflag111;
extern
uint16_t
lightnumber
;
#endif
\ 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