[][src]Struct Rusty_CryptoAuthLib::packet::ATCAPacket

pub struct ATCAPacket<'a> {
    pub pkt_id: u8,
    pub txsize: u8,
    pub opcode: u8,
    pub param1: u8,
    pub param2: [u8; 2],
    pub req_data: &'a [u8],
    pub crc16: [u8; 2],
}

Security commands are sent (over i2c) to the device and responses received from the device This struct holds 'input commands'. It does not include the 'data payload' section

Fields

pkt_id: u8

pkt_id: 1 byte value of 0x03 for normal operation

txsize: u8

1 byte value that represents the number of bytes to be transferred to the device

opcode: u8

Command Opcode

param1: u8

An additional 1 byte command parameter that must always be present. Value depends on the command being sent

param2: [u8; 2]

An additional 2 byte Command parameter that must always be present. Vlaue depends on the command being sent

req_data: &'a [u8]

data bytes

crc16: [u8; 2]

2 byte CRC

Implementations

impl<'a, '_> ATCAPacket<'_>[src]

pub fn make_packet(
    &mut self,
    txsize: Option<u8>,
    opcode: Option<u8>,
    param1: Option<u8>,
    param2: Option<[u8; 2]>
) -> &mut Self
[src]

This methods constructs an input command packet. An input security command is sent after transmitting the 'i2c device address' and is broken down as follows

  • pkt_id: 1 byte value of 0x03 for normal operation
  • txsize: 1 byte value that represents the number of bytes to be transferred to the device, including count byte, packet bytes, and checksum bytes. The count byte should therefore always have a value of (N+1), where N is equal to the number of bytes in the packet plus the two checksum bytes.
  • Param1: An additional 1 byte command parameter that must always be present. Value depends on the command being sent
  • Param2: An additional 2 byte Command parameter that must always be present. Vlaue depends on the command being sent

pub fn crc(self, src: &[u8], length: usize) -> [u8; 2][src]

A method to calculate a 2 byte checksum value. The input to this method is a fully constructed input command packet along with its length.

Trait Implementations

impl<'a> Clone for ATCAPacket<'a>[src]

impl<'a> Copy for ATCAPacket<'a>[src]

impl<'a> Debug for ATCAPacket<'a>[src]

impl<'de: 'a, 'a> Deserialize<'de> for ATCAPacket<'a>[src]

impl<'a> Eq for ATCAPacket<'a>[src]

impl<'a> PartialEq<ATCAPacket<'a>> for ATCAPacket<'a>[src]

impl<'a> Serialize for ATCAPacket<'a>[src]

impl<'a> StructuralEq for ATCAPacket<'a>[src]

impl<'a> StructuralPartialEq for ATCAPacket<'a>[src]

Auto Trait Implementations

impl<'a> Send for ATCAPacket<'a>

impl<'a> Sync for ATCAPacket<'a>

impl<'a> Unpin for ATCAPacket<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.