|
发表于 2023-1-21 06:36:40
|
显示全部楼层
I spend many time for discove this simple C job in LUA . It needs to "translate" number to letter
- local txt={}
- local a, b
- txt = convert_mb_to_txt(ModbusBaseAddr + GROUP_NAME_OFFSET, ScrBuf)
- if (txt== nil) then txt = "---" end
- set_text(ScreenActual, 5, txt)
复制代码- function convert_mb_to_txt(regAdr, buf)
- local txt= ""
- local i, a
-
- if (buf[regAdr] ==nil or buf[regAdr] == 0) then
- return nil
- end
- -- we need only 9 sign
- for i=0, 9, 1 do
- a= buf[regAdr + i]
- if (a==0) then break end -- value =0 mean that we find text termination.
- a = string.char(buf[regAdr + i])
- txt = txt..a
- end
- return txt
- end
复制代码 If u want to send text then u made similar, but u need to use 'string.byte' |
|