我只是从Python和Linux开始。在
我用Python编写了一个通过ttyS0与串行LCD通信的程序,并编写了一个在启动时启动它的脚本。为了防止出现问题,我禁用了inittab中的行“#T0:2345:respawn:/sbin/getty-L ttyS0 115200 vt100”。我得到的是不同的行为,这取决于我如何启动程序。在
我不能使用其他的TTY*因为还有其他设备在使用它们。其他设备工作正常。 我首先尝试像这样使用inittab'null::重生:python/home/python/glv.py“但行为是一样的。在
日志示例:
2014-10-06 13:48:30,407 - __main__ - DEBUG - *****************
2014-10-06 13:48:30,420 - __main__ - DEBUG - *** Start GLV ***
2014-10-06 13:48:30,432 - __main__ - DEBUG - *****************
2014-10-06 13:48:30,444 - lcd - INFO - Initialize
2014-10-06 13:48:35,492 - lcd - ERROR - Didn't receive an answer in ClearScreen
2014-10-06 13:48:38,588 - lcd - ERROR - Didn't receive an answer in SetLandscape
2014-10-06 13:48:41,635 - lcd - ERROR - Didn't receive an answer in SetBackgroundColor
2014-10-06 13:48:44,681 - lcd - ERROR - Didn't receive an answer in SetForegroundColor
2014-10-06 13:48:47,728 - lcd - ERROR - Didn't receive an answer in SetTextBackgroundColor
2014-10-06 13:48:50,791 - lcd - ERROR - Didn't receive an answer in EnableTouchScreen
2014-10-06 13:48:53,837 - lcd - ERROR - Didn't receive an answer in ClearScreen
2014-10-06 13:48:56,884 - lcd - ERROR - Didn't receive an answer in ClearScreen
2014-10-06 13:48:59,931 - lcd - ERROR - Didn't receive an answer in SetForegroundColorGreen
2014-10-06 13:49:02,978 - lcd - ERROR - Didn't receive an answer in SetTextBackgroundColor1
2014-10-06 13:49:06,024 - lcd - ERROR - Didn't receive an answer in preparing WriteTextPos
环境:
^{pr2}$所以,有人知道为什么只有当程序在重启后由脚本启动时,LCD才会出现超时? 我自己想不出来。在
编辑:
例如,设置LCD的背景色:
def SetBackgroundColor(self):
toSend = "\xFF\xA4\x19\xEB"
state, res = self.SendBytesAndWaitResponse(toSend, "\x06", 3)
if(state != 0):
self.logger.error("Didn't receive an answer in SetBackgroundColor")
def SendBytesAndWaitResponse(self, toSend, toWait, timeout):
strres = ""
try:
while(self.lockcomm):
time.sleep(0.1)
self.lockcomm = True
start_time = time.time()
end_time = start_time + timeout
self.ser.write(toSend)
while True:
cur_time = time.time()
if cur_time >= end_time:
return (-1, strres)
else:
result = self.ser.read()
strres += result
if(strres.find(toWait) != -1):
return (0, strres)
except:
return (-1, strres)
finally:
self.lockcomm = False
我发送4个字节的字符,并将超时设置为3秒(这太多了),但在这3秒钟内,我从来没有得到LCD上实现的响应(char 0x06)。在
目前没有回答
相关问题 更多 >
编程相关推荐