Browse Source

accept arguments from command line

master
Michael Preisach 7 years ago
parent
commit
76572a7da4
  1. 10
      .idea/misc.xml
  2. 1
      src/encoder.rs
  3. 18
      src/main.rs

10
.idea/misc.xml

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="MacroExpansionManager">
<option name="directoryName" value="lbsqolEk" />
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="/usr/bin" />
<option name="version" value="2" />
</component>
</project> </project>

1
src/encoder.rs

@ -51,6 +51,7 @@ impl Sevensegment {
'u'|'U' => [false, false, true, true, true, false, false, false].to_vec(), 'u'|'U' => [false, false, true, true, true, false, false, false].to_vec(),
'y'|'Y' => [false, true, true, true, false, true, true, false].to_vec(), 'y'|'Y' => [false, true, true, true, false, true, true, false].to_vec(),
'_' => [false, false, false, true, false, false, false, false].to_vec(), '_' => [false, false, false, true, false, false, false, false].to_vec(),
'-' => [false, false, false, false, false, false, true, false].to_vec(),
'.' => [false, false, false, false, false, false, false, true].to_vec(), '.' => [false, false, false, false, false, false, false, true].to_vec(),
_ => [false, false, false, false, false, false, false, false].to_vec(), _ => [false, false, false, false, false, false, false, false].to_vec(),
}; };

18
src/main.rs

@ -3,8 +3,9 @@ use thread_priority::*;
use std::net::{TcpStream}; use std::net::{TcpStream};
use std::io::prelude::*; use std::io::prelude::*;
use std::io::{BufReader}; use std::io::{BufReader};
use std::time::{Duration}; //use std::time::{Duration};
use std::thread; //use std::{thread, env};
use std::env;
mod encoder; mod encoder;
@ -18,12 +19,21 @@ fn main() {
ThreadPriority::Max, ThreadPriority::Max,
ThreadSchedulePolicy::Normal(NormalThreadSchedulePolicy::Normal)).is_ok()); ThreadSchedulePolicy::Normal(NormalThreadSchedulePolicy::Normal)).is_ok());
let address = "192.168.1.77:8000"; let address = "192.168.1.201:8000";
let stream: TcpStream = TcpStream::connect(address).expect("connection failed"); let stream: TcpStream = TcpStream::connect(address).expect("connection failed");
let mut outstream = stream.try_clone().unwrap(); let mut outstream = stream.try_clone().unwrap();
let mut reader = BufReader::new(stream); let mut reader = BufReader::new(stream);
let mut instructions; let mut instructions;
let input = String::from("0123456789aBcDeFhijlnOpTuY_. ");
let _input2 = String::from(". . ... . . ... . . ... ... . ... . . . . ... ... ... . ... ... . ... . . . . ... . ... ... . .");
let mut args: Vec<String> = env::args().collect();
let input = if args.len() > 0 {
args.remove(0)
} else {
String::from("fl9_u_r_b3y0nd_n00b")
};
let mut state = Encodestate::new(); let mut state = Encodestate::new();

Loading…
Cancel
Save