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])
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
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)
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])
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
def from_cdata_string(cdata_string): s = ffi.string(cdata_string) if sysver == 3: s = s.decode("UTF-8") return s
def __repr__(self): result = ffi.string(lib.ddca_dh_repr(self.c_dh)) if sysver == 3: result = result.decode("UTF-8") return result
def __repr__(self): result = "[Display_Info: dispno=%d, mfg=%s]" %\ ( self._c_dinfo.dispno, ffi.string(self._c_dinfo.mfg_id) ) return result
def sn(self): result = ffi.string(self._c_dinfo.sn) if sysver == 3: result = result.decode("UTF-8") return result
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
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