For tmp105 and tmp421 temperature same error: "Invalid parameter type for 'temperature', expected: integer"

Viewed 30

I have followed the steps in https://gist.github.com/jonte/b4bd83a5f2e8330418b1f3322bff74f2 to simulate a tmp105 temperature sensor with QEMU:

Assuming you have the qemu sources in the qemu directory:

cd qemu
echo "CONFIG_TMP105=y" >> default-configs/i386-softmmu.mak
./configure && make

then launching QEmu

    build/qemu-system-x86_64                    \
        --enable-kvm                            \
        -hda ~/Projects/qemu/virtualdebian.img  \
        -m 1G                                   \
        -device tmp105,id=sensor,address=0x50   \
        -qmp unix:$HOME/qmp.sock,server,nowait  \
        -nic user

but afterwards, when I try to write the temperature it fails like this:

$ scripts/qmp/qom-get -s $HOME/qmp.sock sensor.temperature    
0
$ scripts/qmp/qom-get -s $HOME/qmp.sock sensor.temperature 
0
$ scripts/qmp/qom-set -s $HOME/qmp.sock sensor.temperature 1 
Traceback (most recent call last):
  File "scripts/qmp/qom-set", line 66, in <module>
    print(srv.command('qom-set', path=path, property=prop, value=value))
  File "scripts/qmp/../../python/qemu/qmp.py", line 274, in command
    raise QMPResponseError(ret)
qemu.qmp.QMPResponseError: Invalid parameter type for 'temperature', expected: integer

In happens also with tmp421 temperature sensor.

Do you know how to fix this error? And why it happens?

1 Answers

yes, the answer was in https://www.mail-archive.com/qemu-devel@nongnu.org/msg747323.html

But is fixed in newer versions of QEmu

    diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
    index 240a78187f..49eebe4924 100755
    --- a/scripts/qmp/qom-set
    +++ b/scripts/qmp/qom-set
    @@ -56,7 +56,10 @@ if len(args) > 1:
              path, prop = args[0].rsplit('.', 1)
          except:
              usage_error("invalid format for path/property/value")
    -    value = args[1]
    +    try:
    +        value = int(args[1])
    +    except ValueError:
    +        value = args[1]
      else:
          usage_error("not enough arguments")
Related