python - Windows Powershell not quitting script with Ctrl-C -


so running python 3.4 scripts on windows, , when run particular script, have infinite loop (while true:) using, when try quit script ctrl-c, not exiting script. prints keyboard interrupt, if has quit, leaves blinking cursor , not let me type, have exit out red x.

import serial  import time import pyfirmata  #from pyfirmata import arduino, util, pwm  board = pyfirmata.arduino('com4', baudrate = 9600, timeout = 5) time.sleep(2)       #sleep in units of sec  = pyfirmata.util.iterator(board) it.start()   digital1 = board.get_pin('d:5:p') digital2 = board.get_pin('d:6:p') digital3 = board.get_pin('d:10:p') digital4 = board.get_pin('d:11:p')   digital = (digital1, digital2, digital3, digital4)  distobject = 1.5         #start warning @ 4 inches away objects (arbitrary) forcegraspl = 0 forcegraspr = 0 maxforcel = 60       maxforcer = 60 motormaxforcel = maxforcel / 2 motormaxforcer = maxforcer / 2  while true:     left = 0     right = 0            leftmid = 0     rightmid = 0         distperc = 0     motors = (left, right, leftmid, rightmid)       if (distobject != 0 , distobject < 4 , forcegraspl == 0 , forcegraspr == 0):         left = 0.9         distperc = round(distobject / 4.0 * 100)       elif (forcegraspl != 0 or forcegraspr !=0):         if (forcegraspl < motormaxforcel , forcegraspr < motormaxforcer):             left = forcegraspl / motormaxforcel             right = forcegraspr / motormaxforcer              elif (forcegraspl < maxforcel , forcegraspr < motormaxforcer):             left = 1             leftmid = (forcegraspl - motormaxforcel)/ motormaxforcel             right = forcegraspr / motormaxforcer         elif (forcegraspl < motormaxforcel , forcegraspr < maxforcer):             left = forcegraspl / motormaxforcel             right = 1               rightmid = (forcegraspr - motormaxforcer)/ motormaxforcer         elif (forcegraspl < maxforcel , forcegraspr < maxforcer):             left = 1             leftmid = (forcegraspl - motormaxforcel)/ motormaxforcel             right = 1               rightmid = (forcegraspr - motormaxforcer)/ motormaxforcer         else:             left = 1             leftmid = 1             rightmid = 1              right = 1          if (distperc < 100 , distperc > 0):             pin in range(1, length(digital)):                 digital[pin].write(motors(pin))             time.sleep(.5)             pin in range(1, length(digital)):                 digital[pin].write(0)             time.sleep(.5)          else:             pin in range(1, length(digital)):                 digital[pin].write(motors(pin)) 

any suggestions on in script might causing problem appreciated. can tell problem in script because have tried other scripts infinite loops, , ctrl-c works those.

i found answer in problems posted on source webpage:

https://github.com/tino/pyfirmata

it bug lies in original code, code sequence (which left out of above code originally, apologies!):

it = pyfirmata.util.iterator(board) it.start() 

however, can not rid of code otherwise serial buffer overload.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -