Exemplo n.º 1
0
    def get_vcp_value(self,
                      feature_code,
                      feature_type=lib.DDCA_UNSET_VCP_VALUE_TYPE_PARM):
        print("(get_vcp_value) Starting")
        pvalrec = ffi.new("DDCA_Any_Vcp_Value **", init=ffi.NULL)
        rc = lib.ddca_get_any_vcp_value(self.c_dh, feature_code, feature_type,
                                        pvalrec)
        if rc != 0:
            excp = create_ddc_exception(rc)
            raise excp

        # print("pvalrec: ", pvalrec)
        # print("unpacked: ", ffi.unpack(pvalrec,8))

        valrec = pvalrec[0]
        print("valrec: ", valrec)
        # v2 = convert_to_python(valrec)
        # print("v2: ",  v2)

        # return valrec
        if valrec.value_type == lib.DDCA_NON_TABLE_VCP_VALUE:
            retval = Non_Table_Vcp_Value(valrec.opcode, valrec.val.c_nc.mh,
                                         valrec.val.c_nc.ml,
                                         valrec.val.c_nc.sh,
                                         valrec.val.c_nc.sl)
        else:
            # bytestring = ??
            bytestring = None
            retval = Table_Vcp_Value(valrec.opcode, bytestring)
        return retval
Exemplo n.º 2
0
 def get_formatted_vcp_value(self, feature_code):
     ps = ffi.new("char **", init=ffi.NULL)
     rc = lib.ddca_get_formatted_vcp_value(self.c_dh, feature_code, ps)
     if rc != 0:
         excp = create_ddc_exception(rc)
         raise excp
     return ffi.string(ps[0])
Exemplo n.º 3
0
 def open(cls, dref):
     pc_dh = ffi.new("void **", init=ffi.NULL)
     rc = lib.ddca_open_display(dref.c_dref, pc_dh)
     if rc != 0:
         excp = create_ddc_exception(rc)
         raise excp
     dh = Display_Handle()
     dh.c_dh = pc_dh[0]
     return dh
Exemplo n.º 4
0
 def create_from_did(cls, did):
     c_dref = ffi.new("void **", init=ffi.NULL)
     rc = lib.ddca_create_display_ref(did.c_did, c_dref)
     if rc != 0:
         excp = create_ddc_exception(rc)
         raise excp
     # dref = Display_Ref()
     # dref.c_dref = c_dref[0]
     dref = Display_Ref(c_dref[0])
     return dref
Exemplo n.º 5
0
 def create_from_string(cls, cap_string):
     print("(create_from_string) cap_string = %s" % cap_string)
     c_parsed_caps = ffi.new("DDCA_Capabilities **", init=ffi.NULL)
     print(c_parsed_caps)
     print(type(cap_string))
     print(type(c_parsed_caps))
     rc = lib.ddca_parse_capabilities_string(cap_string, c_parsed_caps)
     if rc != 0:
         excp = create_ddc_exception(rc)
         raise excp
     parsed = Parsed_Capabilities(c_parsed_caps[0])
     return parsed
Exemplo n.º 6
0
    def create_by_vcp_version(cls, feature_code, mccs_version_id):
        print("(create_by_vcp_version) mccs_version_id=%d" % mccs_version_id)
        # TODO: validate mccs_version_id

        c_feature_info = ffi.new("DDCA_Version_Feature_Info **", init=ffi.NULL)
        rc = lib.ddca_get_feature_info_by_vcp_version(feature_code,
                                                      mccs_version_id,
                                                      c_feature_info)
        if rc != 0:
            excp = create_ddc_exception(rc)
            raise excp
        finfo = Feature_Info(c_feature_info[0])
        return finfo
Exemplo n.º 7
0
    def get_mccs_version_id(self):
        pid = ffi.new("DDCA_MCCS_Version_Id *")
        # pid = ffi.new("lib.DDCA_MCCS_Version_Id *", init=ffi.NULL)
        # pid = ffi.new("int *")
        rc = lib.ddca_get_mccs_version_id(self.c_dh, pid)
        if rc != 0:
            excp = create_ddc_exception(rc)
            raise excp
        print("pid: ", pid)
        print("unpacked: ", ffi.unpack(pid, 4))

        id = pid[0]
        print("id: ", id)
        return id
Exemplo n.º 8
0
    def create_by_query(cls, feature_code, mccs_version_id):
        print("(create_by_query) feature_code = 0x%02x, mccs_version=%d" %
              (feature_code, mccs_version_id))
        # TODO: validate mccs_version_id

        pc_table = ffi.new("DDCA_Feature_Value_Table *", init=ffi.NULL)
        rc = lib.ddca_get_simple_sl_value_table(feature_code, mccs_version_id,
                                                pc_table)
        if rc != 0:
            raise create_ddc_exception(rc)
        t = Feature_Value_Table.create_from_c_table(pc_table[0])
        # print(t)
        # return pc_table[0]
        return t
Exemplo n.º 9
0
    def get_capabilities_string(self):
        ps = ffi.new("char **", init=ffi.NULL)
        rc = lib.ddca_get_capabilities_string(self.c_dh, ps)
        if rc != 0:
            excp = create_ddc_exception(rc)
            raise excp

        # print("ps: ", ps)
        # print("unpacked: ", ffi.unpack(ps,4))

        # s=ps[0]
        # print("s: ", s)
        # s2 = ffi.string(s)
        # print("s2: ", s2)

        return ffi.string(ps[0])
Exemplo n.º 10
0
    def create_by_dispno(cls, dispno):
        # c_did1 = ffi.new("void **")
        c_did2 = ffi.new("void **", init=ffi.NULL)
        # cannot instantiate ctype void of unknown size
        # c_did3 = ffi.new("void *")
        # c_did4 = ffi.new("void *", init=ffi.NULL)

        rc = lib.ddca_create_dispno_display_identifier(dispno, c_did2)
        if rc != 0:
            excp = create_ddc_exception(rc)
            raise excp
        # print(c_did2)
        # print(ffi.unpack(c_did2,1))

        c_did2u = c_did2[0]
        # print(c_did2u)

        result = Display_Identifier()
        result.c_did = c_did2u
        return result
Exemplo n.º 11
0
    def get_mccs_version(self):
        print("(get_mccs_version) Starting.")
        pv = ffi.new("DDCA_MCCS_Version_Spec *")
        rc = lib.ddca_get_mccs_version(self.c_dh, pv)
        if rc != 0:
            raise create_ddc_exception(rc)
        print("pv: ", pv)
        print("unpacked: ", ffi.unpack(pv, 4))

        ver = pv[0]
        print("ver: ", ver)
        # print("unpacked: ", ffi.unpack(ver,2))

        print("ver.major: ", ver.major)

        v2 = convert_to_python(ver)
        print("v2: ", v2)
        # return as dictionary
        # return v2

        return (ver.major, ver.minor)