怎么搭建开发环境? #163
Unanswered
camoon0618
asked this question in
问答 Q&A
怎么搭建开发环境?
#163
Replies: 2 comments
-
1. 用2022
2. 未按模板填写
…---原始邮件---
发件人: ***@***.***>
发送时间: 2024年5月6日(周一) 上午8:10
收件人: ***@***.***>;
抄送: ***@***.***>;
主题: [chenxuuu/llcom] 怎么搭建开发环境? (Discussion #163)
1.请问怎么搭建开发环境? 我下载了VS2017,并导入了解决方案,但是编译时出现了非常多的错误。
2.在使用这个工具时,当使用50ms发送串口数据时,就很容易卡死(我测试了window自带的串口调试助手,10ms发送接收不会卡顿,是否和选择的这种解释性语言有关?)。考虑可能时Log写入时,比较耗费时间,我想关闭log, 或者只输出我希望的log, 但是这个log似乎是强制, 系统的Log会存储,并且可以看到即存储了HEX格式的收发数据,也存储了str格式的数据。
我测试用代码如下:
LOG_SILENT = LOGLEVEL_INFO -- 不起作用
-- 用于存储接收到的串口数据
local uartBuffer = ""
-- 定义一个函数实现 XOR 操作
local function xor(a, b)
-- 使用按位取反和按位与来实现 XOR
return (a | b) & ~(a & b)
end
-- 串口数据接收回调函数
local function uartDataCallback(data)
uartBuffer = uartBuffer .. data
::uartloop::
--print("uartBuffer len",#uartBuffer)
while #uartBuffer >= 6 do
if uartBuffer:byte(1) ~= 0xFE then -- 不等于
uartBuffer = uartBuffer:sub(2) -- 2是子串其实位置
--print("uartBuffer len",#uartBuffer)
goto uartloop
else
-- 解析长度字段
local len = uartBuffer:byte(3) * 256 + uartBuffer:byte(2)
-- 检查缓冲区是否包含完整的数据包
if #uartBuffer >= 6 + len then -- 提取完整的数据包 local packet = uartBuffer:sub(1, 6 + len) -- 从第二个字节开始计算XOR校验和 local calcXor = 0 for i = 2, #packet-1 do calcXor = xor(calcXor, packet:byte(i)) end -- 检查校验和 if calcXor == packet:byte(#packet) then print("接收到有效数据包:", packet:sub(5,-2):toHex(" ")) else print("数据包校验和错误") end -- 移除已处理的数据 uartBuffer = uartBuffer:sub(6 + len + 1) else return -- 继续接收 end end end
end
-- uart,对应软件自身的串口功能
apiSetCb("uart",function (data)
--log.info("uart received",data)
--sys.publish("UART_RECEIVE", data)
uartDataCallback(data)
--strSend = ("FE 01 00 7A 49 00 32"):fromHex()
--apiSend("uart",strSend)
end)
local sendList = {
{1,100},
{3,500},
{2,2000},
{4,300},
{5,6000},
{6,1500},
}
sys.taskInit(function ()
while true do
for _,i in pairs(sendList) do
local data = apiQuickSendList(i[1])
if data then
--log.info("send data",apiSendUartData(data),data)
apiSendUartData(data)
sys.wait(i[2])
end
end
end
end)
系统记录的log:
2024-05-05 22:09:09.191 +08:00 [INF] [SRART]Logs by LLCOM. https://github.com/chenxuuu/llcom
2024-05-05 22:09:09.206 +08:00 [DBG] [openPort]False,XDS110 Class Application/User UART (COM47)
2024-05-05 22:09:09.206 +08:00 [DBG] [openPort]GetPortNames
2024-05-05 22:09:09.207 +08:00 [DBG] [openPort]GetPortNames11
2024-05-05 22:09:09.207 +08:00 [DBG] [openPort]PortName:COM47,isOpeningPort:False
2024-05-05 22:09:09.208 +08:00 [DBG] [openPort]SetName
2024-05-05 22:09:09.208 +08:00 [DBG] [openPort]open
2024-05-05 22:09:09.209 +08:00 [DBG] [UartOpen]refreshSerialDevice
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]start
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]lastPortBaseStream.Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]BaseStream.Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]new
2024-05-05 22:09:09.211 +08:00 [DBG] [refreshSerialDevice]done
2024-05-05 22:09:09.211 +08:00 [DBG] [UartOpen]open
2024-05-05 22:09:09.213 +08:00 [DBG] [UartOpen]done
2024-05-05 22:09:09.213 +08:00 [DBG] [openPort]change show
2024-05-05 22:09:09.217 +08:00 [DBG] [openPort]check to send
2024-05-05 22:09:09.332 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.332 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.392 +08:00 [INF] ->�␁␀zI␀2
2024-05-05 22:09:09.392 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.398 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.398 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.398 +08:00 [DBG] [openPort]done
2024-05-05 22:09:09.398 +08:00 [DBG] [openPort]all done
2024-05-05 22:09:09.438 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.438 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.470 +08:00 [INF] ->�␁␀zI␀2�␁␀zI␀2
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
log并不耗时,最耗时的是显示发送和接收的数据数据这个动作,每次刷新ui最耗时 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
1.请问怎么搭建开发环境? 我下载了VS2017,并导入了解决方案,但是编译时出现了非常多的错误。
2.在使用这个工具时,当使用50ms发送串口数据时,就很容易卡死(我测试了window自带的串口调试助手,10ms发送接收不会卡顿,是否和选择的这种解释性语言有关?)。考虑可能时Log写入时,比较耗费时间,我想关闭log, 或者只输出我希望的log, 但是这个log似乎是强制, 系统的Log会存储,并且可以看到即存储了HEX格式的收发数据,也存储了str格式的数据。
我测试用代码如下:
LOG_SILENT = LOGLEVEL_INFO -- 不起作用
-- 用于存储接收到的串口数据
local uartBuffer = ""
-- 定义一个函数实现 XOR 操作
local function xor(a, b)
-- 使用按位取反和按位与来实现 XOR
return (a | b) & ~(a & b)
end
-- 串口数据接收回调函数
local function uartDataCallback(data)
uartBuffer = uartBuffer .. data
::uartloop::
--print("uartBuffer len",#uartBuffer)
while #uartBuffer >= 6 do
if uartBuffer:byte(1) ~= 0xFE then -- 不等于
uartBuffer = uartBuffer:sub(2) -- 2是子串其实位置
--print("uartBuffer len",#uartBuffer)
goto uartloop
else
-- 解析长度字段
local len = uartBuffer:byte(3) * 256 + uartBuffer:byte(2)
-- 检查缓冲区是否包含完整的数据包
end
-- uart,对应软件自身的串口功能
apiSetCb("uart",function (data)
--log.info("uart received",data)
--sys.publish("UART_RECEIVE", data)
uartDataCallback(data)
--strSend = ("FE 01 00 7A 49 00 32"):fromHex()
--apiSend("uart",strSend)
end)
local sendList = {
{1,100},
{3,500},
{2,2000},
{4,300},
{5,6000},
{6,1500},
}
sys.taskInit(function ()
while true do
for _,i in pairs(sendList) do
local data = apiQuickSendList(i[1])
if data then
--log.info("send data",apiSendUartData(data),data)
apiSendUartData(data)
sys.wait(i[2])
end
end
end
end)
系统记录的log:
2024-05-05 22:09:09.191 +08:00 [INF] [SRART]Logs by LLCOM. https://github.com/chenxuuu/llcom
2024-05-05 22:09:09.206 +08:00 [DBG] [openPort]False,XDS110 Class Application/User UART (COM47)
2024-05-05 22:09:09.206 +08:00 [DBG] [openPort]GetPortNames
2024-05-05 22:09:09.207 +08:00 [DBG] [openPort]GetPortNames11
2024-05-05 22:09:09.207 +08:00 [DBG] [openPort]PortName:COM47,isOpeningPort:False
2024-05-05 22:09:09.208 +08:00 [DBG] [openPort]SetName
2024-05-05 22:09:09.208 +08:00 [DBG] [openPort]open
2024-05-05 22:09:09.209 +08:00 [DBG] [UartOpen]refreshSerialDevice
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]start
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]lastPortBaseStream.Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]BaseStream.Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]Dispose
2024-05-05 22:09:09.210 +08:00 [DBG] [refreshSerialDevice]new
2024-05-05 22:09:09.211 +08:00 [DBG] [refreshSerialDevice]done
2024-05-05 22:09:09.211 +08:00 [DBG] [UartOpen]open
2024-05-05 22:09:09.213 +08:00 [DBG] [UartOpen]done
2024-05-05 22:09:09.213 +08:00 [DBG] [openPort]change show
2024-05-05 22:09:09.217 +08:00 [DBG] [openPort]check to send
2024-05-05 22:09:09.332 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.332 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.392 +08:00 [INF] ->�␁␀zI␀2
2024-05-05 22:09:09.392 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.398 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.398 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.398 +08:00 [DBG] [openPort]done
2024-05-05 22:09:09.398 +08:00 [DBG] [openPort]all done
2024-05-05 22:09:09.438 +08:00 [INF] <-�␁␀zI␀2
2024-05-05 22:09:09.438 +08:00 [DBG] [HEX]FE 01 00 7A 49 00 32
2024-05-05 22:09:09.470 +08:00 [INF] ->�␁␀zI␀2�␁␀zI␀2
Beta Was this translation helpful? Give feedback.
All reactions