Coder Social home page Coder Social logo

ads-rs's People

Contributors

birkenfeld avatar divi255 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ads-rs's Issues

Unable to set TC status

Hello,

I am trying to use the adstool example to set device status, but I am unable to do it.

The same operation works fine using the TwinCAT Powershell API

image

Compilation currently broken

Hello, I am triying to run the example but seems that the build is broken:

> git clone https://github.com/birkenfeld/ads-rs.git
> cd ads-rs
> cargo build
error: failed to download `syn v2.0.15`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `C:\Users\gimmi\.cargo\registry\src\github.com-1ecc6299db9ec823\syn-2.0.15\Cargo.toml`

Caused by:
  failed to parse the `edition` key

Caused by:
  this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.

silent panic if twincat restarts mid-read

I'm finding that if a twincat restart completes (not sure yet exactly at which state transition the problem occurs) during device.get_state() or ads::Handle.read(), or ads::Handle::new(), the call never returns with a Result<> - this leads me to believe something in the background silently panics.

Is there something you're aware of that can be monitored to explicitly avoid this scenario? or otherwise, suggestions for where this silent panic may be taking place?

Thanks!

"Failed to read data" from PLC

Using ads = { git = "https://github.com/birkenfeld/ads-rs.git" } in the Cargo.toml file and the same large project I am getting a new error message, and it is printing my first lines (just for my test setup). Would you like me to open a new Issue for that error message?

