pub fn msg_processor(msg_format: &MsgFormat) -> Vec<u8> {
    let mut sec_result;
    let mut result = 0;
    let msg_byte_array;
    let mut msg_byte_vec: Vec<u8> = Vec::new();
    let mut total_num_bytes = 0;
    if msg_format.sections.len() == 1 {
        result = section_proc(&msg_format.sections[0]);
        total_num_bytes += msg_format.sections[0].num_bytes;
    } else {
        for i in 0..msg_format.sections.len() {
            sec_result = section_proc(&msg_format.sections[i]);
            // shifting the bits to make room for the new result
            result <<= msg_format.sections[i].num_bytes * 8;
            // ORing to add the new result on the end
            result |= sec_result;
            total_num_bytes += msg_format.sections[i].num_bytes;
        }
    }
    // bit shifting the final result so we push the actual
    // code all the way to the left as needed for CAN
    result <<= 64 - total_num_bytes * 8;
    // Chopping up result into a vec<u8>!
    // (done at end because it's simpler to do bit shifting with a single number before now)
    msg_byte_array = result.to_be_bytes();
    for msg in &msg_byte_array {
        msg_byte_vec.push(*msg);
    }
    msg_byte_vec
}
/// Create CAN message data using provided message format
Create CAN message data using provided message format
Create CAN message data using provided message format
pub fn msg_processor(msg_format: &MsgFormat) -> Vec<u8> {
    let mut sec_result;
    let mut result = 0;
    let msg_byte_array;
    let mut msg_byte_vec: Vec<u8> = Vec::new();
    let mut total_num_bytes = 0;
    if msg_format.sections.len() == 1 {
        result = section_proc(&msg_format.sections[0]);
        total_num_bytes += msg_format.sections[0].num_bytes;
    } else {
        for i in 0..msg_format.sections.len() {
            sec_result = section_proc(&msg_format.sections[i]);
            // shifting the bits to make room for the new result
            result <<= msg_format.sections[i].num_bytes * 8;
            // ORing to add the new result on the end
            result |= sec_result;
            total_num_bytes += msg_format.sections[i].num_bytes;
        }
    }
    // bit shifting the final result so we push the actual
    // code all the way to the left as needed for CAN
    result <<= 64 - total_num_bytes * 8;
    // Chopping up result into a vec<u8>!
    // (done at end because it's simpler to do bit shifting with a single number before now)
    msg_byte_array = result.to_be_bytes();
    for msg in &msg_byte_array {
        msg_byte_vec.push(*msg);
    }
    msg_byte_vec
}
pub fn msg_processor ( msg_format : & MsgFormat ) -> Vec < u8 > { let mut sec_result ; let mut result = 0 ; let msg_byte_array ; let mut msg_byte_vec : Vec < u8 > = Vec :: new ( ) ; let mut total_num_bytes = 0 ; if msg_format . sections . len ( ) == 1 { result = section_proc ( & msg_format . sections [ 0 ] ) ; total_num_bytes += msg_format . sections [ 0 ] . num_bytes ; } else { for i in 0 .. msg_format . sections . len ( ) { sec_result = section_proc ( & msg_format . sections [ i ] ) ; // shifting the bits to make room for the new result result <<= msg_format . sections [ i ] . num_bytes * 8 ; // ORing to add the new result on the end result |= sec_result ; total_num_bytes += msg_format . sections [ i ] . num_bytes ; } } // bit shifting the final result so we push the actual // code all the way to the left as needed for CAN result <<= 64 - total_num_bytes * 8 ; // Chopping up result into a vec<u8>! // (done at end because it's simpler to do bit shifting with a single number before now) msg_byte_array = result . to_be_bytes ( ) ; for msg in & msg_byte_array { msg_byte_vec . push ( * msg ) ; } msg_byte_vec }
Create CAN message data using provided message format
Create CAN message data using provided message format
msg_format
&MsgFormat
msg_format
&MsgFormat