def execute(self, read_response=True):
<EOL>if self.command != pyhsm.defines.YSM_NULL:<EOL><INDENT>cmd_buf = struct.pack('<STR_LIT>', len(self.payload) + <NUM_LIT:1>, self.command)<EOL><DEDENT>else:<EOL><INDENT>cmd_buf = chr(self.command)<EOL><DEDENT>cmd_buf += self.payload<EOL>debug_info = None<EOL>unlock = self.stick.acquire()<EOL>try:<EOL><INDENT>if self.stick.debug:<EOL><INDENT>debug_info = "<STR_LIT>" % (pyhsm.defines.cmd2str(self.command),len(self.payload), len(self.payload))<EOL><DEDENT>self.stick.write(cmd_buf, debug_info)<EOL>if not read_response:<EOL><INDENT>return None<EOL><DEDENT>return self._read_response()<EOL><DEDENT>finally:<EOL><INDENT>unlock()<EOL><DEDENT>
Write command to HSM and read response.

@param read_response: Whether to expect a response or not.
@type read_response: bool