Skip to content

Commit 78ebefa

Browse files
Merge pull request #42 from FrameworkComputer/better-port-permission-setup-and-errors
Co-authored-by: Daniel Schaefer <[email protected]>
2 parents d944247 + 3c3eac6 commit 78ebefa

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ Optionally there are is also a [Python script](python.md).
3838

3939
For device specific commands, see their individual documentation pages.
4040

41-
Common commands:
41+
###### Permissions on Linux
42+
To ensure that the input module's port is accessible, install the `udev` rule and trigger a reload:
43+
44+
```
45+
sudo cp release/50-framework-inputmodule.rules /etc/udev/rules.d/
46+
sudo udevadm control --reload && sudo udevadm trigger
47+
```
48+
49+
##### Common commands:
4250

4351
###### Listing available devices
4452

inputmodule-control/src/inputmodule.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,17 @@ fn simple_cmd_multiple(serialdevs: &Vec<String>, command: Command, args: &[u8])
393393
}
394394

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

401-
simple_cmd_port(&mut port, command, args);
400+
match port_result {
401+
Ok(mut port) => simple_cmd_port(&mut port, command, args),
402+
Err(error) => match error.kind {
403+
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."),
404+
other_error => panic!("Couldn't open port: {:?}", other_error)
405+
}
406+
};
402407
}
403408

404409
fn open_serialport(serialdev: &str) -> Box<dyn SerialPort> {
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Framework Laptop 16 - LED Matrix
2+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0020", MODE="0660", TAG+="uaccess"
3+
4+
# B1 Display (Experimental prototype, not a product)
5+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0021", MODE="0660", TAG+="uaccess"
6+
7+
# C1 Minimal Microcontroller Module (Template for DIY Module)
8+
SUBSYSTEMS=="usb", ATTRS{idVendor}=="32ac", ATTRS{idProduct}=="0022", MODE="0660", TAG+="uaccess"

0 commit comments

Comments
 (0)