Starting Execution at time 2022-09-21T16:45:28.716185300-05:00.
[2022-09-21T21:45:28Z INFO  actix_server::builder] Starting 8 workers
[2022-09-21T21:45:28Z INFO  actix_server::server] Actix runtime found; starting in Actix runtime
"GVL_Constants.NDX_MAX_XXXX" type: "USINT" value: 4
"MAIN._M_Test.XXXX" type: "ULINT" value: 0
"MAIN._M_Test.XYZ type: "ULINT" value: 0
"MAIN._M_Test.YD" type: "ULINT" value: 5
"MAIN._M_Test.ABC" type: "ULINT" value: 0
"MAIN._M_Test.EFG" type: "BOOL" value: false
"MAIN._M_Test.HIJ" type: "ULINT" value: 0
"MAIN.ActiveXXXX" type: "REFERENCE TO FB_XXXX" value: [123, 1, 1, 1, 1, 1, 1, 255]"MAIN.ActiveXXXXX" type: "E_YYYYY" value: [0, 0, 0, 0]
thread 'actix-rt|system:0|arbiter:0' panicked at 'Failed to read the data from the PLC handle with error read data: Reading/writing not permitted (0x704)', src\resource\ads_communication.rs:38:31
stack backtrace:
   0:     0x7ff69ef4d3cf - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff69ef4d3cf - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff69ef4d3cf - std::sys_common::backtrace::_print_fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ff69ef4d3cf - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ff69ef6429a - core::fmt::write
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\fmt\mod.rs:1197
   5:     0x7ff69ef47619 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\io\mod.rs:1672
   6:     0x7ff69ef4fa5b - std::sys_common::backtrace::_print
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ff69ef4fa5b - std::sys_common::backtrace::print
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ff69ef4fa5b - std::panicking::default_hook::closure$1
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:295
   9:     0x7ff69ef4f6db - std::panicking::default_hook
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:314
  10:     0x7ff69ef50009 - std::panicking::rust_panic_with_hook
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:698
  11:     0x7ff69ef4ff0d - std::panicking::begin_panic_handler::closure$0
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:588
  12:     0x7ff69ef4dd57 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:138
  13:     0x7ff69ef4fbe9 - std::panicking::begin_panic_handler
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:584
  14:     0x7ff69efbee15 - core::panicking::panic_fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\panicking.rs:142
  15:     0x7ff69e8d6699 - rust_config_param_viewer::api::ads_communication::get_ads_symbols
                               at C:\projects\rust_config_param_viewer\src\resource\ads_communication.rs:38
  16:     0x7ff69e96de3c - rust_config_param_viewer::api::impl$4::register::get_sysParamList::async_fn$0  
                               at C:\projects\rust_config_param_viewer\src\resource\api.rs:58
  17:     0x7ff69e8d38c7 - core::future::from_generator::impl$1::poll<enum$<rust_config_param_viewer::api::impl$4::register::get_sysParamList::async_fn_env$0> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\mod.rs:91
  18:     0x7ff69e96697e - actix_web::handler::handler_service::closure$0::async_block$0<core::future::from_generator::GenFuture<enum$<rust_config_param_viewer::api::impl$4::register::get_sysParamList::async_fn_env$0> > (*)(),tuple$<> >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-web-4.2.1\src\handler.rs:105
  19:     0x7ff69e8d30a7 - core::future::from_generator::impl$1::poll<enum$<actix_web::handler::handler_service::closure$0::async_block_env$0<core::future::from_generator::GenFuture<enum$<rust_config_param_viewer::api::impl$4::register::get_sysParamList::async_fn_env$0> > (*)(),tup
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\mod.rs:91
  20:     0x7ff69e9fea49 - core::future::future::impl$1::poll<alloc::boxed::Box<dyn$<core::future::future::Future<assoc$<Output,enum$<core::result::Result<actix_web::service::ServiceResponse<actix_http::body::boxed::BoxBody>,actix_web::error::error::Error> > > > >,alloc::alloc::Glo
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\future.rs:124
  21:     0x7ff69ea0d43d - actix_web::resource::impl$2::register::closure$0::async_block$0<actix_web::resource::ResourceEndpoint,actix_http::body::boxed::BoxBody>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-web-4.2.1\src\resource.rs:383
  22:     0x7ff69e9f2a17 - core::future::from_generator::impl$1::poll<enum$<actix_web::resource::impl$2::register::closure$0::async_block_env$0<actix_web::resource::ResourceEndpoint,actix_http::body::boxed::BoxBody> > >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\mod.rs:91
  23:     0x7ff69e9fea49 - core::future::future::impl$1::poll<alloc::boxed::Box<dyn$<core::future::future::Future<assoc$<Output,enum$<core::result::Result<actix_web::service::ServiceResponse<actix_http::body::boxed::BoxBody>,actix_web::error::error::Error> > > > >,alloc::alloc::Glo
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\future.rs:124
  24:     0x7ff69e8d3f80 - actix_web::middleware::logger::impl$4::poll<actix_web::app_service::AppRouting,actix_http::body::boxed::BoxBody>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-web-4.2.1\src\middleware\logger.rs:302
  25:     0x7ff69e921c56 - actix_service::map_err::impl$4::poll<actix_web::app_service::AppInitService<actix_web::middleware::logger::LoggerMiddleware<actix_web::app_service::AppRouting>,actix_web::middleware::logger::StreamLog<actix_http::body::boxed::BoxBody> >,actix_http::reques
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-service-2.0.2\src\map_err.rs:99
  26:     0x7ff69e8fbe28 - actix_http::h1::dispatcher::InnerDispatcher<tokio::net::tcp::stream::TcpStream,actix_service::map_err::MapErr<actix_web::app_service::AppInitService<actix_web::middleware::logger::LoggerMiddleware<actix_web::app_service::AppRouting>,actix_web::middleware:
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-http-3.2.2\src\h1\dispatcher.rs:653
  27:     0x7ff69e8f5b4d - actix_http::h1::dispatcher::InnerDispatcher<tokio::net::tcp::stream::TcpStream,actix_service::map_err::MapErr<actix_web::app_service::AppInitService<actix_web::middleware::logger::LoggerMiddleware<actix_web::app_service::AppRouting>,actix_web::middleware:
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-http-3.2.2\src\h1\dispatcher.rs:744
  28:     0x7ff69e900ad8 - actix_http::h1::dispatcher::impl$4::poll<tokio::net::tcp::stream::TcpStream,actix_service::map_err::MapErr<actix_web::app_service::AppInitService<actix_web::middleware::logger::LoggerMiddleware<actix_web::app_service::AppRouting>,actix_web::middleware::lo
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-http-3.2.2\src\h1\dispatcher.rs:1129
  29:     0x7ff69e957d13 - actix_http::service::impl$8::poll<tokio::net::tcp::stream::TcpStream,actix_service::map_err::MapErr<actix_web::app_service::AppInitService<actix_web::middleware::logger::LoggerMiddleware<actix_web::app_service::AppRouting>,actix_web::middleware::logger::S
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-http-3.2.2\src\service.rs:716
  30:     0x7ff69e8b17d6 - actix_service::and_then::impl$3::poll<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::closure_env$0<actix_service::map_config::MapConfig<actix_service::map_err::MapErrServiceFactory<actix_web::app_service::AppInit<actix_service::tra
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-service-2.0.2\src\and_then.rs:114
  31:     0x7ff69e91fc56 - actix_server::service::impl$1::call::async_block$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::closure_env$0<actix_service::map_config::MapConfig<actix_service::map_err::MapErrServiceFacto
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-server-2.1.1\src\service.rs:75
  32:     0x7ff69e8d3ca9 - core::future::from_generator::impl$1::poll<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::closure_env$0<actix_service::map_config:
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\mod.rs:91
  33:     0x7ff69e8ec170 - tokio::runtime::task::core::impl$3::poll::closure$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\core.rs:184
  34:     0x7ff69e962f02 - tokio::loom::std::unsafe_cell::UnsafeCell<enum$<tokio::runtime::task::core::Stage<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnSer
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\loom\std\unsafe_cell.rs:14
  35:     0x7ff69e8ebf7f - tokio::runtime::task::core::CoreStage<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::closu
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\core.rs:174
  36:     0x7ff69e891e8a - tokio::runtime::task::harness::poll_future::closure$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::im
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\harness.rs:480
  37:     0x7ff69e927923 - core::panic::unwind_safe::impl$23::call_once<enum$<core::task::poll::Poll<tuple$<> > >,tokio::runtime::task::harness::poll_future::closure_env$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_ser
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\panic\unwind_safe.rs:271
  38:     0x7ff69e916eb0 - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::closure_env$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then:
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panicking.rs:492
  39:     0x7ff69e917703 - std::panicking::try::do_catch<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::impl$1::complete::closure_env$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and
  40:     0x7ff69e9162e6 - std::panicking::try<enum$<core::task::poll::Poll<tuple$<> > >,core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::closure_env$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_blo
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panicking.rs:456
  41:     0x7ff69e8d5f1b - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::closure_env$0<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::And
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panic.rs:137
  42:     0x7ff69e89195e - tokio::runtime::task::harness::poll_future<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\harness.rs:468
  43:     0x7ff69e892225 - tokio::runtime::task::harness::Harness<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::clos
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\harness.rs:104
  44:     0x7ff69e892f53 - tokio::runtime::task::harness::Harness<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::clos
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\harness.rs:57
  45:     0x7ff69e982572 - tokio::runtime::task::raw::poll<core::future::from_generator::GenFuture<enum$<actix_server::service::impl$1::call::async_block_env$0<actix_service::and_then::AndThenService<actix_service::fn_service::FnService<actix_http::service::impl$3::tcp::closure_env
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\raw.rs:194
  46:     0x7ff69ee27e50 - tokio::runtime::task::raw::RawTask::poll
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\raw.rs:134
  47:     0x7ff69ee12ec2 - tokio::runtime::task::LocalNotified<alloc::sync::Arc<tokio::task::local::Shared> >::run<alloc::sync::Arc<tokio::task::local::Shared> >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\task\mod.rs:385
  48:     0x7ff69ee37cfe - tokio::task::local::impl$2::tick::closure$0
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:578
  49:     0x7ff69edea305 - tokio::coop::with_budget::closure$0<tuple$<>,tokio::task::local::impl$2::tick::closure_env$0>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:102
  50:     0x7ff69ede7942 - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::try_with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<tuple$<>,tokio::task::local::impl$2::tick::closure_env$0>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:445
  51:     0x7ff69ede7664 - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<tuple$<>,tokio::task::local::impl$2::tick::closure_env$0>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:421
  52:     0x7ff69ee37ca3 - tokio::coop::with_budget
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:95
  53:     0x7ff69ee37ca3 - tokio::coop::budget
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:72
  54:     0x7ff69ee37ca3 - tokio::task::local::LocalSet::tick
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:578
  55:     0x7ff69edbb9b6 - tokio::task::local::impl$8::poll::closure$0<actix_rt::arbiter::ArbiterRunner>  
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:845
  56:     0x7ff69edba808 - tokio::task::local::impl$2::with::closure$0<enum$<core::task::poll::Poll<tuple$<> > >,tokio::task::local::impl$8::poll::closure_env$0<actix_rt::arbiter::ArbiterRunner> >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:633
  57:     0x7ff69ede492a - std::thread::local::LocalKey<core::cell::Cell<enum$<core::option::Option<alloc::rc::Rc<tokio::task::local::Context> >, 1, 18446744073709551615, Some> > >::try_with<core::cell::Cell<enum$<core::option::Option<alloc::rc::Rc<tokio::task::local::Context> >, 1
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:445
  58:     0x7ff69ede3b96 - std::thread::local::LocalKey<core::cell::Cell<enum$<core::option::Option<alloc::rc::Rc<tokio::task::local::Context> >, 1, 18446744073709551615, Some> > >::with<core::cell::Cell<enum$<core::option::Option<alloc::rc::Rc<tokio::task::local::Context> >, 1, 18
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:421
  59:     0x7ff69edba75e - tokio::task::local::LocalSet::with<enum$<core::task::poll::Poll<tuple$<> > >,tokio::task::local::impl$8::poll::closure_env$0<actix_rt::arbiter::ArbiterRunner> >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:616
  60:     0x7ff69edbb7f2 - tokio::task::local::impl$8::poll<actix_rt::arbiter::ArbiterRunner>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:831
  61:     0x7ff69edbae1e - tokio::task::local::impl$2::run_until::async_fn$0<actix_rt::arbiter::ArbiterRunner>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:536
  62:     0x7ff69edbbd49 - core::future::from_generator::impl$1::poll<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\mod.rs:91
  63:     0x7ff69edd1a7a - core::future::future::impl$1::poll<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > > >                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\future\future.rs:124
  64:     0x7ff69edc7e5a - tokio::runtime::scheduler::current_thread::impl$9::block_on::closure$0::closure$0::closure$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:525
  65:     0x7ff69edc9fa9 - tokio::coop::with_budget::closure$0<enum$<core::task::poll::Poll<tuple$<> > >,tokio::runtime::scheduler::current_thread::impl$9::block_on::closure$0::closure$0::closure_env$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::tas
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:102
  66:     0x7ff69ede471a - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::try_with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<enum$<core::task::poll::Poll<tuple$<> > >,tokio::runtime::scheduler::current_thread::impl$9::block
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:445
  67:     0x7ff69ede375d - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<enum$<core::task::poll::Poll<tuple$<> > >,tokio::runtime::scheduler::current_thread::impl$9::block_on:
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\local.rs:421
  68:     0x7ff69edc7c72 - tokio::coop::with_budget
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:95
  69:     0x7ff69edc7c72 - tokio::coop::budget
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\coop.rs:72
  70:     0x7ff69edc7c72 - tokio::runtime::scheduler::current_thread::impl$9::block_on::closure$0::closure$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > > > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:525
  71:     0x7ff69edc60eb - tokio::runtime::scheduler::current_thread::Context::enter<enum$<core::task::poll::Poll<tuple$<> > >,tokio::runtime::scheduler::current_thread::impl$9::block_on::closure$0::closure_env$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:349
  72:     0x7ff69edc6efb - tokio::runtime::scheduler::current_thread::impl$9::block_on::closure$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > > > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:524
  73:     0x7ff69edc6bf0 - tokio::runtime::scheduler::current_thread::impl$9::enter::closure$0<tokio::runtime::scheduler::current_thread::impl$9::block_on::closure_env$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::asy
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:595
  74:     0x7ff69edc4b21 - tokio::macros::scoped_tls::ScopedKey<tokio::runtime::scheduler::current_thread::Context>::set<tokio::runtime::scheduler::current_thread::Context,tokio::runtime::scheduler::current_thread::impl$9::enter::closure_env$0<tokio::runtime::scheduler::current_thr
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\macros\scoped_tls.rs:61
  75:     0x7ff69edc667a - tokio::runtime::scheduler::current_thread::CoreGuard::enter<tokio::runtime::scheduler::current_thread::impl$9::block_on::closure_env$0<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_en
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:595
  76:     0x7ff69edc6cb5 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on<core::pin::Pin<ref_mut$<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > > > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:515
  77:     0x7ff69edc52ad - tokio::runtime::scheduler::current_thread::CurrentThread::block_on<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\scheduler\current_thread.rs:161
  78:     0x7ff69ede3197 - tokio::runtime::Runtime::block_on<core::future::from_generator::GenFuture<enum$<tokio::task::local::impl$2::run_until::async_fn_env$0<actix_rt::arbiter::ArbiterRunner> > > >
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\runtime\mod.rs:490
  79:     0x7ff69edbaa61 - tokio::task::local::LocalSet::block_on<actix_rt::arbiter::ArbiterRunner>       
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.21.1\src\task\local.rs:497
  80:     0x7ff69edbc047 - actix_rt::runtime::Runtime::block_on<actix_rt::arbiter::ArbiterRunner>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-rt-2.7.0\src\runtime.rs:80
  81:     0x7ff69ea86850 - actix_rt::arbiter::impl$2::with_tokio_rt::closure$0<actix_server::worker::impl$10::start::closure_env$1>
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-rt-2.7.0\src\arbiter.rs:144
  82:     0x7ff69ea6dc00 - std::sys_common::backtrace::__rust_begin_short_backtrace<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\sys_common\backtrace.rs:122
  83:     0x7ff69ea70704 - std::thread::impl$0::spawn_unchecked_::closure$1::closure$0<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >      
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\mod.rs:505
  84:     0x7ff69ea4fa64 - core::panic::unwind_safe::impl$23::call_once<tuple$<>,std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> > >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\panic\unwind_safe.rs:271
  85:     0x7ff69ea89181 - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panicking.rs:492
  86:     0x7ff69ea8c173 - alloc::vec::into_iter::impl$15::as_inner<tuple$<usize,enum$<actix_server::socket::MioListener, Tcp> >,alloc::alloc::Global>
  87:     0x7ff69ea886fb - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panicking.rs:456
  88:     0x7ff69ea65fb4 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::impl$0::spawn_unchecked_::closure$1::closure_env$0<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> > >,t
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\panic.rs:137
  89:     0x7ff69ea6fe06 - std::thread::impl$0::spawn_unchecked_::closure$1<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\thread\mod.rs:504
  90:     0x7ff69ea3e48e - core::ops::function::FnOnce::call_once<std::thread::impl$0::spawn_unchecked_::closure_env$1<actix_rt::arbiter::impl$2::with_tokio_rt::closure_env$0<actix_server::worker::impl$10::start::closure_env$1>,tuple$<> >,tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\ops\function.rs:248
  91:     0x7ff69ef5295c - alloc::boxed::impl$44::call_once
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\alloc\src\boxed.rs:1951
  92:     0x7ff69ef5295c - alloc::boxed::impl$44::call_once
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\alloc\src\boxed.rs:1951
  93:     0x7ff69ef5295c - std::sys::windows::thread::impl$0::new::thread_start
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys\windows\thread.rs:56
  94:     0x7ff974a47034 - BaseThreadInitThunk
  95:     0x7ff9760a26a1 - RtlUserThreadStart


