I tested this code but it does not work
I do not even happens to read it ... esp probably loop
STX=0x02
ETX=0x03
function ToFile(data)
-- open 'init.lua' in 'a+' mode
file.open("data.txt", "a+")
file.write(data)
file.write('\r')
file.close()
end
function lectureserie()
print("before setup")
uart.setup( 0, 1200, 7, 1, 1 )
print("after setup")
-- when 0x02 is received.
uart.on("data", STX,
function(data)
print("receive from uart:", data)
ToFile(data)
if data==ETX then
uart.on("data")
ToFile(data)
end
end, 0)
end
any idea?
thank you