Skip to content

Commit

Permalink
can processor start
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfbastos committed Nov 16, 2024
1 parent fd90cf0 commit 97913e8
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/motors/can_processor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn process_message(id: u16, data: &[u8; 8]) -> Message {
Message.id = id;
Message.index = data[1] << 8 | data[0];
Message.command = data[3];
Message.subindex = data[2]
Message.data = data[7] << 24 | data[6] << 16 | data[5] << 8 | data[4];
}



95 changes: 95 additions & 0 deletions lib/motors/config/messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
struct Message {
id: u16,
index: u16,
subindex: u8,
command: u8,
data: u32,
}

mod config_messages {
use super::Message;

pub const TEST_STEPPER_ENABLE: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x09,
data: 0x00000001,
};

pub const TEST_MODE_COMMAND: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x2031,
subindex: 0x00,
data: 0x00000060,
};
}

mod messages {
use super::Message;

pub const ENTER_STOP_STATE: Message = Message {
id: 0x000,
command: 0x02,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

pub const ENTER_PREOPERATIONAL_STATE: Message = Message {
id: 0x000,
command: 0x03,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

pub const ENTER_OPERATIONAL_STATE: Message = Message {
id: 0x000,
command: 0x01,
index: 0x0000,
subindex: 0x00,
data: 0x00000000,
};

pub const SET_FREQUENCY: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x2040,
subindex: 0x04,
data: 0x00000000,
};

pub const SHUTDOWN: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000006,
};

pub const SWITCH_ON: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000007,
};

pub const START_DRIVE: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x0000000F,
};

pub const QUICK_STOP: Message = Message {
id: 0x601,
command: 0x2B,
index: 0x6040,
subindex: 0x00,
data: 0x00000002,
};
}

0 comments on commit 97913e8

Please sign in to comment.