Originally posted by @alex-boring in #8 (comment)

ads::symbol::get_symbol_info breaks on large TwinCAT projects

Hey,
great library, thanks a lot for that!

I am running into an issue when using ads::symbol::get_symbol_info on a large TwinCAT project. With a small one it works just fine (tested with a couple dozen variables). Not sure where the threshold is when it breaks.

Any help would be appreciated!
Thanks,
Alex

Output:

thread 'main' panicked at 'range end index 1993 out of range for slice of length 1024', library\core\src\slice\index.rs:73:5
stack backtrace:
   0:     0x7ff75966713f - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff75966713f - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff75966713f - std::sys_common::backtrace::_print_fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ff75966713f - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ff7596780ea - core::fmt::write
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\fmt\mod.rs:1197
   5:     0x7ff7596633c9 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\io\mod.rs:1672
   6:     0x7ff7596697cb - std::sys_common::backtrace::_print
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ff7596697cb - std::sys_common::backtrace::print
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ff7596697cb - std::panicking::default_hook::closure$1
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:295
   9:     0x7ff75966944b - std::panicking::default_hook
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:314
  10:     0x7ff759669d79 - std::panicking::rust_panic_with_hook
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:698
  11:     0x7ff759669c7d - std::panicking::begin_panic_handler::closure$0
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:588
  12:     0x7ff759667ac7 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\sys_common\backtrace.rs:138
  13:     0x7ff759669959 - std::panicking::begin_panic_handler
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:584
  14:     0x7ff75967f495 - core::panicking::panic_fmt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\panicking.rs:142
  15:     0x7ff7596799cb - core::slice::index::slice_end_index_len_fail_rt
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\slice\index.rs:73
  16:     0x7ff759676b19 - core::ops::function::FnOnce::call_once<never$ (*)(usize,usize),tuple$<usize,usize> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\ops\function.rs:248
  17:     0x7ff759676d79 - core::intrinsics::const_eval_select<tuple$<usize,usize>,never$ (*)(usize,usize),never$ (*)(usize,usize),never$>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\intrinsics.rs:2376
  18:     0x7ff75967f559 - core::slice::index::slice_end_index_len_fail
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\slice\index.rs:67
  19:     0x7ff75962308e - core::slice::index::impl$3::index_mut<u8>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\slice\index.rs:315
  20:     0x7ff75962327e - core::slice::index::impl$4::index_mut<u8>
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\slice\index.rs:356
  21:     0x7ff75960cb58 - core::slice::index::impl$1::index_mut<u8,core::ops::range::RangeTo<usize> >    
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\slice\index.rs:30
  22:     0x7ff75960dd6e - core::array::impl$16::index_mut<u8,core::ops::range::RangeTo<usize>,1024>      
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\array\mod.rs:298
  23:     0x7ff759621c6b - ads::symbol::decode_symbol_info::decode_type_info
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.1\src\symbol.rs:252
  24:     0x7ff75961f828 - ads::symbol::decode_symbol_info
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.1\src\symbol.rs:296
  25:     0x7ff75961f418 - ads::symbol::get_symbol_info
                               at C:\Users\testUser\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.1\src\symbol.rs:213
  26:     0x7ff7595eb025 - rust_config_param_viewer::get_ads_symbols
                               at C:\projects\rust_config_param_viewer\src\main.rs:30
  27:     0x7ff7595eb34e - rust_config_param_viewer::main
                               at C:\projects\rust_config_param_viewer\src\main.rs:48
  28:     0x7ff7595ec41b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\core\src\ops\function.rs:248
  29:     0x7ff7595e32ab - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> > 
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\sys_common\backtrace.rs:122
  30:     0x7ff7595e49b1 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\rt.rs:145
  31:     0x7ff75965f2c1 - core::ops::function::impls::impl$2::call_once
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\ops\function.rs:280
  32:     0x7ff75965f2c1 - std::panicking::try::do_call
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:492
  33:     0x7ff75965f2c1 - std::panicking::try
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:456
  34:     0x7ff75965f2c1 - std::panic::catch_unwind
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panic.rs:137
  35:     0x7ff75965f2c1 - std::rt::lang_start_internal::closure$2
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\rt.rs:128
  36:     0x7ff75965f2c1 - std::panicking::try::do_call
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:492
  37:     0x7ff75965f2c1 - std::panicking::try
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:456
  38:     0x7ff75965f2c1 - std::panic::catch_unwind
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panic.rs:137
  39:     0x7ff75965f2c1 - std::rt::lang_start_internal
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\rt.rs:128
  40:     0x7ff7595e497f - std::rt::lang_start<tuple$<> >
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\library\std\src\rt.rs:144
  41:     0x7ff7595eb376 - main
  42:     0x7ff75967dba0 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78  
  43:     0x7ff75967dba0 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 
  44:     0x7ff974a47034 - BaseThreadInitThunk
  45:     0x7ff9760a26a1 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\rust_config_param_viewer.exe` (exit code: 101) ```

