예제 #1
0
 def _get_error_code(data):
     """Extracts error code from RSTACK or ERROR frames."""
     try:
         code = t.NcpResetCode(data[2])
     except ValueError:
         code = t.NcpResetCode.ERROR_UNKNOWN_EM3XX_ERROR
     return code, data[1]
예제 #2
0
 def error_frame_received(self, data):
     """Error frame receive handler."""
     self._stats_frames_error += 1
     try:
         code = t.NcpResetCode(data[2])
     except ValueError:
         code = t.NcpResetCode.ERROR_UNKNOWN_EM3XX_ERROR
     if code is t.NcpResetCode.ERROR_EXCEEDED_MAXIMUM_ACK_TIMEOUT_COUNT and self._Run_Event.is_set(
     ):
         LOGGER.error("Error (%s), reset connection", code.name)
         self._failed_mode = 1
         self._Run_Event.clear()
         pending, self._pending = self._pending, (-1, None)
         if pending[1]:
             pending[1].set_result(True)
         self._application.restart()
     else:
         LOGGER.debug("Error frame: %s", binascii.hexlify(data))
예제 #3
0
    def rstack_frame_received(self, data):
        """Reset acknowledgement frame receive handler"""
        self._send_seq = 0
        self._rec_seq = 0
        try:
            code = t.NcpResetCode(data[2])
        except ValueError:
            code = t.NcpResetCode.ERROR_UNKNOWN_EM3XX_ERROR

        LOGGER.debug("RSTACK Version: %d Reason: %s frame: %s", data[1],
                     code.name, binascii.hexlify(data))
        # Only handle the frame, if it is a reply to our reset request
        if code is not t.NcpResetCode.RESET_SOFTWARE:
            return

        if self._reset_future is None:
            LOGGER.warn("Reset future is None")
            return

        self._reset_future.set_result(True)
예제 #4
0
파일: uart.py 프로젝트: Yoda-x/bellows
 def _get_error_code(data):
     """Extracts error code from RSTACK or ERROR frames."""
     return t.NcpResetCode(data[2]), data[1]