Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLC - CanOpen #50

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
}
Loading