decode_symbol_info panics when parsing ARRAY with negative indices such as ARRAY[-1..5] OF INT;

I created a TwinCAT program with negative indices ARRAY[-1..5] OF INT; and tried parsing the symbols from the program.

The library panicked for reason "attempt to add with overflow" in line 258 of symbol.rs.

Stack trace looks something like this:

   0: std::panicking::begin_panic_handler
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\panicking.rs:142
   2: core::panicking::panic
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library\core\src\panicking.rs:48
   3: ads::symbol::decode_symbol_info::decode_type_info
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.3\src\symbol.rs:258
   4: ads::symbol::decode_symbol_info
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.3\src\symbol.rs:296
   5: ads::symbol::get_symbol_info
             at C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\ads-0.4.3\src\symbol.rs:213

Getting the symbol type of a specific handle

When using this library, I am trying to get the symbol information for a specific handle.

I am using the get_symbol_information method to retrieve all the symbols that are in the PLC.
However, looking through the docs and (quickly) through the implementation, I could not find a way to map an instance of a Handle to a Symbol in TypeMap.

let symbol_info = ads::symbol::get_symbol_info(device)?;

let handle_name= "MAIN.m_info";
let handle = Handle::new(device, handle_name)?;
// How to get the Symbol/Type for this handle?

Is this possible? If not, I might have some time to help with the implementation if needed.

