コード例 #1
0
    def send(self, opcode, opType, motor, value, moduleID=None):
        """
        Send a TMCL datagram and read back a reply. This function blocks until
        the reply has been received
        """
        if not (type(opcode) == type(opType) == type(motor) == type(value) ==
                int):
            raise TypeError("Expected integer values")

        # If no module ID is given, use the default one
        if not moduleID:
            moduleID = self._MODULE_ID

        request = TMCL_Request(moduleID, opcode, opType, motor, value)

        if self._debug:
            request.dump()

        # Send the request
        self._send(self._HOST_ID, moduleID, request.toBuffer())

        # Read out the reply
        reply = TMCL_Reply(self._recv(self._HOST_ID, moduleID))

        if self._debug:
            reply.dump()

        return reply
コード例 #2
0
ファイル: tmcl_interface.py プロジェクト: dnmiller/PyTrinamic
    def sendBoot(self, moduleID=None):
        """
        Send the command for entering bootloader mode. This TMCL command does
        result in a reply.
        """
        # If no module ID is given, use the default one
        if not moduleID:
            moduleID = self._MODULE_ID

        request = TMCL_Request(moduleID, TMCL_Command.BOOT, 0x81, 0x92, 0xA3B4C5D6)

        if self._debug:
            request.dump()

        # Send the request
        self._send(self._HOST_ID, moduleID, request.toBuffer())
コード例 #3
0
    def send ( self, address, command, commandType, motorbank, value ):
        """
        Send a message to the specified module. This is a blocking function that
        will not return until a reply has been received from the module. 
        """
       
        "prepare TMCL request"
        request = TMCL_Request(address, command, commandType, motorbank, value)
        
        if self.debugEnabled:
            request.dump()
        
        "send request, wait, and handle reply"
        self.serial.write(request.toBuffer())
        reply = TMCL_Reply(struct.unpack(TMCL.PACKAGE_STRUCTURE, self.serial.read(TMCL.PACKAGE_LENGTH)))
        
        if self.debugEnabled:
            reply.dump()

        return reply