Problem with set multiple targets in python


I have a Micro Maestro and I’m having a problem getting the set multiple targets command to work from within python. I’ve written a class that encapsulates calls to the appropriate control methods as defined in the specifications. All other commands that I’ve written work fine. So, for example, the following method defined in the class sets the acceleration (self.ser is the python serial object I’ve already created):

    def setAcceleration(self, channel, accel):
        """Set the acceleration of this channel.  Value should be between 1 and 255.  A setting of 0 removes the acceleration limit."""

        commandByte = chr(0x89)
        channelByte = chr(channel)
        lowTargetByte = chr(accel)
        highTargetByte = chr(0x00)
        command = commandByte + channelByte + lowTargetByte + highTargetByte

However I’m having difficult getting similar code to work for set multiple targets. The following is the member method that I’ve written and that does not work:

    def setMultipleTargets(self, targetList, startTarget = 0):
        """Set multiple targets in a contiguous block."""

        numTargets = len(targetList)
        commandByte = chr(0x9f)
        numTargetsByte = chr(numTargets)
        startTargetByte = chr(startTarget)
        command = commandByte + numTargetsByte + startTargetByte
        for angle in targetList:
            scaledValue = self.__scaleAngle(angle)
            lowTargetByte = chr(scaledValue & 0x7F)
            highTargetByte = chr((scaledValue >> 7) & 0x7F)
            command += lowTargetByte
            command += highTargetByte


This gives a serial error according to the maestro control center. If I try and write the bytes by hand, I also get a serial error:

p.ser.write(chr(0x9f) + chr(0x02) + chr(0x03) + chr(0x00) + chr(0x00) + chr(0x70) + chr(0x2E))

I should add that I wasn’t able to get it to work with the Pololu protocol either. I have the 1.01 firmware. Is there anything else I should check to figure out what’s going on?

Sorry, the Set Multiple Targets command is only supported on the Mini Maestros, not the Micro Maestro. That’s why you are getting the serial protocol error.


Thanks for pointing that out to me! Guess I didn’t read the docs closely enough as it’s stated right there…my eyes were just going to the hex values…