Updated the sync utilities

This commit is contained in:
2024-05-23 16:00:32 +02:00
parent 32a8c27dbf
commit d9d6dae19f
2 changed files with 19 additions and 12 deletions

2
utils/macmaster.py Normal file → Executable file
View File

@ -24,7 +24,7 @@ class MasterMACS():
def receive(self): def receive(self):
buf = self._socke.recv(35, socket.MSG_WAITALL) buf = self._socke.recv(35, socket.MSG_WAITALL)
if len(buf) < 35: 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) idx = buf.find(0x0D)
ackbyte = buf[idx-1] ackbyte = buf[idx-1]
if ackbyte == 0x06: if ackbyte == 0x06:

View File

@ -6,6 +6,7 @@ from a MasterMAC motor controller.
Mark Koennecke, February 2023 Mark Koennecke, February 2023
""" """
import sys import sys
import time
from macmaster import MasterMACS from macmaster import MasterMACS
@ -33,6 +34,7 @@ def pretty_line(newlist, comma_list):
def transact(command): def transact(command):
global mac global mac
mac.send(command) mac.send(command)
time.sleep(.1)
return mac.receive() return mac.receive()
def fix_line(par_list, index_list): def fix_line(par_list, index_list):
@ -40,18 +42,23 @@ def fix_line(par_list, index_list):
addridx = index_list.index('ADDR') addridx = index_list.index('ADDR')
motNo = int(par_list[addridx]) motNo = int(par_list[addridx])
ack, reply = transact('%dR24' % motNo) ack, reply = transact('%dR24' % motNo)
if ack == 'NO':
idx = reply.find('=') idx = reply.find('=')
lowlim = reply[idx+1:] lowlim = reply[idx+1:]
lowidx = index_list.index('DLLM') lowidx = index_list.index('DLLM')
par_list[lowidx] = lowlim.strip() par_list[lowidx] = lowlim.strip()
ack, reply = transact('%dR23' % motNo) ack, reply = transact('%dR23' % motNo)
if ack == 'NO':
idx = reply.find('=') idx = reply.find('=')
highlim = reply[idx+1:] highlim = reply[idx+1:]
highidx = index_list.index('DHLM') highidx = index_list.index('DHLM')
par_list[highidx] = highlim.strip() par_list[highidx] = highlim.strip()
# speed = transact('Q%d03' % motNo) ack, reply = transact('%dR05' % motNo)
# speedidx = index_list['VELO'] if ack == 'NO':
# par_list[speedidx] = speed.trim() idx = reply.find('=')
speed = reply[idx+1:]
speedidx = index_list.index('VELO')
par_list[speedidx] = speed.strip()
return par_list return par_list
def scan_substitution_file(filename): def scan_substitution_file(filename):