Cannot connect to localhost

Hi,

I am trying to connect to the local plc like this:

use ads::{Handle};

fn main() -> ads::Result<()> {


    println!("ADS port: {}", ads::PORT);

    // Open a connection to an ADS device identified by hostname/IP and port.
    // For TwinCAT devices, a route must be set to allow the client to connect.
    // The source AMS address is automatically generated from the local IP,
    // but can be explicitly specified as the third argument.
    let client = ads::Client::new(("localhost", ads::PORT),  ads::Timeouts::new(std::time::Duration::from_secs(1)), None)?;

    // Specify the target ADS device to talk to, by NetID and AMS port.
    // Port 851 usually refers to the first PLC instance.
    let device = client.device(ads::AmsAddr::new([127, 0, 0, 1, 1, 1].into(), 851));

    // Ensure that the PLC instance is running.
    assert!(device.get_state()?.0 == ads::AdsState::Run);

    // Request a handle to a named symbol in the PLC instance.
    let handle = Handle::new(device, "MY_SYMBOL")?;
    // Read data in form of an u32 from the handle.
    let mut data = [0; 4];
    handle.read(&mut data)?;
    println!("MY_SYMBOL value is {}", u32::from_le_bytes(data));

    // Connection will be closed when the client is dropped.
    Ok(())
}

