Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
5b60a38a
Commit
5b60a38a
authored
Nov 10, 2014
by
funshine
Browse files
modify readme
parent
3a2797c2
Changes
1
Show whitespace changes
Inline
Side-by-side
README.md
View file @
5b60a38a
...
...
@@ -2,6 +2,11 @@
###version 0.1 2014-10-11
###change log:
2014-11-10
<br
/>
change log module to file module
<br
/>
now file operation support multiple read/write
<br
/>
for now file module only allowed one file opened
<br
/>
2014-11-5
<br
/>
delete log operation api from node module
<br
/>
add log module
<br
/>
...
...
@@ -206,17 +211,17 @@ nil
####See also
**-**
[](
)
#
log
module
<a
id=
"
lg_format
"
></a>
##
log.format
()
#
file
module
<a
id=
"
fl_remove
"
></a>
##
file.remove
()
####Description
format flash for users
.
remove file from user flash
.
####Syntax
log.format(
)
file.remove(filename
)
####Parameters
nil
filename: file to be removed
####Returns
nil
...
...
@@ -224,29 +229,31 @@ nil
####Example
```
//record log to init.lua. Call the file after system restart.
log.format()
log.start("init.lua", 1)
print("hello world")
log.stop()
//remove "foo.lua" from user flash.
file.remove("foo.lua")
```
####See also
**-**
[
log.start()
](
#lg_start
)
<br
/>
**-**
[
log.stop()
](
#lg_stop
)
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
file.close()
](
#fl_close
)
<a
id=
"
lg_start
"
></a>
##
log.start
()
<a
id=
"
fl_open
"
></a>
##
file.open
()
####Description
start to log input
open file.
####Syntax
log.start
(filename,
nopars
e)
file.open
(filename,
mod
e)
####Parameters
filename: log file, directories are not supported
<br
/>
noparse: 1 for lua VM doesn’t parse input, 0 for lua VM parse input
filename: file to be opened, directories are not supported
<br
/>
mode:
<br
/>
"r": read mode (the default)
<br
/>
"w": write mode
<br
/>
"a": append mode
<br
/>
"r+": update mode, all previous data is preserved
<br
/>
"w+": update mode, all previous data is erased
<br
/>
"a+": append update mode, previous data is preserved, writing is only allowed at the end of file
####Returns
nil
...
...
@@ -254,25 +261,23 @@ nil
####Example
```
//record log to init.lua. Call the file after system restart.
log.format()
log.start("init.lua", 1)
print("hello world")
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
//open 'init.lua', print the first line.
file.open("init.lua", "r")
print(file.readline())
file.close()
```
####See also
**-**
[
log.format()
](
#lg_format
)
<br
/>
**-**
[
log.stop()
](
#lg_stop
)
**-**
[
file.close()
](
#fl_close
)
<br
/>
**-**
[
file.readline()
](
#fl_readline
)
<a
id=
"
lg_stop
"
></a>
##
log.stop
()
<a
id=
"
fl_close
"
></a>
##
file.close
()
####Description
stop log
.
close the file
.
####Syntax
log.stop
()
file.close
()
####Parameters
nil
...
...
@@ -283,55 +288,53 @@ nil
####Example
```
//record log to init.lua. Call the file after system restart.
log.format()
log.start("init.lua", 1)
print("hello world")
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
//open 'init.lua', print the first line.
file.open("init.lua", "r")
print(file.readline())
file.close()
```
####See also
**-**
[
log.format()
](
#lg_format
)
<br
/>
**-**
[
log.start()
](
#lg_start
)
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
file.readline()
](
#fl_readline
)
<a
id=
"
lg_open
"
></a>
##
log.open
()
<a
id=
"
fl_readline
"
></a>
##
file.readline
()
####Description
open the log file
read one line of file which is opened before line by line.
####Syntax
log.open(filename
)
file.readline(
)
####Parameters
filename: log file, directories are not supported
nil
####Returns
nil
file content in string, line by line
####Example
```
//print the first line of 'init.lua'
log
.open("init.lua")
print(
log
.readline())
log
.close()
file
.open("init.lua"
, "r"
)
print(
file
.readline())
file
.close()
```
####See also
**-**
[
log.close()
](
#lg_close
)
<br
/>
**-**
[
log.readline()
](
#lg_readlin
e
)
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
file.close()
](
#fl_clos
e
)
<a
id=
"
lg_clos
e"
></a>
##
log.clos
e()
<a
id=
"
fl_writelin
e"
></a>
##
file.writelin
e()
####Description
close the log file which opened before
write new line to file with a '
\n
' at the end.
####Syntax
log.close(
)
file.writeline(string
)
####Parameters
n
il
string: content to be write to f
il
e
####Returns
nil
...
...
@@ -339,50 +342,52 @@ nil
####Example
```
//print the first line of 'init.lua'
log.open("init.lua")
print(log.readline())
log.close()
//open 'init.lua' in 'a+' mode
file.open("init.lua", "a+")
//write 'foo bar' to the end of the file
file.writeline('foo bar')
file.close()
```
####See also
**-**
[
log
.open()
](
#l
g
_open
)
<br
/>
**-**
[
log.readline()
](
#lg_readlin
e
)
**-**
[
file
.open()
](
#
f
l_open
)
<br
/>
**-**
[
file.write()
](
#fl_writ
e
)
<a
id=
"
lg_readlin
e"
></a>
##
log.readlin
e()
<a
id=
"
fl_writ
e"
></a>
##
file.writ
e()
####Description
read log file which is opened before line by lin
e.
write string to fil
e.
####Syntax
log.readline(
)
file.write(string
)
####Parameters
nil
string: content to be write to file.
####Returns
log file content in string, line by line
nil
####Example
```
//print the first line of 'init.lua'
log.open("init.lua")
print(log.readline())
log.close()
//open 'init.lua' in 'a+' mode
file.open("init.lua", "a+")
//write 'foo bar' to the end of the file
file.write('foo bar')
file.close()
```
####See also
**-**
[
log
.open()
](
#l
g
_open
)
**-**
[
log.close()
](
#lg_clos
e
)
**-**
[
file
.open()
](
#
f
l_open
)
<br
/>
**-**
[
file.writeline()
](
#fl_writelin
e
)
<a
id=
"l
g
_list"
></a>
##
log
.list()
<a
id=
"
f
l_list"
></a>
##
file
.list()
####Description
list all files.
####Syntax
log
.list()
file
.list()
####Parameters
nil
...
...
@@ -393,14 +398,14 @@ a lua table which contains the {file name: file size} pairs
####Example
```
l =
log
.list();
l =
file
.list();
for k,v in l do
print("name:"..k..", size:"..v)
end
```
####See also
**-**
[
log.format()
](
#lg_format
)
**-**
[
file.remove()
](
#fl_remove
)
#wifi module
##CONSTANT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment