eclipse-iceoryx / iceoryx2

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

CLI for participating with `iox2` communication from the terminal #413

Open orecham opened 1 month ago

orecham commented 1 month ago

Brief feature description

Make it possible to publish, subscribe, notify, listen (request, respond, etc.) to iceoryx2 services directly from the CLI, e.g.

iox2 service publish <TOPIC> <PAYLOAD>
iox2 service subscribe <TOPIC>
iox2 service listen <TOPIC>
iox2 service notify <TOPIC>
// etc.

Detailed information

Nice to have:

  1. Make it possible to plug in custom logic for working with payloads, e.g.
    1. Publish data from a file
    2. Display image payloads from subscribers directly in the terminal
brosier01 commented 13 hours ago

Hi @orecham, I'm currently working on this feature. First, I'm trying to implement the publish subcommand. I'm using the “publish_subscribe_subscriber” example as a test endpoint. As I understand it, in order to communicate with the subscriber, I need to define a service with a specific payload size. Can I get the size of this payload and create a new service with this payload size at runtime? (Because at compile time, I don't know the payload size and the subscriber needs a payload of size)

orecham commented 38 minutes ago

@brosier01

Hmm, this is a tough problem to solve - something I completely overlooked when imagining this feature, my mistake.

As a first step, I guess the CLI could be made to only use the [u8] payload type so that concrete types aren't needed. We are currently working on updating iceoryx2 so that the maximum_slice_len does not need to be provided when defining services of type [u8]. This however would mean that applications would also need to use the [u8] payload type for the CLI to connect to it, which is not ideal for many reasons (usability, safety, etc.). Proceeding with this first though would allow for focusing on the other (maybe simpler) aspects of implementing the CLI.

To get the CLI to work with services with concrete types, two ideas come to mind (but I think they might definitely need some more thought):

  1. Add functionality for iceoryx2 applications to compile type definitions into a separate shared library
    1. The CLI would need to have a way to find these libraries to get the type definitions
      1. Ideally this would be automatic, but could be done manually by passing an argument as a stepping stone
  2. Use something like schemars (and serde?) to store type descriptions along with services?
    1. Not sure how feasible it is, but could also be an interesting option
    2. Not sure if this removes the requirement of using [u8] payload types though

Let me know if you have any other ideas. I am not yet super confident that one of these two options would be optimal. Might need some discussion before we work out what makes the most sense.

Can I get the size of this payload and create a new service with this payload size at runtime?

Until we remove the max_slice_len requirement, you could maybe just make the size the actual size of the payload.