But I get this:

ADS port: 48898
Error: Io("connecting TCP socket with timeout", Error { kind: TimedOut, message: "connection timed out" })

The Python ADS client connects without any problems on this machine. What can I do to fix this?

Mebus

Reading multiple handles

Good day,

First, great library! Missing async support but I read the previous issues and understand why. Hope to help you with that soon.

About the subject - as I see there's no crate method to read multiple variables by their handles, can you please at least make Handle::handle public or create a getter for it?

ADS crate

Hi!

Recently discovered you crate, and also did some experiments with a rust implementation of ADS.

https://github.com/windelbouwman/lognplot/tree/master/rads

Any chance you still doing something with this? I do not have access to a PLC, so I cannot test my code, but the protocol of ADS appeared simple enough to implement.

Regards,
Windel

Trouble connecting to remote PLC

Hello,

I've been banging my head against a wall having problems connecting to a remote Twincat with ADS.
Just copy pasting the example code always ends up failing at device.get_state() with error Io("receiving reply (route set?)", Kind(UnexpectedEof))'

Here is my code:

let client = ads::Client::new(("138.131.232.36", ads::PORT), ads::Timeouts::none(), ads::Source::Auto).unwrap();
let device = client.device(ads::AmsAddr::new([138, 131, 232, 36, 1, 1].into(), 851));
println!("{:?}", device.get_state().unwrap().0);

