doc:lua:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
doc:lua:start [2011/06/05 17:46] – admin | doc:lua:start [2011/06/19 19:45] – admin | ||
---|---|---|---|
Line 27: | Line 27: | ||
In the moment the OOBD interface supports two kinds of interfaces for Lua: Some for creating the menus, and some to talk to the serial line (( this is certainly subject to change in the future, when OOBD becomes more generic and the data links become more abstract)) | In the moment the OOBD interface supports two kinds of interfaces for Lua: Some for creating the menus, and some to talk to the serial line (( this is certainly subject to change in the future, when OOBD becomes more generic and the data links become more abstract)) | ||
+ | |||
+ | |||
+ | **Important** To allow it during debugging to replace the hardcoded extended Lua functions against some own debugging code, normally the hardcoded functions are assigned to some Lua variables first, which then are used in the later script: | ||
+ | |||
+ | local serFlush =serFlushCall | ||
+ | serflush() | ||
+ | | ||
+ | | ||
+ | So by naming convention the hardcoded extended functions ends with xxx" | ||
+ | |||
+ | Please keep this in mind while reading this document or writing own code. | ||
Line 122: | Line 133: | ||
- than that Lua function is called, with two parameters: | - than that Lua function is called, with two parameters: | ||
* the actual displayed value of that item | * the actual displayed value of that item | ||
- | * and the id with we gave to that menu item during | + | * and the id with we gave to that menu item during |
- than the called Lua function does something, e.g. a calculation or it starts to generate another submenu | - than the called Lua function does something, e.g. a calculation or it starts to generate another submenu | ||
- when the function is finished, it returns a string value | - when the function is finished, it returns a string value | ||
- that string value is then displayed as new value of the menu item | - that string value is then displayed as new value of the menu item | ||
- | That' | + | That' |
+ | |||
+ | |||
+ | ==== The Communication | ||
+ | |||
+ | OOBD uses (actual) serial communication to talk to the diagnostic device. To allow Lua to send and receive data from the serial port, a few extended Lua functions exists: | ||
+ | |||
+ | === serFlush() === | ||
+ | |||
+ | It just clears the input buffer (from anything which was maybe received in the meantime and which is not needed anymore) | ||
+ | |||
+ | |||
+ | === serWrite(String) === | ||
+ | |||
+ | Sends //String// to the output (which is normally the serial port) | ||
+ | |||
+ | |||
+ | === serSleep(milliseconds) === | ||
+ | |||
+ | waits // | ||
+ | |||
+ | === serReadLn(msTimeout) === | ||
+ | |||
+ | reads from input until a LF (dez. 10 hex 0x0A) appears and returns that input as String | ||
+ | |||
+ | === serWait(OptionString, | ||
+ | |||
+ | In case you want to wait for some input strings, of which several could appear, you fill the // | ||
+ | |||
+ | |||
+ | ==== Miscellaneous | ||
+ | |||
+ | === serDisplayWrite(String) === | ||
+ | |||
+ | |||
+ | Writes //String// to the build in output console. | ||
===== Some Programming Tricks ===== | ===== Some Programming Tricks ===== |