hansic99 / ads_client Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi.
I'm getting this panic message:
thread 'test' panicked at 'called
Result::unwrap()on an
Err value: AdsError { n_error: 1, s_msg: "AdsCommand: Conversion from u16 failed" }', C:\...\ads_client-1.2.1\src\lib.rs:170:85
It seems like line 170 of lib.rs
let ads_cmd = Client::extract_cmd_tyte(&header_buf).unwrap();
inside Clients:
async fn process_response(handles: Arc<Mutex<Vec<Handle>>>, not_handles: Arc<Mutex<Vec<NotHandle>>>, mut rd_stream : ReadHalf<TcpStream>)
and my code:
pub const SYM_DT_UPLOAD: u32 = 0xF00E;
pub const SYM_UPLOAD_INFO2: u32 = 0xF00F;
pub const SYM_UPLOAD: u32 = 0xF00B;
#[tokio::test]
async fn test() -> Result<()> {
let ads_client = Client::new("192.168.1.108.1.1", 851, AdsTimeout::CustomTimeout(10)).await?;
let mut read_data: [u8; 64] = [0; 64];
if let Err(err) = ads_client.read(index::SYM_UPLOAD_INFO2, 0, &mut read_data).await {
println!("Error: {}", err);
}
let symbol_len = LE::read_u32(&read_data[4..]) as usize;
let types_len = LE::read_u32(&read_data[12..]) as usize;
let mut types_data = vec![0; types_len];
let mut symbol_data = vec![0; symbol_len];
if let Err(err) = ads_client.read(index::SYM_DT_UPLOAD, 0, &mut types_data).await {
println!("Error: {}", err);
};
if let Err(err) = ads_client.read(index::SYM_UPLOAD, 0, &mut symbol_data).await {
println!("Error: {}", err);
};
Ok(())
}
It works fine for small projects but fails 90% of the time with large ones. I'm trying to load metadata from the project. I am not sure if this is a crate fault or an ADS fault due to the size.
Edit:
I cloned the repo, and after some testing, I made it work. It appears that this is a Haisebug type of error. After adding:
println!("{:?}\n", header_buf);
println!("==========================================================");
to the process_response it fixed itself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.