For reference, here is the ADS route set on my side (client)
image
and the route on the PLC side
image

I've seemingly tried everything but cannot get it to work, and every time I run the code above the route in TwinCAT stops showing "connected", if that means anything...

Weirdly, this works totally fine with another PLC I have and the only difference I've been able to find is that this one has a fixed IP instead of being set through DHCP.

Any help would be welcome...

Decoding and flattening of struct array - question

Hey,
the library is working great so far!

One question I have when using it that you might be able to answer: do you have an example on how to decode (and flatten) arrays, especially struct arrays using the library?

Example Struct:

TYPE ST_Test:
STRUCT
	IN	: ST_Test_IO_IN;
	OUT	: ST_Test_IO_OUT;
        Test    : LREAL;
END_STRUCT
END_TYPE

Example Usage in MAIN Program:

Test	: ARRAY[0..9] OF ST_Test;

Getting the nested symbol information for non-array symbols works like a charm with your recursive function in the examples. Using an adjusted version of your function I am getting down to the Array level like this, but not further. Example print:

Name: GVL_MainGlobals.TestParams Level: 1 Typ: ARRAY [1..6] OF ST_Test Size: 2650

Now when I am using the Rust app to get all the information on the symbols in a struct array it would be great to get a flattened array like this that I can work with and forward. How the print could ideally look like:

