import os
from pypcie import Device
# Bind to PCI device at "0000:03:00.0"
d = Device("0000:00:02.0")
# Access BAR 0
bar = d.bar[0]
# write 0xdeadbeef to BAR 0, offset 0x1000
bar.write(0x100, 0xdeadbeef)
# read BAR 0, offset 0x1004
ret = bar.read(0x104)
print(ret)
Issue:
root@PC-13:/home/work/script/script/script/pyPCIe-main# python3 test_pcie_bar.py
/sys/bus/pci/devices/0000:00:02.0/resource0
/sys/bus/pci/devices/0000:00:02.0/resource2
/sys/bus/pci/devices/0000:00:02.0/resource4
Traceback (most recent call last):
File "test_pcie_bar.py", line 6, in
d = Device("0000:00:02.0")
File "/home/work/script/script/script/pyPCIe-main/pypcie/device.py", line 23, in init
self.bar[barnum] = Bar(resfile)
File "/home/work/script/script/script/pyPCIe-main/pypcie/bar.py", line 19, in init
self.__map = mmap(fd, 0, prot=PROT_READ | PROT_WRITE)
OSError: [Errno 19] No such device
Issue: root@PC-13:/home/work/script/script/script/pyPCIe-main# python3 test_pcie_bar.py /sys/bus/pci/devices/0000:00:02.0/resource0 /sys/bus/pci/devices/0000:00:02.0/resource2 /sys/bus/pci/devices/0000:00:02.0/resource4 Traceback (most recent call last): File "test_pcie_bar.py", line 6, in
d = Device("0000:00:02.0")
File "/home/work/script/script/script/pyPCIe-main/pypcie/device.py", line 23, in init
self.bar[barnum] = Bar(resfile)
File "/home/work/script/script/script/pyPCIe-main/pypcie/bar.py", line 19, in init
self.__map = mmap(fd, 0, prot=PROT_READ | PROT_WRITE)
OSError: [Errno 19] No such device