- Tue Dec 02, 2014 6:20 pm
#3871
I'm still trying to figure out how this works, no clue yet, read the API doc a million times, and have already spent MANY hours on this
Can someone please explain the behavior of this simple testcode and output. Every 5 secs a simple expression is executed with node.input.
Code: Select allfunction s_output(str)
if str then
s=str
end -- if
end -- function
s=""
c="print(3+5)"
tmr.alarm(5000, 1, function()
print("node.output(s_output,1)")
node.output(s_output,1)
node.input(c)
node.output(nil)
print("node.output(nil)")
print("----")
print(s)
print("----")
print("node.output(s_output,0)")
node.output(s_output,0)
node.input(c)
node.output(nil)
print("node.output(nil)")
print("----")
print(s)
print("----")
end) -- tmr.alarm
Output in the console is this, and is repeated every 5 secs.
Code: Select allnode.output(s_output,1)
node.output(nil)
----
----
node.output(s_output,0)
node.output(nil)
----
----
8
My observations:
1. It seems that function s_output is never called,
2. If node.output(s_output,0) is used, the correct result 8 is printed in the console. If node.output(s_output,1) is used, the correct result 8 is NOT printed in the console. The API doc says :serial_debug: 1 output also show in serial. 0: no serial output. That's the opposite from my observations, or is it?
Who can explain the behavior of my code, I'm stuck. I don't mind being told that I made stupid mistakes in my code. Enlighten me!