|
| 1 | +# LLCOM |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +[](https://chenxuuu.visualstudio.com/llcom/_build/latest?definitionId=1&branchName=master) |
| 6 | +[](https://ci.appveyor.com/project/chenxuuu/llcom) |
| 7 | +[](https://github.com/chenxuuu/llcom/blob/master/LICENSE) |
| 8 | +[](https://github.com/chenxuuu/llcom/archive/master.zip) |
| 9 | + |
| 10 | +A serial port debugger tool, with lua script. |
| 11 | + |
| 12 | +> this tools is only Chinese now, you can help me to translate, thanks! |
| 13 | +
|
| 14 | +## Download |
| 15 | + |
| 16 | +Release page stable version: [GitHub](https://github.com/chenxuuu/llcom/releases/latest) |
| 17 | + |
| 18 | +Appveyor snapshot version: [Appveyor Artifacts](https://ci.appveyor.com/project/chenxuuu/llcom/build/artifacts) |
| 19 | + |
| 20 | +## Functions |
| 21 | + |
| 22 | +- Basic functions of serial port debugger tools. |
| 23 | +- The log is clear with two colors, display both HEX values and strings at same time. |
| 24 | +- Auto save serial and lua script logs, with time stamp. |
| 25 | +- Auto reconnect serial port after disconnected. |
| 26 | +- Data you want to send can be processed with your own Lua scripts. |
| 27 | +- Quick send bar on the right. |
| 28 | +- Lua scripts can be run independently with timer and co-process task features.([Based on LUAT TASK](http://wiki.openluat.com/doc/luatFramework/)) |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +## features' exemplary |
| 35 | + |
| 36 | +### Use Lua script process data you want to send |
| 37 | + |
| 38 | +1. end with "\r\n" |
| 39 | + |
| 40 | +```lua |
| 41 | +return uartData.."\r\n" |
| 42 | +``` |
| 43 | + |
| 44 | +2. send HEX values |
| 45 | + |
| 46 | +```lua |
| 47 | +return uartData:fromHex() |
| 48 | +``` |
| 49 | + |
| 50 | +this script can change `30313233` to `0123`. |
| 51 | + |
| 52 | +3. another script example |
| 53 | + |
| 54 | +```lua |
| 55 | +json = require("JSON") |
| 56 | +t = uartData:split(",") |
| 57 | +return JSON:encode({ |
| 58 | + key1 = t[1], |
| 59 | + key2 = t[2], |
| 60 | + key3 = t[3], |
| 61 | +}) |
| 62 | +``` |
| 63 | + |
| 64 | +this script can change `a,b,c` to `{"key1":"a","key2":"b","key3":"c"}`. |
| 65 | + |
| 66 | +**these scripts also work with Quick send bar** |
| 67 | + |
| 68 | +### independent script auto process uart sand and receive |
| 69 | + |
| 70 | +you can run your own Lua script on the right, such as llcom's example: |
| 71 | + |
| 72 | +```lua |
| 73 | +--register serial port receiver function |
| 74 | +uartReceive = function (data) |
| 75 | + log.info("uartReceive",data) |
| 76 | + sys.publish("UART",data)--publish message |
| 77 | +end |
| 78 | + |
| 79 | +--create a task, wait for message |
| 80 | +sys.taskInit(function() |
| 81 | + while true do |
| 82 | + local _,udata = sys.waitUntil("UART")--wait for message |
| 83 | + log.info("task waitUntil",udata) |
| 84 | + local sendResult = apiSendUartData("ok!")--send uart data |
| 85 | + log.info("uart send",sendResult) |
| 86 | + end |
| 87 | +end) |
| 88 | + |
| 89 | +--reate a task, sleep 1000ms and loop |
| 90 | +sys.taskInit(function() |
| 91 | + while true do |
| 92 | + sys.wait(1000)--wait 1000ms |
| 93 | + log.info("task wait",os.time()) |
| 94 | + end |
| 95 | +end) |
| 96 | + |
| 97 | +--1000ms loop timer |
| 98 | +sys.timerLoopStart(log.info,1000,"timer test") |
| 99 | +``` |
| 100 | + |
| 101 | +you alse can use `xlua` to use C# codes |
| 102 | + |
| 103 | +```lua |
| 104 | +request = CS.System.Net.WebRequest.Create("http://example.com") |
| 105 | +request.ContentType = "text/html;charset=UTF-8"; |
| 106 | +request.Timeout = 5000; |
| 107 | +request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Vivaldi/2.2.1388.37"; |
| 108 | + |
| 109 | +response = request:GetResponse():GetResponseStream() |
| 110 | + |
| 111 | +myStreamReader = CS.System.IO.StreamReader(response, CS.System.Text.Encoding.UTF8); |
| 112 | + |
| 113 | +print(myStreamReader:ReadToEnd())--get body |
| 114 | + |
| 115 | +myStreamReader:Close() |
| 116 | +response:Close() |
| 117 | +``` |
| 118 | + |
| 119 | +you can make your debug automatic |
| 120 | + |
| 121 | +## api document (in Chinese) |
| 122 | + |
| 123 | +you can [click here](https://github.com/chenxuuu/llcom/blob/master/LuaApi.md) |
| 124 | + |
| 125 | +## Known bugs and functions to be added |
| 126 | + |
| 127 | +- [ ] bug:SerialPort The Requested Resource is in Use([.net's bug](https://github.com/dotnet/corefx/issues/39464)) |
| 128 | + |
0 commit comments