digitaltrails / ddcutil-service

A Dbus ddcutil server for control of DDC Monitors/VDUs
GNU General Public License v2.0
11 stars 1 forks source link

Had to extract status_definitions from libddcutil #6

Closed digitaltrails closed 9 months ago

digitaltrails commented 9 months ago

I had to extract status definitions from libddcutil to provide clients with a way to lookup/test the meaning of integer status indicators.

The status definitions are exposed as a StatusValues read-only property on the interface:

% dbus-send --session --print-reply  --dest=com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject org.freedesktop.DBus.Properties.Get string:com.ddcutil.DdcutilInterface string:StatusValues
method return time=1700512707.564423 sender=:1.101 -> destination=:1.142 serial=131 reply_serial=2
   variant       array [
         dict entry(
            int32 0
            string "DDCRC_OK"
         )
         dict entry(
            int32 -3001
            string "DDCRC_DDC_DATA"
         )
         dict entry(
            int32 -3002
            string "DDCRC_NULL_RESPONSE"
         )
         dict entry(
            int32 -3003
            string "DDCRC_MULTI_PART_READ_FRAGMENT"
         )
         dict entry(
            int32 -3004
            string "DDCRC_ALL_TRIES_ZERO"
         )
         dict entry(
            int32 -3005
            string "DDCRC_REPORTED_UNSUPPORTED"
         )
         dict entry(
            int32 -3006
            string "DDCRC_READ_ALL_ZERO"
         )
         dict entry(
            int32 -3007
            string "DDCRC_RETRIES"
         )
         dict entry(
            int32 -3008
            string "DDCRC_EDID"
         )
         dict entry(
            int32 -3009
            string "DDCRC_READ_EDID"
         )
         dict entry(
            int32 -3010
            string "DDCRC_INVALID_EDID"
         )
         dict entry(
            int32 -3011
            string "DDCRC_ALL_RESPONSES_NULL"
         )
         dict entry(
            int32 -3012
            string "DDCRC_DETERMINED_UNSUPPORTED"
         )
         dict entry(
            int32 -3013
            string "DDCRC_ARG"
         )
         dict entry(
            int32 -3014
            string "DDCRC_INVALID_OPERATION"
         )
         dict entry(
            int32 -3015
            string "DDCRC_UNIMPLEMENTED"
         )
         dict entry(
            int32 -3016
            string "DDCRC_UNINITIALIZED"
         )
         dict entry(
            int32 -3017
            string "DDCRC_UNKNOWN_FEATURE"
         )
         dict entry(
            int32 -3018
            string "DDCRC_INTERPRETATION_FAILED"
         )
         dict entry(
            int32 -3019
            string "DDCRC_MULTI_FEATURE_ERROR"
         )
         dict entry(
            int32 -3020
            string "DDCRC_INVALID_DISPLAY"
         )
         dict entry(
            int32 -3021
            string "DDCRC_INTERNAL_ERROR"
         )
         dict entry(
            int32 -3022
            string "DDCRC_OTHER"
         )
         dict entry(
            int32 -3023
            string "DDCRC_VERIFY"
         )
         dict entry(
            int32 -3024
            string "DDCRC_NOT_FOUND"
         )
         dict entry(
            int32 -3025
            string "DDCRC_LOCKED"
         )
         dict entry(
            int32 -3026
            string "DDCRC_ALREADY_OPEN"
         )
         dict entry(
            int32 -3027
            string "DDCRC_BAD_DATA"
         )
      ]

In the service I copied from ddcutil and created the following structure:

Status_Definition status_definitions[] = {
  { "DDCRC_OK", DDCRC_OK },
  { "DDCRC_DDC_DATA", DDCRC_DDC_DATA },
  { "DDCRC_NULL_RESPONSE", DDCRC_NULL_RESPONSE },
  { "DDCRC_MULTI_PART_READ_FRAGMENT", DDCRC_MULTI_PART_READ_FRAGMENT },
  { "DDCRC_ALL_TRIES_ZERO", DDCRC_ALL_TRIES_ZERO },
  { "DDCRC_REPORTED_UNSUPPORTED", DDCRC_REPORTED_UNSUPPORTED },
  { "DDCRC_READ_ALL_ZERO", DDCRC_READ_ALL_ZERO },
  { "DDCRC_RETRIES", DDCRC_RETRIES },
  { "DDCRC_EDID", DDCRC_EDID },
  { "DDCRC_READ_EDID", DDCRC_READ_EDID },
  { "DDCRC_INVALID_EDID", DDCRC_INVALID_EDID },
  { "DDCRC_ALL_RESPONSES_NULL", DDCRC_ALL_RESPONSES_NULL },
  { "DDCRC_DETERMINED_UNSUPPORTED", DDCRC_DETERMINED_UNSUPPORTED },
digitaltrails commented 9 months ago

Should libddcutil provide this info? Ask @rockowitz.

digitaltrails commented 9 months ago

Found libddcutil has ddca_rc_name() - using this now.