eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
586 stars 26 forks source link

Minimal pub-sub example failed to launch: "Failed to create config since the config file could not be opened." #385

Closed nodakai closed 1 week ago

nodakai commented 1 week ago

Required information

Operating system:

Rust version: rustc 1.80.1

Cargo version: cargo 1.80.1 (376290515 2024-07-16)

iceoryx2 version: name = "iceoryx2" version = "0.3.0"

Observed result or behaviour:

root@------:/host# cargo run -- --pub
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/testio2 --pub`
        0 [D] FileBuilder { file_path: FilePath { value: FixedSizeByteString<4096> { len: 20, data: "config/iceoryx2.toml" } }, access_mode: Read, permission: OWNER_READ | OWNER_WRITE | OWNER_EXEC | OWNER_ALL, has_ownership: false, owner: None, group: None, truncate_size: None, creation_mode: None }
              | Unable to open file since it does not exist.
        1 [D] Config { global: Global { root_path_unix: "/tmp/iceoryx2/", root_path_windows: "C:\\Temp\\iceoryx2\\", prefix: "iox2_", service: Service { directory: "services", publisher_data_segment_suffix: ".publisher_data", static_config_storage_suffix: ".service", dynamic_config_storage_suffix: ".dynamic", creation_
              timeout: 500ms, connection_suffix: ".connection" } }, defaults: Defaults { publish_subscribe: PublishSubscribe { max_subscribers: 8, max_publishers: 2, subscriber_max_buffer_size: 2, subscriber_max_borrowed_samples: 2, publisher_max_loaned_samples: 2, publisher_history_size: 1, enable_safe_overflow: true,
               unable_to_deliver_strategy: Block }, event: Event { max_listeners: 1, max_notifiers: 16, event_id_max_value: 32 } } }
              | Failed to create config since the config file could not be opened.
        2 [W] "Config::get_global_config()"
              | Unable to load default config file, populate config with default values.
        3 [T] FileBuilder { file_path: FilePath { value: FixedSizeByteString<4096> { len: 76, data: "/tmp/iceoryx2/services/iox2_b61bd15e8c3ea16146985e960906a8e125156a73.service" } }, access_mode: ReadWrite, permission: OWNER_READ | OWNER_WRITE | OWNER_EXEC | OWNER_ALL, has_ownership: false, owner: None, group: None, t
              runcate_size: None, creation_mode: Some(CreateExclusive) }
              | created
        4 [T] SharedMemory { name: FileName { value: FixedSizeByteString<255> { len: 94, data: "iox2_305ad9523c6b202364d581359ec3d2c5743e42e7_b61bd15e8c3ea16146985e960906a8e125156a73.dynamic" } }, size: 570, base_address: 0x7fea82b57000, has_ownership: false, file_descriptor: FileDescriptor { value: 4, is_owned: true }
              , memory_lock: None }
              | create
        5 [T] ServiceState { static_config: StaticConfig { uuid: "b61bd15e8c3ea16146985e960906a8e125156a73", service_name: ServiceName { value: FixedSizeByteString<255> { len: 19, data: "My/Funk/ServiceName" } }, messaging_pattern: PublishSubscribe(StaticConfig { max_subscribers: 8, max_publishers: 2, history_size: 1, 
              subscriber_max_buffer_size: 2, subscriber_max_borrowed_samples: 2, enable_safe_overflow: true, type_name: "usize", type_size: 32, type_alignment: 16 }) }, global_config: Config { global: Global { root_path_unix: "/tmp/iceoryx2/", root_path_windows: "C:\\Temp\\iceoryx2\\", prefix: "iox2_", service: Service
               { directory: "services", publisher_data_segment_suffix: ".publisher_data", static_config_storage_suffix: ".service", dynamic_config_storage_suffix: ".dynamic", creation_timeout: 500ms, connection_suffix: ".connection" } }, defaults: Defaults { publish_subscribe: PublishSubscribe { max_subscribers: 8, max
              _publishers: 2, subscriber_max_buffer_size: 2, subscriber_max_borrowed_samples: 2, publisher_max_loaned_samples: 2, publisher_history_size: 1, enable_safe_overflow: true, unable_to_deliver_strategy: Block }, event: Event { max_listeners: 1, max_notifiers: 16, event_id_max_value: 32 } } }, dynamic_storage:
               Storage { shm: SharedMemory { name: FileName { value: FixedSizeByteString<255> { len: 94, data: "iox2_305ad9523c6b202364d581359ec3d2c5743e42e7_b61bd15e8c3ea16146985e960906a8e125156a73.dynamic" } }, size: 570, base_address: 0x7fea82b57000, has_ownership: false, file_descriptor: FileDescriptor { value: 4, 
              is_owned: true }, memory_lock: None }, name: FileName { value: FixedSizeByteString<255> { len: 40, data: "b61bd15e8c3ea16146985e960906a8e125156a73" } }, _phantom_data: PhantomData<iceoryx2::service::dynamic_config::DynamicConfig> }, static_storage: Storage { name: FileName { value: FixedSizeByteString<255
              > { len: 40, data: "b61bd15e8c3ea16146985e960906a8e125156a73" } }, config: Configuration { path: Path { value: FixedSizeByteString<4096> { len: 22, data: "/tmp/iceoryx2/services" } }, suffix: FileName { value: FixedSizeByteString<255> { len: 8, data: ".service" } }, prefix: FileName { value: FixedSizeByte
              String<255> { len: 5, data: "iox2_" } } }, has_ownership: false, file: File { path: Some(FilePath { value: FixedSizeByteString<4096> { len: 76, data: "/tmp/iceoryx2/services/iox2_b61bd15e8c3ea16146985e960906a8e125156a73.service" } }), file_descriptor: FileDescriptor { value: 3, is_owned: true }, has_owner
              ship: false }, len: 353 } }
              | open service
        6 [T] SharedMemory { name: FileName { value: FixedSizeByteString<255> { len: 99, data: "iox2_0354a209029e7d094a819e2d4030ea331e6caaf0_5332_422444594209983705762963455475712.publisher_data" } }, size: 1454, base_address: 0x7fea82b56000, has_ownership: true, file_descriptor: FileDescriptor { value: 5, is_owned: t
              rue }, memory_lock: None }
              | create

Expected result or behaviour: https://github.com/eclipse-iceoryx/iceoryx2/tree/v0.3.0?tab=readme-ov-file#publish-subscribe

Conditions where it occurred / Performed steps:

It's just the pub and sub samples from the README combined into a single binary

use std::time::Duration;
use std::env;

use iceoryx2::prelude::*;

const CYCLE_TIME: Duration = Duration::from_secs(1);

fn pub_main() -> Result<(), Box<dyn std::error::Error>> {
  let service_name = ServiceName::new("My/Funk/ServiceName")?;

  let service = zero_copy::Service::new(&service_name)
    .publish_subscribe()
    .open_or_create::<usize>()?;

  let publisher = service.publisher().create()?;

  while let Iox2Event::Tick = Iox2::wait(CYCLE_TIME) {
    let sample = publisher.loan_uninit()?;
    let sample = sample.write_payload(1234);
    sample.send()?;
  }

  Ok(())
}

fn sub_main() -> Result<(), Box<dyn std::error::Error>> {
  let service_name = ServiceName::new("My/Funk/ServiceName")?;

  let service = zero_copy::Service::new(&service_name)
    .publish_subscribe()
    .open_or_create::<usize>()?;

  let subscriber = service.subscriber().create()?;

  while let Iox2Event::Tick = Iox2::wait(CYCLE_TIME) {
    while let Some(sample) = subscriber.receive()? {
      println!("received: {:?}", *sample);
    }
  }

  Ok(())
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
  if env::args().skip(1).any(|e| e == "--pub") {
    pub_main()
  } else {
    sub_main()
  }
}
elfenpiff commented 1 week ago

@nodakai, thanks for reporting the issue!

The error message just states that the config file could not be opened, but actually, this is not a problem since the following line states: Unable to load default config file, populate config with default values.

When the process is started twice, once with --pub and argument and once without so that the subscriber is started, do you observe the println with the send sample or not? From the code point of view everything looks fine.

nodakai commented 1 week ago

Ah so [D] are Debug logs, and [T] are Trace logs, which can be ignored?

In fact the publisher and the subscriber seem to work fine, except they produce noisy Debug/Trace logs.

Where can I disable logs below Info level? I can't seem to find config items for log levels under https://docs.rs/iceoryx2/latest/iceoryx2/config/index.html Maybe I need to enable logger_log and configure the log crate?

elBoberido commented 1 week ago

You can use these call

use iceoryx2_bb_log::set_log_level;

set_log_level(iceoryx2_bb_log::LogLevel::Info);
elfenpiff commented 1 week ago

@nodakai you are right, they are currently a bit noisy - some left over from the early days. We will release v0.4 next week and there we will turn down the noisyness of the examples a bit.

nodakai commented 1 week ago

Thank you both, I guess the tutorial could start with set_log_level(iceoryx2_bb_log::LogLevel::Info) unless you're planning a major overhaul