Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dd91df

Browse files
committed
improve register load, add dtr option to serial connet
1 parent1b6016a commit0dd91df

File tree

1 file changed

+27
-3
lines changed
  • crates/arduinox86_client/src

1 file changed

+27
-3
lines changed

‎crates/arduinox86_client/src/lib.rs‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use serialport::{ClearBuffer, SerialPort};
4343
use thiserror::Error;
4444

4545
pubconstARDUINO_BAUD:u32 =1000000;
46+
pubuse binrw::BinWrite;
4647
pubuse cycle_state::*;
4748
pubuse register_printer::*;
4849
pubuse registers::*;
@@ -67,6 +68,7 @@ impl ServerFlags {
6768
pubconstENABLE_DEBUG:u32 =0x0000_0040;// Enable debug serial output
6869
pubconstENABLE_CYCLE_LOGGING:u32 =0x0000_0080;// Enable cycle logging
6970
pubconstENABLE_ALE_INTERRUPT:u32 =0x0000_0100;// Enable ALE interrupt to arbitrate READY line
71+
pubconstRESOLVE_BUS_STEP:u32 =0x0000_0200;// Resolve bus step on each cycle
7072
}
7173

7274
/// [ServerCommand] represents the commands that can be sent to the Arduino808X server.
@@ -464,6 +466,17 @@ pub enum RegisterSetType {
464466
Intel386Smm,
465467
}
466468

469+
implRegisterSetType{
470+
pubfnsize(&self) ->usize{
471+
matchself{
472+
RegisterSetType::Intel8088 =>28,
473+
RegisterSetType::Intel286 =>102,
474+
RegisterSetType::Intel386 =>204,
475+
RegisterSetType::Intel386Smm =>208,
476+
}
477+
}
478+
}
479+
467480
implFrom<&RemoteCpuRegisters>forRegisterSetType{
468481
fnfrom(value:&RemoteCpuRegisters) ->Self{
469482
match value{
@@ -748,6 +761,7 @@ impl CpuClient {
748761
/// Try to open the specified serial port and query it for an Arduino808X server.
749762
pubfntry_port(port_info: serialport::SerialPortInfo,timeout:u64) ->Option<Box<dynSerialPort>>{
750763
let port_result = serialport::new(port_info.port_name.clone(),0)
764+
.dtr_on_open(true)
751765
.baud_rate(0)
752766
.timeout(std::time::Duration::from_millis(timeout))
753767
.stop_bits(serialport::StopBits::One)
@@ -846,12 +860,12 @@ impl CpuClient {
846860
Ok(true)
847861
}
848862
else{
849-
log::error!("read_result_code: command returned failure: {:02X}", buf[0]);
863+
log::error!("read_result_code(): command{:?}returned failure: {:02X}", cmd, buf[0]);
850864
Err(CpuClientError::CommandFailed(cmd))
851865
}
852866
}
853867
Err(e) =>{
854-
log::error!("read_result_code:read operation failed: {}", e);
868+
log::error!("read_result_code(): command {:?}:read operation failed: {}", cmd, e);
855869
Err(CpuClientError::ReadFailure)
856870
}
857871
}
@@ -912,7 +926,17 @@ impl CpuClient {
912926
letmut buf:[u8;1] =[0;1];
913927
buf[0] = reg_type.into();
914928
self.send_buf(&buf)?;
915-
self.send_buf(reg_data)?;
929+
930+
let expected_buf_size = reg_type.size();
931+
if reg_data.len() < expected_buf_size{
932+
returnErr(CpuClientError::BadParameter(format!(
933+
"Expected at least {} byte buffer for register data, got: {}",
934+
expected_buf_size,
935+
reg_data.len()
936+
)));
937+
}
938+
939+
self.send_buf(&reg_data[0..expected_buf_size])?;
916940
self.read_result_code(ServerCommand::CmdLoad)
917941
}
918942

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp