Seite 1 von 1

ioctl mit Pointer

Verfasst: Donnerstag 12. Mai 2005, 11:59
von rayo
Hi

Ich hab einen Ioctl bei dem man ein Struct mit Pointer drin übergeben muss. Normalerweise mach ichs mit struct.pack damit ich das c-struct übergeben kann (Datentypen Int 1/2/4Byte). Aber was mach ich mit einem Pointer? Das gibts ja nicht wirklich in Python, was kann ich da hineinpacken damit der Call funktioniert?

Hat einer eine Ahnung?

Hier noch 3 Structs bei denen es einen Pointer drin hat.

Code: Alles auswählen

typedef struct osd_cmd_s {
        OSD_Command cmd;
        int x0;
        int y0;
        int x1;
        int y1;
        int color;
        void __user *data;
} osd_cmd_t;

struct video_still_picture {
        char __user *iFrame;        /* pointer to a single iframe in memory */
        int32_t size;
};

typedef struct video_spu_palette {      /* SPU Palette information */
	int length;
	uint8_t *palette;
} video_spu_palette_t;
Gruss

Verfasst: Donnerstag 12. Mai 2005, 12:52
von CM
Was hast Du vor? Einen Pythonwrapper für C-Datentypen zu entwerfen? C-structs in Python zu übernehmen?

Ehrlich gesagt: Ich verstehe zunächst einmal Deine Frage nicht.

Gruß,
Christian

Verfasst: Donnerstag 12. Mai 2005, 14:04
von jens
Ich weiß auch nicht so recht was gemeint ist... Suchst du vielleicht sowas wie ich mit read_variable_String() hier http://www.python-forum.de/viewtopic.php?p=17226#17226 gemacht habe?

Verfasst: Donnerstag 12. Mai 2005, 19:27
von rayo
Also habs jetzt gelöst. Hab mich wohl unverständlich ausgedrückt.

Brauchte den Pointer auf Daten im Speicher.
Habs mit array.array('B', string).buffer_info() gemacht. Da bekomm ich (Pointer, length) zurück.

Code: Alles auswählen

#osd_cmd_t
struct.pack('IiiiiiP', cmd, x0, y0, x1, y1, color, array.array('B', string).buffer_info()[0])
gruss