This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
239 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "icy_term" | ||
version = "0.7.3" | ||
version = "0.8.0" | ||
edition = "2021" | ||
authors = ["Mike Krüger <[email protected]>"] | ||
description = "A terminal program supporting CP437, PetScii and ViewData" | ||
|
@@ -19,14 +19,15 @@ egui_extras = { version="0.26.0", features = ["all_loaders"] } | |
egui_glow = "0.26.0" | ||
egui-modal = "0.3.3" | ||
egui-bind = "0.11.0" | ||
egui_file = "0.15.0" | ||
egui_file = "0.16.2" | ||
glow = "0.13.0" | ||
dark-light = "1.0.0" | ||
serde = "1.0.185" | ||
versions = "6.1.0" | ||
regex = "1.5.4" | ||
github_release_check = "0.2.1" | ||
semver = "1.0.20" | ||
serial = "0.4.0" | ||
|
||
#sound | ||
rodio = { version = "0.17.1" , default-features = false, features = [] } | ||
|
@@ -53,7 +54,7 @@ once_cell = "1.18.0" | |
|
||
log = "0.4" | ||
log4rs = "1.2.0" | ||
web-time = "0.2.0" | ||
web-time = "1.0.0" | ||
|
||
# WebSocket support | ||
tungstenite = { version = "0.21.0", features = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#![allow(dead_code)] | ||
|
||
use crate::Modem; | ||
|
||
use super::{Com, OpenConnectionData, TermComResult}; | ||
use dark_light::Mode; | ||
use serial::{prelude::*, unix::TTYPort}; | ||
use std::{ | ||
io::{self, ErrorKind, Read, Write}, | ||
net::{TcpStream, ToSocketAddrs}, | ||
time::Duration, | ||
}; | ||
|
||
pub struct ComModemImpl { | ||
modem: Modem, | ||
port: Box<dyn serial::SerialPort>, | ||
} | ||
|
||
impl ComModemImpl { | ||
pub fn connect(connection_data: &OpenConnectionData) -> TermComResult<Self> { | ||
let modem = connection_data.modem.as_ref().unwrap().clone(); | ||
let mut port = serial::open(&modem.device)?; | ||
port.reconfigure(&|settings| { | ||
settings.set_baud_rate(serial::BaudRate::from_speed(modem.baud_rate))?; | ||
settings.set_char_size(modem.char_size); | ||
settings.set_parity(modem.parity); | ||
settings.set_stop_bits(modem.stop_bits); | ||
settings.set_flow_control(modem.flow_control); | ||
Ok(()) | ||
})?; | ||
port.write_all(modem.init_string.as_bytes())?; | ||
port.write_all(b"\n")?; | ||
port.write_all(modem.dial_string.as_bytes())?; | ||
port.write_all(connection_data.address.as_bytes())?; | ||
port.write_all(b"\n")?; | ||
Ok(Self { modem, port: Box::new(port) }) | ||
} | ||
} | ||
|
||
impl Com for ComModemImpl { | ||
fn get_name(&self) -> &'static str { | ||
"Modem" | ||
} | ||
|
||
fn default_port(&self) -> u16 { | ||
0 | ||
} | ||
|
||
fn set_terminal_type(&mut self, _terminal: crate::addresses::Terminal) {} | ||
|
||
fn read_data(&mut self) -> TermComResult<Option<Vec<u8>>> { | ||
let mut buf: Vec<u8> = (0..255).collect(); | ||
let size = self.port.read(&mut buf[..])?; | ||
buf.truncate(size); | ||
Ok(Some(buf)) | ||
} | ||
|
||
fn send(&mut self, buf: &[u8]) -> TermComResult<usize> { | ||
self.port.write_all(buf)?; | ||
Ok(buf.len()) | ||
} | ||
|
||
fn disconnect(&mut self) -> TermComResult<()> { | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ pub use options::*; | |
|
||
pub mod addresses; | ||
pub use addresses::*; | ||
|
||
pub mod modem; | ||
pub use modem::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use serial::{prelude::*, CharSize, FlowControl, StopBits}; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct Modem { | ||
pub device: String, | ||
pub baud_rate: usize, | ||
|
||
pub char_size: CharSize, | ||
pub stop_bits: StopBits, | ||
pub parity: serial::Parity, | ||
|
||
pub flow_control: FlowControl, | ||
|
||
pub init_string: String, | ||
pub dial_string: String, | ||
} | ||
|
||
impl Default for Modem { | ||
fn default() -> Self { | ||
Self { | ||
#[cfg(target_os = "windows")] | ||
device: "COM1".to_string(), | ||
#[cfg(not(target_os = "windows"))] | ||
device: "/dev/ttyS0".to_string(), | ||
baud_rate: 9600, | ||
char_size: CharSize::Bits8, | ||
stop_bits: StopBits::Stop1, | ||
parity: serial::Parity::ParityNone, | ||
flow_control: FlowControl::FlowNone, | ||
init_string: "ATZ".to_string(), | ||
dial_string: "ATDT".to_string(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.