Now with rudimentary support for reading incoming records

This commit is contained in:
2020-11-11 16:17:02 +01:00
parent c294e8033f
commit cfdfedb5b4
3 changed files with 45 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ use tn3270s::tn3270;
#[derive(StructOpt)]
pub struct Cli {
#[structopt(short="h", long = "host", default_value="[::1]")]
#[structopt(short="h", long = "host", default_value="::1")]
host: String,
#[structopt(short="p", long = "port", default_value="2101")]
port: u16,
@@ -14,7 +14,7 @@ pub struct Cli {
fn run(mut session: tn3270::Session) -> anyhow::Result<()> {
use tn3270::stream::*;
let mut record = WriteCommand::new(WriteCommandCode::Write, WCC::RESET);
let mut record = WriteCommand::new(WriteCommandCode::Write, WCC::RESET | WCC::KBD_RESTORE);
let bufsz = BufferAddressCalculator { width: 80, height: 24 };
record.set_buffer_address(0)
.erase_unprotected_to_address(bufsz.encode_address(79, 23))
@@ -23,6 +23,14 @@ fn run(mut session: tn3270::Session) -> anyhow::Result<()> {
.send_text("Hello from Rust!");
session.send_record(record)?;
let record = session.receive_record(None)?;
if let Some(record) = record {
eprintln!("Incoming record: {:?}", hex::encode(record));
} else {
eprintln!("No record");
}
std::thread::sleep(Duration::from_secs(60));
Ok(())
}