Skip to content

How to Set a Property Value? #202

@rickbassham

Description

@rickbassham

I know I'm just doing something wrong, but can't figure out what it is. In this code I'm getting and setting the property value of an object. Getting the value works fine, but setting the value returns the following error:

No such method 'Set' in interface 'org.freedesktop.DBus.Properties' at object path '/KStars/Ekos/Capture' (signature 'sss')

Code in question:

package main

import (
	"github.com/godbus/dbus/v5"
)

func main() {
	conn, _ := dbus.SessionBus()
	obj := conn.Object("org.kde.kstars", "/KStars/Ekos/Capture")

	v, err := obj.GetProperty("org.kde.kstars.Ekos.Capture.camera")
	if err != nil {
		panic(err.Error())
	}
	println(v.Value().(string))

	err = obj.SetProperty("org.kde.kstars.Ekos.Capture.camera", "CCD Simulator")
	if err != nil {
		panic(err.Error())
	}
}

Example python code that works just fine:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import time
import dbus

bus = dbus.SessionBus()
remote_object = bus.get_object("org.kde.kstars", "/KStars/Ekos/Capture")
props = dbus.Interface(remote_object, "org.freedesktop.DBus.Properties")
properties = props.GetAll("org.kde.kstars.Ekos.Capture")
props.Set("org.kde.kstars.Ekos.Capture", "camera", "CCD Simulator")

Here's a link to the results of introspecting the object with:

	node, _ := introspect.Call(obj)
	d, _ := xml.MarshalIndent(node, "", "  ")
	println(string(d))

https://gist.github.com/rickbassham/99ac97b9d4fbf0747d4de5d2ccc6bc50

This introspection shows a Set method on org.freedesktop.DBus.Properties.

So, can someone point out what I'm doing wrong here, please? I don't really have any experience working DBus at all. I'm managed to get signals, methods, and getting properties to work fine with this package, just not setting properties.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions