fn send_command_raw(
        &mut self,
        command: u8,
        sub_command: u8,
        data: &[u8],
    ) -> JoyConResult<usize> {
        let mut buf = [0x0; 0x40];
        // set command
        buf[0] = command;
        // set packet number
        buf[1] = self.global_packet_number();
        // increase packet number
        self.increase_global_packet_number();

        // rumble
        let (rumble_l, rumble_r) = self.get_rumble_status();
        if let Some(rumble_l) = rumble_l {
            let rumble_left: [u8; 4] = rumble_l.into();
            buf[2..6].copy_from_slice(&rumble_left);
        }
        if let Some(rumble_r) = rumble_r {
            let rumble_right: [u8; 4] = rumble_r.into();
            buf[6..10].copy_from_slice(&rumble_right);
        }

        // set sub command
        buf[10] = sub_command;
        // set data
        buf[11..11 + data.len()].copy_from_slice(data);

        // send command
        self.write(&buf)
    }
/// Send command, sub-command, and data (sub-command's arguments) with u8 integers
/// This returns ACK packet for the command or Error.
Send command, sub-command, and data (sub-command's arguments) with u8 integers
This returns ACK packet for the command or Error.
Send command sub - command and data ( sub - command ' s arguments ) with u8 integers This returns ACK packet for the command or Error .
fn send_command_raw(
        &mut self,
        command: u8,
        sub_command: u8,
        data: &[u8],
    ) -> JoyConResult<usize> {
        let mut buf = [0x0; 0x40];
        // set command
        buf[0] = command;
        // set packet number
        buf[1] = self.global_packet_number();
        // increase packet number
        self.increase_global_packet_number();
        // rumble
        let (rumble_l, rumble_r) = self.get_rumble_status();
        if let Some(rumble_l) = rumble_l {
            let rumble_left: [u8; 4] = rumble_l.into();
            buf[2..6].copy_from_slice(&rumble_left);
        }
        if let Some(rumble_r) = rumble_r {
            let rumble_right: [u8; 4] = rumble_r.into();
            buf[6..10].copy_from_slice(&rumble_right);
        }
        // set sub command
        buf[10] = sub_command;
        // set data
        buf[11..11 + data.len()].copy_from_slice(data);
        // send command
        self.write(&buf)
    }
fn send_command_raw ( & mut self , command : u8 , sub_command : u8 , data : & [ u8 ] , ) -> JoyConResult < usize > { let mut buf = [ 0x0 ; 0x40 ] ; // set command buf [ 0 ] = command ; // set packet number buf [ 1 ] = self . global_packet_number ( ) ; // increase packet number self . increase_global_packet_number ( ) ; // rumble let ( rumble_l , rumble_r ) = self . get_rumble_status ( ) ; if let Some ( rumble_l ) = rumble_l { let rumble_left : [ u8 ; 4 ] = rumble_l . into ( ) ; buf [ 2 .. 6 ] . copy_from_slice ( & rumble_left ) ; } if let Some ( rumble_r ) = rumble_r { let rumble_right : [ u8 ; 4 ] = rumble_r . into ( ) ; buf [ 6 .. 10 ] . copy_from_slice ( & rumble_right ) ; } // set sub command buf [ 10 ] = sub_command ; // set data buf [ 11 .. 11 + data . len ( ) ] . copy_from_slice ( data ) ; // send command self . write ( & buf ) }
Send command, sub-command, and data (sub-command's arguments) with u8 integers
This returns ACK packet for the command or Error.
Send command sub - command and data ( sub - command ' s arguments ) with u8 integers This returns ACK packet for the command or Error .
&mut self
command
u8
sub_command
u8
data
&[u8]
&mut self
command
u8
sub_command
u8
data
&[u8]