This is my first time using Blender. I have made a CPLD device that can transmit ASCII binary when pressing push buttons. It has been tested to work well on Spyder IDLE using pyserial.
However, whenever I run this simple test to print input from COM4 in Blender (Text.py), it hangs when I press P to run the Blender game.
import serial, bge, bpy ser = serial.Serial() ser.baudrate = 115200 ser.port = "COM4" ser.close() ser.open() def MoveCube(): cont = bge.logic.getCurrentController() obj = cont.owner a = ser.read() if (a != b''): print (a.decode('utf-8')) obj.applyMovement([3,0,0], False) #just a random testing def execute_after_game(scene): ser.close() bpy.app.handlers.game_post.append(execute_after_game)
What is going on? Thanks in advance.