I am trying to convert some c++ code into python for my project. but I am not getting the same output from both codes.
so the c++ code is
int fd_frbuf;
fd_frbuf = open("/dev/fb0", O_RDWR|O_SYNC);
printf("%d\n", fd_frbuf);
if (fd_frbuf < 1) {
printf("Invalid fb0 device file\n");
}
the output is 3.
and my python code is
fd_frbuf = open("/dev/fb0", "r+b")
print(fd_frbuf.read())
output is nothing, so my check for fb0 is available or not by doing "< 1"
is always false.
I have tried,
fd_frbuf = os.open("/dev/fb1", os.O_RDWR|os.O_SYNC) print(os.read(fd_frbuf, 1)
tried to print differently,
print(struct.unpack('i', fd_frbuf.read(4))[0]) print(np.fromfile(fd_frbuf, dtype=np.uint32))
how can I read this file so that I get the same output as c++?