diff --git a/utils/macmaster.py b/utils/macmaster.py old mode 100644 new mode 100755 index 0ebac3a..f625a37 --- a/utils/macmaster.py +++ b/utils/macmaster.py @@ -24,7 +24,7 @@ class MasterMACS(): def receive(self): buf = self._socke.recv(35, socket.MSG_WAITALL) if len(buf) < 35: - raise EOFException('Master MACS returned only %d bytes, 30 expected' % len(buf)) + raise EOFException('Master MACS returned only %d bytes, 35 expected' % len(buf)) idx = buf.find(0x0D) ackbyte = buf[idx-1] if ackbyte == 0x06: diff --git a/utils/syncMasterMAC.py b/utils/syncMasterMAC.py index 3e27a9b..3f35e38 100755 --- a/utils/syncMasterMAC.py +++ b/utils/syncMasterMAC.py @@ -6,6 +6,7 @@ from a MasterMAC motor controller. Mark Koennecke, February 2023 """ import sys +import time from macmaster import MasterMACS @@ -33,6 +34,7 @@ def pretty_line(newlist, comma_list): def transact(command): global mac mac.send(command) + time.sleep(.1) return mac.receive() def fix_line(par_list, index_list): @@ -40,18 +42,23 @@ def fix_line(par_list, index_list): addridx = index_list.index('ADDR') motNo = int(par_list[addridx]) ack, reply = transact('%dR24' % motNo) - idx = reply.find('=') - lowlim = reply[idx+1:] - lowidx = index_list.index('DLLM') - par_list[lowidx] = lowlim.strip() + if ack == 'NO': + idx = reply.find('=') + lowlim = reply[idx+1:] + lowidx = index_list.index('DLLM') + par_list[lowidx] = lowlim.strip() ack, reply = transact('%dR23' % motNo) - idx = reply.find('=') - highlim = reply[idx+1:] - highidx = index_list.index('DHLM') - par_list[highidx] = highlim.strip() - # speed = transact('Q%d03' % motNo) - # speedidx = index_list['VELO'] - # par_list[speedidx] = speed.trim() + if ack == 'NO': + idx = reply.find('=') + highlim = reply[idx+1:] + highidx = index_list.index('DHLM') + par_list[highidx] = highlim.strip() + ack, reply = transact('%dR05' % motNo) + if ack == 'NO': + idx = reply.find('=') + speed = reply[idx+1:] + speedidx = index_list.index('VELO') + par_list[speedidx] = speed.strip() return par_list def scan_substitution_file(filename):