Reputation: 8712
I am doing a project in which the program reads values from com port and use it for a game. I am using pyserial for reading from com port.
it works fine, but when i try to print this value in pygame using the following code :
myfont = pygame.font.Font(None, 70)
score=pygame.Rect(1200,100,200,200)
.
.
.
screen.fill((0,0,0))
label = myfont.render(str(SCORE),1,(0,250,0))
screen.blit(label,(1200,100))
pygame.display.update(score)
it gives me the following error
Unhandled exception in thread started by <function brainwave at 0x00000000036A65F8>
Traceback (most recent call last):
File "E:\Project\game\Game.py", line 38, in brainwave
object1.start()
File "C:\Python27\lib\site-packages\NeuroPy\NeuroPy.py", line 76, in start
self.srl=serial.Serial(self.__port,self.__baudRate)
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 31, in __init__
SerialBase.__init__(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\serial\serialutil.py", line 180, in _ __init__
self.open()
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 62, in open
raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM3': WindowsError(121, 'The semaphore timeout period has expired.')
If there is no code for printing(above code) , the values are read fine and the game works, but when i use this code i get this error. Also even if printing code has no relation with reading value from com port , that is it is printing some other value, i get the error. Is this printing code and pyserial somehow related? please help me
ps: if there is any other way to print text in pygame, tell me.
Upvotes: 0
Views: 299