I have an Arduino which sends a JSON packet to a Python process (PP1). This Python process will run continuously. But this process has to invite and receive JSON packets to another Python process (PP2). Basically PP1 has to pass the JSON packet received from Arduino to PP2. And PP1 has to receive commands packets from PP2 (can be in JSON format too).
Link to architecture image:
Bellow a begin the code of Python process 1
import json
#open port
serialport = serial.Serial('COM5',38400,timeout=1,stopbits=serial.STOPBITS_TWO);
time.sleep(1);
#loop
while(True):
#receive arduino data
receive = serialport.readline()
#vparse json
try:
test = json.loads(receive)
except:
print Exception.message
else:
print json.dumps(test)
Do you know a simple way to do this? Is multithreading necessary?