Last active
March 29, 2021 21:55
-
-
Save C47D/15cbe7765b9119cb860fd07d56b36b26 to your computer and use it in GitHub Desktop.
[Rust lang] Read files and send it via serialport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::io::prelude::*; | |
use serialport::available_ports; | |
fn main() { | |
let mut file = File::open("info.txt").expect("Can't open the file"); | |
let mut contents = String::new(); | |
file.read_to_string(&mut contents) | |
.expect("Can't read file"); | |
println!("File content: {}", contents); | |
let ports = available_ports().expect("No ports found"); | |
for p in ports { | |
println!("{}", p.port_name); | |
} | |
} |
Author
C47D
commented
Mar 29, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment