Code Monkey home page Code Monkey logo

ads_client's People

Contributors

hansic99 avatar krystian-l-lis avatar

Watchers

 avatar  avatar

Forkers

krystian-l-lis

ads_client's Issues

AdsCommand: Conversion from u16 failed

Hi.

I'm getting this panic message:

thread 'test' panicked at 'called Result::unwrap()on anErr 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.