while "forever":
# get a line message form blender output
text = input()
if text[0:5]=='NIRPS':
# if message starts with NIRPS, its ours
text = text[6:]
if text[0:4] == 'SAVE':
# just save data without processing
doSave(x, y, cx, cy, calCx, calCy, filename)
elif text[0:4] == 'FILE':
# set filename to save
filename = text[5:]
elif text[0:5] == 'PRINT':
doPrint(x, y, LIMx, LIMy, cx, cy, calCx, calCy)
elif text[0:4] == 'PROC':
# Save data to Matlab
doSaveData()
# process light hits to find center
doProcess(x, y, cx, cy, N, data, LIMx, LIMy)
# save centers
doSaveCxCy()
elif text[0:3] == 'CAL':
# perform calibration
doCalibrate(calCx, calCy, cx, cy, LIMx, LIMy)
else:
# if starts with NIRPS but its just numbers, append to data (they are light hits)
data.append(list(map(float, text.split(','))))
else:
# ignore blender normal console output
print('[ignored]: '+text)