Answer the question
In order to leave comments, you need to log in
How to receive data from Serial and give it to the web server?
UART data comes from Arduino to Onion Omega2+ (OpenWRT microcomputer), I need to store data from UART and send it to web server when requested.
Bottle is used as a web framework, since the storage is only 22mb.
Separately, there is no problem to perform these actions, this is how I send data to web clients:
from bottle import route, run
@route('/')
def main():
return "Test"
run(host='0.0.0.0', port=8080, debug=True)
import serial
ser = serial.Serial('/dev/ttyS1', 115200, timeout=0, parity=serial.PARITY_EVEN, bytesize=serial.EIGHTBITS)
while True:
bytesArr = ser.read(5)
if bytesArr:
buffer = bytesArr.decode("ascii", "ignore")
print(buffer) # send this string
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question