Script execution
This commit is contained in:
@@ -16,24 +16,28 @@ class RobotTCP(TcpDevice):
|
||||
self.trailer = "\n"
|
||||
self.msg_id = 0
|
||||
|
||||
def sendReceive(self, msg):
|
||||
def call(self, msg):
|
||||
tx = self.header if (self.header != None) else ""
|
||||
id = "%03d" % self.msg_id
|
||||
self.msg_id = (self.msg_id+1)%1000
|
||||
tx = tx + id + " " + msg
|
||||
if (len(tx)>127):
|
||||
raise Exception("Exceeded maximum message size")
|
||||
self.getLogger().finer("TX = " + str(tx))
|
||||
if (self.trailer != None): tx = tx + self.trailer
|
||||
rx = self.sendReceive(tx, None, self.trailer , 0, self.timeout, self.retries).strip()
|
||||
self.getLogger().finer("RX = " + str(rx))
|
||||
if rx[:3] != id:
|
||||
raise Exception("Received invalid message id")
|
||||
return rx[3:]
|
||||
return rx[4:]
|
||||
|
||||
def execute(self, command, *argv):
|
||||
msg = str(command)
|
||||
#if len(argv>10):
|
||||
# raise Exception("Exceeded maximum number of parameters")
|
||||
for arg in argv:
|
||||
msg = msg + "," + str(arg)
|
||||
ret = self.sendReceive(msg)
|
||||
ret = self.call(msg)
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user