0.1.0 |
|
---|
#82 in #sending
14KB
312 行
espvpnet
espvpnet是一个用于ESC/VP.net协议(EPson控制视频投影仪)的Rust库
示例
发现ESC/VP.net主机
let mut addrs: Vec<SocketAddr> = Vec::new();
for i in 0..255 {
addrs.push(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, i), 3629).into()) // generate socket addrs from ip range
}
let up_addrs = discover_hosts("0.0.0.0:3629", &addrs, Some(Duration::from_millis(100))); // ping hosts and put the up hosts in up_addrs
println!("{:?}", up_addrs);
创建ESC/VP.net客户端并发送命令
use espvpnet::{ client::Client, protocol::Command, utils::commands::LAMP};
let client = Client::connect("192.168.0.1:3629")?; // init client connection
let command = Command::Get { command: LAMP }; // send "LAMP?" command to get the number of hours left of the video projector lamp
client::send(command)?; // send command to the video projector