# Problems with sending messages that contain strings to a service

**URL:** <https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899>\
**Category:** Applications & Usage\
**Created:** [May 26, 2023, 5:43pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899 "2023-05-26T17:43:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![merakian](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@merakian](https://forum.opencyphal.org/u/merakian)\
**Post date:** [May 26, 2023, 5:43pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/1 "2023-05-26T17:43:32Z")

</div>

Hi all,

I have a dsdl named TestServiceInput.0.1.dsdl that looks like this:

uint8[10] message  
@sealed

for a personal service called TestService with ID of 17 that I register to my cyphal implementation with node ID of 22.

when I invoke the following:

yakut call 22 17:TestServiceInput.0.1 ‘message:“helloworld”’

I get the following:

Error: TestServiceInput.0.1 is not a service type.

What does this error message mean (and how do I fix this), and what is the correct way of sending a message that contains a string ?

---

<div class="post-metadata">

**Author:** ![maksim.drachov](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/maksim.drachov/32/1577_2.png) [@maksim.drachov](https://forum.opencyphal.org/u/maksim.drachov)\
**Post date:** [May 26, 2023, 9:39pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/2 "2023-05-26T21:39:47Z")

</div>

The DSDL you have defined is a Message, not a Service.

A Service has the following structure, with `---` delineating the Request and Response part respectively:

```auto
# This service accepts a list of 2D point coordinates and returns the best-fit linear function coefficients.
# If no solution exists, the returned coefficients are NaN.

PointXY.1.0[<64] points
@extent 1024 * 8
---
float64 slope
float64 y_intercept
@extent 64 * 8

```

(Example taken from pycyphal [demo](https://pycyphal.readthedocs.io/en/stable/pages/demo.html#dsdl-definitions) page)

To send a Message using Yakut, take a look at the following example (given in the same [demo](https://pycyphal.readthedocs.io/en/stable/pages/demo.html#poking-the-node-using-yakut)):

```auto
export UAVCAN __UDP__ IFACE=127.0.0.1
export UAVCAN __NODE__ ID=111 # We need a node-ID to publish messages properly
y pub --count=10 2345:uavcan.si.unit.temperature.scalar 250 \
                 2346:uavcan.si.sample.temperature.scalar 'kelvin: 240'

```

(Obviously you will replace some parts, specifying the correct Node ID, DSDL type,…)

PS: You seem to want to send a string, there’s a `uavcan.primitive.String.1.0` type that is better suited for this purpose (instead of `uint8`). (Unless you’re absolutely sure it will always be _exactly_ 10 bytes → correct me if I’m wrong here @pavel.kirienko )

PS2: I would highly recommend working through the demo provided above, I have made some (rough) personal notes that could provide a bit more background understanding [here](https://github.com/maksimdrachov/opencyphal-tutorial/blob/main/docs/1-pc-demo/pycyphal.md). And lastly, I have been implementing some new pycyphal functionality [here](https://github.com/OpenCyphal-Garage/cyraft), which I think could be helpful for looking up code examples/unit test structure and so on.

---

<div class="post-metadata">

**Author:** ![merakian](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@merakian](https://forum.opencyphal.org/u/merakian)\
**Post date:** [May 26, 2023, 10:27pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/3 "2023-05-26T22:27:48Z")

</div>

Thanks! I’ll give that a shot.

Do you also happen to have documentation on how to format a message as part of a yakut call ? Is it just YAML format ?

---

<div class="post-metadata">

**Author:** ![maksim.drachov](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/maksim.drachov/32/1577_2.png) [@maksim.drachov](https://forum.opencyphal.org/u/maksim.drachov)\
**Post date:** [May 27, 2023, 3:20am UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/4 "2023-05-27T03:20:41Z")

</div>

`yakut call` is only to be used with Service types.

For Messages, you need to use `publish`/`subscribe`.

From `yakut --help`:

```auto
call,q Invoke an RPC-service using the specified request
publish,p,pub Publish messages on the specified subjects
subscribe,s,sub Subscribe to specified subjects and print messages to

```

An [example](https://pycyphal.readthedocs.io/en/stable/pages/demo.html#poking-the-node-using-yakut) on how to use these commands.

---

<div class="post-metadata">

**Author:** ![merakian](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@merakian](https://forum.opencyphal.org/u/merakian)\
**Post date:** [May 30, 2023, 7:32pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/5 "2023-05-30T19:32:49Z")

</div>

My mistake, I meant for Service types.

I fixed the dsdl to be a service type, so now it’s called TestService.0.1

I called the following:

yakut call 22 17:TestService.0.1 ‘{message:“hello world”}’

and I get:

ValueError: invalid literal for int() with base 10: ‘hello world’

Do you have an example of sending strings to a service ?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [May 30, 2023, 9:00pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/6 "2023-05-30T21:00:46Z")

</div>

For this to work, your `message` needs to be a variable-length array of `uint8`, like so:

```python
uint8[<=10] message

```

Otherwise you need to use the YAML list syntax to assign the field.

---

<div class="post-metadata">

**Author:** ![merakian](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@merakian](https://forum.opencyphal.org/u/merakian)\
**Post date:** [May 30, 2023, 11:10pm UTC](https://forum.opencyphal.org/t/problems-with-sending-messages-that-contain-strings-to-a-service/1899/7 "2023-05-30T23:10:23Z")

</div>

Thanks, I 'll experiment with this
