Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BAUD = 115200
- DATABITS = 8
- PARITY = uart.PARITY_NONE
- STOPBITS = uart.STOPBITS_1
- uart.setup(0, BAUD, DATABITS, PARITY, STOPBITS, 0)
- local message = ""
- sv = net.createServer(net.TCP, 30)
- local function close_connection(c)
- if data == "close" then
- c:close()
- end
- end
- function receiver(sck, data)
- uart.write(0, data)
- if data == "close" then
- sck:close()
- end
- end
- if sv then
- sv:listen(5000, "10.10.10.250", function(conn)
- conn:on("receive", receiver)
- if message ~= "" and message ~= nil then
- conn:send(message, close_connection)
- message = ""
- end
- end)
- end
- uart.on("data", 0, function(data)
- message = data
- uart.write(0, data)
- end, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement