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
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
5b60a38a
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
###version 0.1 2014-10-11
###version 0.1 2014-10-11
###change log:
###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
/>
2014-11-5
<br
/>
delete log operation api from node module
<br
/>
delete log operation api from node module
<br
/>
add log module
<br
/>
add log module
<br
/>
...
@@ -206,17 +211,17 @@ nil
...
@@ -206,17 +211,17 @@ nil
####See also
####See also
**-**
[](
)
**-**
[](
)
#
log
module
#
file
module
<a
id=
"
lg_format
"
></a>
<a
id=
"
fl_remove
"
></a>
##
log.format
()
##
file.remove
()
####Description
####Description
format flash for users
.
remove file from user flash
.
####Syntax
####Syntax
log.format(
)
file.remove(filename
)
####Parameters
####Parameters
nil
filename: file to be removed
####Returns
####Returns
nil
nil
...
@@ -224,29 +229,31 @@ nil
...
@@ -224,29 +229,31 @@ nil
####Example
####Example
```
```
//record log to init.lua. Call the file after system restart.
//remove "foo.lua" from user flash.
log.format()
file.remove("foo.lua")
log.start("init.lua", 1)
print("hello world")
log.stop()
```
```
####See also
####See also
**-**
[
log.start()
](
#lg_start
)
<br
/>
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
log.stop()
](
#lg_stop
)
**-**
[
file.close()
](
#fl_close
)
<a
id=
"
lg_start
"
></a>
<a
id=
"
fl_open
"
></a>
##
log.start
()
##
file.open
()
####Description
####Description
start to log input
open file.
####Syntax
####Syntax
log.start
(filename,
nopars
e)
file.open
(filename,
mod
e)
####Parameters
####Parameters
filename: file to be opened, directories are not supported
<br
/>
filename: log file, directories are not supported
<br
/>
mode:
<br
/>
noparse: 1 for lua VM doesn’t parse input, 0 for lua VM parse input
"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
####Returns
nil
nil
...
@@ -254,25 +261,23 @@ nil
...
@@ -254,25 +261,23 @@ nil
####Example
####Example
```
```
//record log to init.lua. Call the file after system restart.
//open 'init.lua', print the first line.
log.format()
file.open("init.lua", "r")
log.start("init.lua", 1)
print(file.readline())
print("hello world")
file.close()
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
```
```
####See also
####See also
**-**
[
log.format()
](
#lg_format
)
<br
/>
**-**
[
file.close()
](
#fl_close
)
<br
/>
**-**
[
log.stop()
](
#lg_stop
)
**-**
[
file.readline()
](
#fl_readline
)
<a
id=
"
lg_stop
"
></a>
<a
id=
"
fl_close
"
></a>
##
log.stop
()
##
file.close
()
####Description
####Description
stop log
.
close the file
.
####Syntax
####Syntax
log.stop
()
file.close
()
####Parameters
####Parameters
nil
nil
...
@@ -283,55 +288,53 @@ nil
...
@@ -283,55 +288,53 @@ nil
####Example
####Example
```
```
//record log to init.lua. Call the file after system restart.
//open 'init.lua', print the first line.
log.format()
file.open("init.lua", "r")
log.start("init.lua", 1)
print(file.readline())
print("hello world")
file.close()
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
```
```
####See also
####See also
**-**
[
log.format()
](
#lg_format
)
<br
/>
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
log.start()
](
#lg_start
)
**-**
[
file.readline()
](
#fl_readline
)
<a
id=
"
lg_open
"
></a>
<a
id=
"
fl_readline
"
></a>
##
log.open
()
##
file.readline
()
####Description
####Description
open the log file
read one line of file which is opened before line by line.
####Syntax
####Syntax
log.open(filename
)
file.readline(
)
####Parameters
####Parameters
filename: log file, directories are not supported
nil
####Returns
####Returns
nil
file content in string, line by line
####Example
####Example
```
```
//print the first line of 'init.lua'
//print the first line of 'init.lua'
log
.open("init.lua")
file
.open("init.lua"
, "r"
)
print(
log
.readline())
print(
file
.readline())
log
.close()
file
.close()
```
```
####See also
####See also
**-**
[
log.close()
](
#lg_close
)
<br
/>
**-**
[
file.open()
](
#fl_open
)
<br
/>
**-**
[
log.readline()
](
#lg_readlin
e
)
**-**
[
file.close()
](
#fl_clos
e
)
<a
id=
"
lg_clos
e"
></a>
<a
id=
"
fl_writelin
e"
></a>
##
log.clos
e()
##
file.writelin
e()
####Description
####Description
close the log file which opened before
write new line to file with a '
\n
' at the end.
####Syntax
####Syntax
log.close(
)
file.writeline(string
)
####Parameters
####Parameters
n
il
string: content to be write to f
il
e
####Returns
####Returns
nil
nil
...
@@ -339,50 +342,52 @@ nil
...
@@ -339,50 +342,52 @@ nil
####Example
####Example
```
```
//print the first line of 'init.lua'
//open 'init.lua' in 'a+' mode
log.open("init.lua")
file.open("init.lua", "a+")
print(log.readline())
//write 'foo bar' to the end of the file
log.close()
file.writeline('foo bar')
file.close()
```
```
####See also
####See also
**-**
[
log
.open()
](
#l
g
_open
)
<br
/>
**-**
[
file
.open()
](
#
f
l_open
)
<br
/>
**-**
[
log.readline()
](
#lg_readlin
e
)
**-**
[
file.write()
](
#fl_writ
e
)
<a
id=
"
lg_readlin
e"
></a>
<a
id=
"
fl_writ
e"
></a>
##
log.readlin
e()
##
file.writ
e()
####Description
####Description
read log file which is opened before line by lin
e.
write string to fil
e.
####Syntax
####Syntax
log.readline(
)
file.write(string
)
####Parameters
####Parameters
nil
string: content to be write to file.
####Returns
####Returns
log file content in string, line by line
nil
####Example
####Example
```
```
//print the first line of 'init.lua'
//open 'init.lua' in 'a+' mode
log.open("init.lua")
file.open("init.lua", "a+")
print(log.readline())
//write 'foo bar' to the end of the file
log.close()
file.write('foo bar')
file.close()
```
```
####See also
####See also
**-**
[
log
.open()
](
#l
g
_open
)
**-**
[
file
.open()
](
#
f
l_open
)
<br
/>
**-**
[
log.close()
](
#lg_clos
e
)
**-**
[
file.writeline()
](
#fl_writelin
e
)
<a
id=
"l
g
_list"
></a>
<a
id=
"
f
l_list"
></a>
##
log
.list()
##
file
.list()
####Description
####Description
list all files.
list all files.
####Syntax
####Syntax
log
.list()
file
.list()
####Parameters
####Parameters
nil
nil
...
@@ -393,14 +398,14 @@ a lua table which contains the {file name: file size} pairs
...
@@ -393,14 +398,14 @@ a lua table which contains the {file name: file size} pairs
####Example
####Example
```
```
l =
log
.list();
l =
file
.list();
for k,v in l do
for k,v in l do
print("name:"..k..", size:"..v)
print("name:"..k..", size:"..v)
end
end
```
```
####See also
####See also
**-**
[
log.format()
](
#lg_format
)
**-**
[
file.remove()
](
#fl_remove
)
#wifi module
#wifi module
##CONSTANT
##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