我有一些python代码,它读取电机的端口,当端口从closed(9)切换到open(8)时,while循环应该退出。然而,我发现while循环似乎被卡住了,尽管上面的情况发生了变化。在
下面是代码和输出。在self.send(param, iostatus,'move', 'e', '-1000') # move mirror above home switch
self.send(param, iostatus,'move', 'a', '-1000') # move mirror west of home switch
sleep(4)
print int(self.send(param, iostatus,'portread', 'e'))
print int(self.send(param, iostatus,'portread', 'a'))
while int(self.send(param, iostatus,'portread', 'e')) \
or int(self.send(param, iostatus,'portread', 'a')) == 9:
if int(self.send(param, iostatus,'portread', 'e')) == 8:
self.send(param, iostatus,'stop', 'e') #stop motor moving
if int(self.send(param, iostatus,'portread', 'a')) == 8:
self.send(param, iostatus,'stop', 'a') #stop motor moving
altt = int(self.send(param, iostatus,'portread', 'e'))
azt= int(self.send(param, iostatus,'portread', 'a'))
print 'altt', altt, 'of type', type(altt), altt==9
print 'azt', azt, 'of type', type(azt), azt==9
sleep(3)
终端输出:(注意,我必须将输出隔开,这样它就不会在本文中出现)
140815-13:03:03发送指令为aA
140815-13:03:03发送指令为eA
140815-13:03:03发送指令为eF1000 1
140815-13:03:04发送指令为aF1000 1
在140815-13:03:06发送指令是e^
等待回家
……为清晰起见,请删去文本
在140815-13:03:21发送指令是e^
在140815-13:03:21发送的指令是
140815-13:03:21发送指令为eM-1000
140815-13:03:21发送指令为aM-1000
140815-13:03:25发送指令为eA
9
140815-13:03:25发送指令为aA
9
140815-13:03:25发送指令为eA
140815-13:03:25发送指令为eA
140815-13:03:25发送指令为aA
140815-13:03:25发送指令为eA
140815-13:03:25发送指令为aA
备降9型真
类型为True的azt 9
……为清晰起见,请删去文本
140815-13:03:57发送指令为eA
140815-13:03:57发送指令为eA
140815-13:03:57发送指令为aA
140815-13:03:58发送指令为eA
发送指令至is 14003:815
备降9型真
类型为True的azt 9
140815-13:04:01发送指令为eA
140815-13:04:01发送指令为eA
140815-13:04:01发送指令为e@
140815-13:04:01发送指令为aA
140815-13:04:01发送指令是@
140815-13:04:01发送指令为eA
140815-13:04:01发送指令为aA
备降场8假
错误类型azt 8
发送指令至eA:815:04
140815-13:04:04发送指令为eA
140815-13:04:04发送指令为e@
140815-13:04:04发送指令为aA
140815-13:04:04发送指令是一个@
140815-13:04:04发送指令为eA
140815-13:04:04发送指令为aA
备降场8假
错误类型azt 8
140815-13:04:07发送指令为eA
140815-13:04:07发送指令为eA
140815-13:04:07发送指令为e@
140815-13:04:07发送指令为aA
140815-13:04:07发送指令是@
140815-13:04:07发送指令为eA
140815-13:04:07发送指令为aA
备降场8假
错误类型azt 8
……并且循环将继续这样,即使这两个端口检查==8并且都是false。在
基本上,我在移动一些马达,等待它们的端口(主交换机)读取8(打开)。当它们打开时,我停止马达,回路应该会退出。但是,循环卡在端口读取检查内部。在
你可以看到下面终端输出的底部
备降场8假
错误类型azt 8
是我读到的,它们都说false,但是while循环继续运行,好像其中一个是真的。在
有什么想法吗?我一直盯着它看,也许我没看清。在
干杯