Problems with sending messages that contain strings to a service

Hi all,

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

uint8[10] message

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 ?

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:

# 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 page)

To send a Message using Yakut, take a look at the following example (given in the same demo):

export UAVCAN__NODE__ID=111         # We need a node-ID to publish messages properly
y pub --count=10   250 \
        '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. And lastly, I have been implementing some new pycyphal functionality here, which I think could be helpful for looking up code examples/unit test structure and so on.

1 Like

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 ?

yakut call is only to be used with Service types.

For Messages, you need to use publish/subscribe.

From yakut --help:

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 on how to use these commands.

1 Like

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 ?

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

uint8[<=10] message

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

Thanks, I 'll experiment with this