Fix packet length check for valid command with empty data

This commit is contained in:
Ken Roberts 2014-10-14 19:18:00 -07:00
parent 0d5709b8f5
commit cf7756d6c7

View File

@ -172,6 +172,7 @@ class PJLink1(QTcpSocket):
self.fan = None
self.source_available = None
self.source = None
self.other_info = None
if hasattr(self, 'timer'):
self.timer.stop()
@ -217,6 +218,9 @@ class PJLink1(QTcpSocket):
if self.power == S_ON and self.source_available is None:
self.send_command('INST')
self.waitForReadyRead()
if self.other_info is None:
self.send_command('INFO')
self.waitForReadyRead()
if self.manufacturer is None:
self.send_command('INF1')
self.waitForReadyRead()
@ -362,9 +366,9 @@ class PJLink1(QTcpSocket):
self.projectorNetwork.emit(S_NETWORK_RECEIVED)
data_in = decode(read, 'ascii')
data = data_in.strip()
if len(data) < 8:
if len(data) < 7:
# Not enough data for a packet
log.debug('(%s) get_data(): Packet length < 8: "%s"' % (self.ip, data))
log.debug('(%s) get_data(): Packet length < 7: "%s"' % (self.ip, data))
return
log.debug('(%s) Checking new data "%s"' % (self.ip, data))
if data.upper().startswith('PJLINK'):