User Tools

Site Tools


doc:lua_make-your-own-scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
doc:lua_make-your-own-scripts [2014/05/31 11:39] – [Miscellaneous Commands] admindoc:lua_make-your-own-scripts [2014/08/17 12:53] – [The Communication Commands] admin
Line 137: Line 137:
  
 ==== The Communication  Commands ==== ==== The Communication  Commands ====
 +
  
 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: 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() === === serFlush() ===
 +
  
 It just clears the input buffer (from anything which was maybe received in the meantime and which is not needed anymore) It just clears the input buffer (from anything which was maybe received in the meantime and which is not needed anymore)
Line 146: Line 149:
  
 === serWrite(String) === === serWrite(String) ===
- 
-Sends //String// to the output (which is normally the serial port) 
  
  
 +Sends //String// to the output (which is normally the serial port)
 === serSleep(milliseconds) === === serSleep(milliseconds) ===
  
-waits //milliseconds// 
  
 +waits //milliseconds// 
 === serReadLn(msTimeout) === === serReadLn(msTimeout) ===
 +
  
 reads from input until a LF (dez. 10 hex 0x0A) appears and returns that input as String reads from input until a LF (dez. 10 hex 0x0A) appears and returns that input as String
 +
  
 === serWait(OptionString, msTimeout) === === serWait(OptionString, msTimeout) ===
 +
  
 In case you want to wait for some input strings, of which several could appear, you fill the //Optionstring// with string1|string2|..|stringN. If then one of this string appears at the input, the index of the found string is returned (first string=1). If the string does not appear within //msTimeout//, the function returns 0. In case you want to wait for some input strings, of which several could appear, you fill the //Optionstring// with string1|string2|..|stringN. If then one of this string appears at the input, the index of the found string is returned (first string=1). If the string does not appear within //msTimeout//, the function returns 0.
 +
 +
 +==== The IO  Commands ====
 +
 +FIXME the whole IO section is in pure experimental state. There's no guarantee that these functions are even exist, are implemented as described or not subject to change.
 +
 +
 +OOBD uses its own scheme for file IO, mainly driven by the restriction of a remote user and the need of complex data buffer handling.
 +
 +Similar to the LUA simple IO model, OOBD has always only just input and output file handle. As long as not redirected, these are stdin and stdout.
 +
 +As OOBD knows more as only one type of data sources, filenames are given as URL, not just as simple path.
 +
 +
 +
 +
 +=== ioInput(URL[,file_extension[,message]]) ===
 +
 +Set the actual input file stream to URL, where URL could be
 +
 +^  URL  ^  Description  ^
 +| ''FILE:<nowiki>//</nowiki>'' | Opens a file in the users file system. If the given file path is empty, just a directory or the given file does not exist, a file dialog opens. If given, the message and file_extension are used in the dialog |
 +| ''SCRIPT:<nowiki>//</nowiki>''| Opens a file in the script archive file system.  |
 +
 +
 +=== ioRead("*line") ===
 +Read one line of the input file ending with either \r\n or \n as string without the EOL. In case of input EOF or read errors the function returns nil
 +
 +=== ioRead ("*all") ===
 +Read the whole file as string
 +
 +=== ioRead (count) ===
 +Read count number of bytes as string
 +
 +=== ioOutput(URL[,append[,message]]) ===
 +
 +Try to opens ''URL'' as output. A ''SCRIPT:<nowiki>//</nowiki>'' URL is readonly and so not allowed as output. If append is TRUE, the output is appended to an already existing file. If the given file path is empty or just a directory, a file dialog opens. If given, the message is used in the dialog as title
 +
 +=== ioWrite (String) ===
 +Attaches the string content to the output file
  
  
doc/lua_make-your-own-scripts.txt · Last modified: 2019/04/08 18:43 by admin