Make it buildable.
This commit is contained in:
parent
031613e59f
commit
255a24b5fe
7 changed files with 79 additions and 17 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
target
|
||||
Cargo.lock
|
||||
debug/
|
||||
target/
|
||||
Cargo.lock
|
||||
|
|
58
Cargo.lock
generated
58
Cargo.lock
generated
|
@ -2,6 +2,64 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "ftdi-mpsse"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7cfcda69930a8d2fdcdd7ffb9234fe4c79a8c73934ed4904327d77bfb5078a"
|
||||
dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libftd2xx"
|
||||
version = "0.32.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f20d68b3138aaabb97edc3db8ed8f418d60f8abd2a7d8220d562906fb38ff08e"
|
||||
dependencies = [
|
||||
"ftdi-mpsse",
|
||||
"libftd2xx-ffi",
|
||||
"log",
|
||||
"paste",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libftd2xx-ffi"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40bed7f53ea45282e0e4f1361d1a8094e62abe0ccfd9a6dbf7e3db932b2789ce"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "wacca-led"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libftd2xx",
|
||||
]
|
||||
|
|
|
@ -13,3 +13,4 @@ default-target="x86_64-pc-windows-gnu"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
libftd2xx = "0.32.5"
|
12
src/lib.rs
12
src/lib.rs
|
@ -39,11 +39,11 @@ pub extern fn USBIntLED_getVersion() -> i64 {
|
|||
pub extern fn USBIntLED_Init() -> bool {
|
||||
println!("Init");
|
||||
// let _ = SOCKET.set(UdpSocket::bind("0.0.0.0:0").unwrap());
|
||||
let e = output::udprealtime::output {
|
||||
socket: None
|
||||
let mut e = output::udprealtime::output {
|
||||
socket: Some(UdpSocket::bind("0.0.0.0:0").unwrap())
|
||||
};
|
||||
e.init();
|
||||
let _ = SOCKET.set(output::Sockets(e));
|
||||
// e.init();
|
||||
let _ = SOCKET.set(output::sockets::udprealtime(e));
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -71,10 +71,10 @@ pub extern fn USBIntLED_set(_a1: i64, a2: usize) {
|
|||
// let mut flattened: Vec<u8> = leds.into_iter().flatten().collect();
|
||||
// header.append(&mut flattened);
|
||||
match SOCKET.get() {
|
||||
Some(&ref socket) => {
|
||||
Some(socket) => {
|
||||
// let sock: UdpSocket = socket.try_clone().unwrap();
|
||||
// let _ = sock.send_to(&header, addr);
|
||||
socket.send(&mut leds);
|
||||
socket.send(&leds);
|
||||
// output::sockets::udprealtime(*socket).send(leds)
|
||||
},
|
||||
None => {
|
||||
|
|
|
@ -5,10 +5,10 @@ pub enum sockets {
|
|||
}
|
||||
|
||||
impl sockets {
|
||||
pub fn send(&mut self, leds: &mut Vec<rgb::RGB>) -> bool {
|
||||
pub fn send(&self, leds: &Vec<rgb::RGB>) -> bool {
|
||||
match self {
|
||||
sockets::udprealtime(s) => {
|
||||
s.send(leds)
|
||||
s.send(&leds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,17 @@ pub struct output {
|
|||
}
|
||||
|
||||
impl output {
|
||||
pub fn init(&mut self) -> bool {
|
||||
self.socket = Some(UdpSocket::bind("0.0.0.0:0").unwrap());
|
||||
return true;
|
||||
}
|
||||
pub fn send(&mut self, leds: &mut Vec<RGB>) -> bool {
|
||||
// pub fn init(&mut self) -> bool {
|
||||
// self.socket =
|
||||
// return true;
|
||||
// }
|
||||
pub fn send(&self, leds: &Vec<RGB>) -> bool {
|
||||
let mut header: Vec<u8> = vec![2, 2];
|
||||
let mut flattened: Vec<u8> = *leds.into_iter().flatten().collect();
|
||||
let leds2 = Vec::clone(leds);
|
||||
let mut flattened: Vec<u8> = leds2.into_iter().flatten().collect();
|
||||
let addr = SocketAddr::from(([100, 64, 0, 79], 21324));
|
||||
header.append(&mut flattened);
|
||||
match self.socket {
|
||||
match &self.socket {
|
||||
Some(s) => { let _ = s.send_to(&header, addr); },
|
||||
None => ()
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#[derive(Clone)]
|
||||
pub struct RGB {
|
||||
pub red: u8,
|
||||
pub green: u8,
|
||||
|
|
Loading…
Reference in a new issue