snap7-cli 0.1.0

CLI tool for communicating with Siemens S7 PLCs — read/write data blocks, watch tags, upload blocks, query SZL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::Result;
use snap7_client::{transport::TcpTransport, S7Client};

use crate::args::{OutputFormat, ReadArgs};
use crate::output::print_bytes;

pub async fn run(
    client: &S7Client<TcpTransport>,
    args: ReadArgs,
    format: &OutputFormat,
) -> Result<()> {
    let data = client
        .db_read(args.db, args.offset, args.size)
        .await
        .map_err(|e| anyhow::anyhow!("{}", e))?;
    print_bytes(&data, format);
    Ok(())
}