Name: GVL_MainGlobals.TestParams[0].IN.whatever  Level: 3  Typ: T_MaxString  Size: 256
Name: GVL_MainGlobals.TestParams[0].OUT.someLightOn  Level: 3  Typ: BOOL Size: 1
Name: GVL_MainGlobals.TestParams[0].Test  Level: 2  Typ: LREAL Size: 8
.
.
.
Name: GVL_MainGlobals.TestParams[9].IN.whatever  Level: 3  Typ: T_MaxString  Size: 256
Name: GVL_MainGlobals.TestParams[9].OUT.someLightOn  Level: 3  Typ: BOOL Size: 1
Name: GVL_MainGlobals.TestParams[9].Test  Level: 2  Typ: LREAL Size: 8

This becomes even trickier for multi dimensional arrays I assume.

Thanks in advance,
Alex

TwinCat 2 Connection issue

Hi, Firstly nice job on the lib, I have used it for TC3 in the past and it works very well!

However, I am trying to connect to a TC2 PLC with this rust lib, however I am having some issues. I am using TC2 v 2.11.0 Build number: 2126. running on 32bit windows

Code:

let client = ads::Client::new(("192.168.0.101", ads::PORT), ads::Timeouts::new(Duration::new(5,0)), 
                                  ads::Source::Addr(ads::AmsAddr::new([192, 168, 0, 101, 1, 1].into(), 801)))?;

// Specify the target ADS device to talk to, by NetID and AMS port.
// Port 851 usually refers to the first PLC instance.
let device = client.device(ads::AmsAddr::new([192, 168, 0, 101, 1, 1].into(), 801));

// Ensure that the PLC instance is running.
assert!(device.get_state()?.0 == ads::AdsState::Run);

Output:

Finished dev [unoptimized + debuginfo] target(s) in 5.87s
Running `target\i686-pc-windows-msvc\debug\compliance_bridge.exe`
Error: Io("receiving reply (route set?)", Kind(TimedOut))
error: process didn't exit successfully: `target\i686-pc-windows-msvc\debug\compliance_bridge.exe` (exit code: 1)

Not sure exactly what is going on here, as I have a route through to the PLC on route manager.

It is worth noting that if I try to do the same thing with python it seems to work using the pyads lib. So, I don't think it's an issue with the PLC or connection etc.

connection = pyads.Connection(ams_net_id='192.168.0.101.1.1', ams_net_port=801, ip_address='192.168.0.101')

connection.open()

print(connection.read_device_info()[1].version)

On another note, when trying to connect to the PLC from localhost, by running the exe on the CX (As that will be the end goal for the code to run on the PLC) I also get an error relating to requesting the Port from the router.

let client = ads::Client::new(("127.0.0.1", ads::PORT), ads::Timeouts::new(Duration::new(5,0)), ads::Source::Request).unwrap();

let device = client.device(ads::AmsAddr::new(ads::AmsNetId::local(), 801));

Let me know if I can help you to replicate the error or debug further, thanks in advance!

Further Symbol and Type data

Is there any way to decode further Symbols and Type data? You mentioned in the source code that some properties were jumped over. Is there any documentation on that?

Making ads::client::Client implement the Send and Sync traits by not using RefCell and Cell in it

Hi, this is a great library so far.

I'm trying to share a single Device object across several different threads so I can make ADS requests using just 1 connection. However, because Device contains Client which uses RefCell and Cell, it doesn't implement Send and Sync, and therefore cannot be sent across different threads.

This is also an issue when trying to use the Device within a tokio asynchronous method, since calling await on a tokio runtime involves possibly moving the runtime to different threads, requiring the Device to implement Send and Sync.

Thanks,
Andrew

Reading / writing strings of length 255

Hey Georg,

I am trying to read / write strings, that are 255 characters long from the PLC. I tried it like this, but this limits me to 32 bytes:

let handle = ads::Handle::new(device, "MyValue").unwrap();
let mut somevalue: [u8; 32];
somevalue =  handle.read_value().unwrap();

What is the correct way to achieve my goal?

Thanks

Mebus

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.