示例#1
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])
示例#2
0
def get_display_info_list():
    print("(get_display_info_list) Starting")
    dilist = lib.ddca_get_display_info_list()
    print("ct: %d" % dilist.ct)
    result = []
    for ndx in range(dilist.ct):
        di = dilist.info[ndx]
        print("di: ", dir(di))
        print(ffi.string(di.mfg_id))
        dinfo = Display_Info(di)
        result.append(dinfo)
    return result
示例#3
0
def convert_to_python(s):
    type = ffi.typeof(s)
    if type.kind == 'struct':
        return dict(__convert_struct_field(s, type.fields))
    elif type.kind == 'array':
        if type.item.kind == 'primitive':
            if type.item.cname == 'char':
                return ffi.string(s)
            else:
                return [s[i] for i in range(type.length)]
        else:
            return [convert_to_python(s[i]) for i in range(type.length)]
    elif type.kind == 'primitive':
        return int(s)
示例#4
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])
示例#5
0
 def create_from_c_table(cls, c_table):
     print("(Feature_Value_Table.create_from_c_table) c_table=%s" % c_table)
     table = Feature_Value_Table(c_table)
     table.entries = {}
     ndx = 0
     while True:
         (k, v) = (c_table[ndx].value_code, c_table[ndx].value_name)
         if k == 0 and v == ffi.NULL:
             break
         v2 = ffi.string(v)
         if sysver == 3:
             v2 = v2.decode("UTF-8")
         # print("ndx=%d, c_table=%s, value_code=%s, value_name=%s" % (ndx, c_table[ndx], k, v2) )
         table.entries[k] = v2
         ndx = ndx + 1
     return table
示例#6
0
def from_cdata_string(cdata_string):
    s = ffi.string(cdata_string)
    if sysver == 3:
        s = s.decode("UTF-8")
    return s
示例#7
0
 def __repr__(self):
     result = ffi.string(lib.ddca_dh_repr(self.c_dh))
     if sysver == 3:
         result = result.decode("UTF-8")
     return result
示例#8
0
 def __repr__(self):
     result = "[Display_Info: dispno=%d, mfg=%s]" %\
                      ( self._c_dinfo.dispno, ffi.string(self._c_dinfo.mfg_id) )
     return result
示例#9
0
 def sn(self):
     result = ffi.string(self._c_dinfo.sn)
     if sysver == 3:
         result = result.decode("UTF-8")
     return result
示例#10
0
 def model_name(self):
     # print("model_name")
     result = ffi.string(self._c_dinfo.model_name)
     if sysver == 3:
         result = result.decode("UTF-8")
     return result
示例#11
0
def get_feature_name(feature_code):
    s = ffi.string(lib.ddca_get_feature_name(feature_code))
    if sysver == 3:
        s = s.decode("UTF-8")
    return s