0
我的/ dev /中有一个fpga设备节点。要与其驱动程序通信,我需要使用以下C代码。如何将结构传递给python中的linux设备节点?
struct pci_cmd {
unsigned int bar_id;
unsigned int command;
void *device_addr;
void *user_addr;
};
ssize_t f = open ("/dev/de4", O_RDWR);
unsigned short val;
struct pci_cmd read_cmd = { 0, 0, 0x2, &val };
read (f, &read_cmd, sizeof(val));
我发现python中有struct结构类,但os.read(fd, n)
只接受两个参数。任何想法在Python中做到这一点?
这不是一个tty I/O。这是一个字符设备。问题是设备驱动程序需要struct pci_cmd信息。 – house