(self, data: str, retries: int = 0)
Send data and return the response.

        Args:
            data: The data to send.
            retries: number of times to retry in case of timeout

        Returns: The command response

        Raises: SerialException
Send data and return the response.
Send data and return the response .
async def _send_data(self, data: str, retries: int = 0) -> str:
        """
        Send data and return the response.

        Args:
            data: The data to send.
            retries: number of times to retry in case of timeout

        Returns: The command response

        Raises: SerialException
        """
        data_encode = data.encode()

        for retry in range(retries + 1):
            log.debug(f"{self.name}: Write -> {data_encode!r}")
            await self._serial.write(data=data_encode)

            response = await self._serial.read_until(match=self._ack)
            log.debug(f"{self.name}: Read <- {response!r}")

            if self._ack in response:
                # Remove ack from response
                response = response.replace(self._ack, b"")
                str_response = self.process_raw_response(
                    command=data, response=response.decode()
                )
                self.raise_on_error(response=str_response)
                return str_response

            log.info(f"{self.name}: retry number {retry}/{retries}")

            await self.on_retry()

        raise NoResponse(port=self._port, command=data)
async def _send_data ( self , data : str , retries : int = 0 ) -> str : data_encode = data . encode ( ) for retry in range ( retries + 1 ) : log . debug ( f"{self.name}: Write -> {data_encode!r}" ) await self . _serial . write ( data = data_encode ) response = await self . _serial . read_until ( match = self . _ack ) log . debug ( f"{self.name}: Read <- {response!r}" ) if self . _ack in response : # Remove ack from response response = response . replace ( self . _ack , b"" ) str_response = self . process_raw_response ( command = data , response = response . decode ( ) ) self . raise_on_error ( response = str_response ) return str_response log . info ( f"{self.name}: retry number {retry}/{retries}" ) await self . on_retry ( ) raise NoResponse ( port = self . _port , command = data )