fn send_sub_command_raw(
        &mut self,
        sub_command: u8,
        data: &[u8],
    ) -> JoyConResult<SubCommandReply<[u8; 362]>> {
        use input_report_mode::sub_command_mode::AckByte;

        self.send_command_raw(1, sub_command, data)?;

        // check reply
        if self.valid_reply() {
            std::iter::repeat(())
                .take(Self::ACK_TRY)
                .flat_map(|()| {
                    let mut buf = [0u8; 362];
                    self.read(&mut buf).ok()?;
                    let ack_byte = AckByte::from(buf[13]);

                    match ack_byte {
                        AckByte::Ack { .. } => Some(buf),
                        AckByte::Nack => None,
                    }
                })
                .next()
                .map(SubCommandReply::Checked)
                .ok_or_else(|| JoyConError::SubCommandError(sub_command, Vec::new()))
        } else {
            Ok(SubCommandReply::Unchecked)
        }
    }
/// Send sub-command, and data (sub-command's arguments) with u8 integers
/// This returns ACK packet for the command or Error.
///
/// # Notice
/// If you are using non-blocking mode,
/// it is more likely to fail to validate the sub command reply.
Send sub-command, and data (sub-command's arguments) with u8 integers
This returns ACK packet for the command or Error.
Send sub - command and data ( sub - command ' s arguments ) with u8 integers This returns ACK packet for the command or Error .
fn send_sub_command_raw(
        &mut self,
        sub_command: u8,
        data: &[u8],
    ) -> JoyConResult<SubCommandReply<[u8; 362]>> {
        use input_report_mode::sub_command_mode::AckByte;
        self.send_command_raw(1, sub_command, data)?;
        // check reply
        if self.valid_reply() {
            std::iter::repeat(())
                .take(Self::ACK_TRY)
                .flat_map(|()| {
                    let mut buf = [0u8; 362];
                    self.read(&mut buf).ok()?;
                    let ack_byte = AckByte::from(buf[13]);
                    match ack_byte {
                        AckByte::Ack { .. } => Some(buf),
                        AckByte::Nack => None,
                    }
                })
                .next()
                .map(SubCommandReply::Checked)
                .ok_or_else(|| JoyConError::SubCommandError(sub_command, Vec::new()))
        } else {
            Ok(SubCommandReply::Unchecked)
        }
    }
fn send_sub_command_raw ( & mut self , sub_command : u8 , data : & [ u8 ] , ) -> JoyConResult < SubCommandReply < [ u8 ; 362 ] > > { use input_report_mode :: sub_command_mode :: AckByte ; self . send_command_raw ( 1 , sub_command , data ) ? ; // check reply if self . valid_reply ( ) { std :: iter :: repeat ( ( ) ) . take ( Self :: ACK_TRY ) . flat_map ( | ( ) | { let mut buf = [ 0u8 ; 362 ] ; self . read ( & mut buf ) . ok ( ) ? ; let ack_byte = AckByte :: from ( buf [ 13 ] ) ; match ack_byte { AckByte :: Ack { .. } => Some ( buf ) , AckByte :: Nack => None , } } ) . next ( ) . map ( SubCommandReply :: Checked ) . ok_or_else ( | | JoyConError :: SubCommandError ( sub_command , Vec :: new ( ) ) ) } else { Ok ( SubCommandReply :: Unchecked ) } }
Send sub-command, and data (sub-command's arguments) with u8 integers
This returns ACK packet for the command or Error.
Send sub - command and data ( sub - command ' s arguments ) with u8 integers This returns ACK packet for the command or Error .
&mut self
sub_command
u8
data
&[u8]
&mut self
sub_command
u8
data
&[u8]
notice
If you are using non-blocking mode,
it is more likely to fail to validate the sub command reply.
If you are using non - blocking mode it is more likely to fail to validate the sub command reply .