Skip to content

Better port permission setup and errors #42

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

Merged
merged 4 commits into from
Aug 25, 2023
Merged
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: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ Optionally there are is also a [Python script](python.md).

For device specific commands, see their individual documentation pages.

Common commands:
###### Permissions on Linux
To ensure that the input module's port is accessible, install the `udev` rule and trigger a reload:

```
sudo cp release/50-framework-inputmodule.rules /etc/udev/rules.d/
sudo udevadm control --reload && sudo udevadm trigger
```

##### Common commands:

###### Listing available devices

Expand Down
13 changes: 9 additions & 4 deletions inputmodule-control/src/inputmodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,17 @@ fn simple_cmd_multiple(serialdevs: &Vec<String>, command: Command, args: &[u8])
}

fn simple_cmd(serialdev: &str, command: Command, args: &[u8]) {
let mut port = serialport::new(serialdev, 115_200)
let port_result = serialport::new(serialdev, 115_200)
.timeout(SERIAL_TIMEOUT)
.open()
.expect("Failed to open port");
.open();

simple_cmd_port(&mut port, command, args);
match port_result {
Ok(mut port) => simple_cmd_port(&mut port, command, args),
Err(error) => match error.kind {
serialport::ErrorKind::Io(std::io::ErrorKind::PermissionDenied) => panic!("Permission denied, couldn't access inputmodule serialport. Ensure that you have permission, for example using a udev rule or sudo."),
other_error => panic!("Couldn't open port: {:?}", other_error)
}
};
}

fn open_serialport(serialdev: &str) -> Box<dyn SerialPort> {
Expand Down
8 changes: 8 additions & 0 deletions release/50-framework-inputmodule.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Framework Laptop 16 - LED Matrix
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0020", MODE="0660", TAG+="uaccess"

# B1 Display (Experimental prototype, not a product)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0021", MODE="0660", TAG+="uaccess"

# C1 Minimal Microcontroller Module (Template for DIY Module)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0022", MODE="0660", TAG+="uaccess"