in reply to Help using ioctl to write a PCI device
I think the problem is that you are passing a ref to 0x03 when you want to pass the value itself. I have no idea if your conversion leads to &PCICARD_SET_REGISTER returning a value. This is simply an integer, so given you can check the value in your working C code, and check what you have in your Perl would be a good sanity check. Obviously these values need to be the same. Also you don't check your file open worked although I don't see why it should fail given you have sufficient permissions to do the open in your C. I would suggest:
#!/usr/bin/perl require 'sys/ioctl.ph'; require '_h2ph_pre.ph'; sub PCICARD_IOC_NUM () { ord('0'); } sub PCICARD_SET_REGISTER () { &_IOR( &PCICARD_IOC_NUM, 1, 'int' ); } sub PCICARD_GET_REGISTER () { &_IOW( &PCICARD_IOC_NUM, 2, 'int' ); } # Sanity check..... print "PCICARD_SET_REGISTER is %d\n", &PCICARD_SET_REGISTER; # you may need $value = pack 'C', 0x03 # as this will pack 0x03 into an unsigned 8 bit (char) value $value = 0x03; open(PCI, '+</dev/pcimax') or die "Can't open card $!\n"; ioctl(PCI, &PCICARD_SET_REGISTER, $value) or die "ioctl error $!\n"; close(PCI);
As a last resort you could just dump your working C code into an Inline::C function. Sometimes this is the easiest thing to do.
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help using ioctl to write a PCI device
by p-rex (Novice) on Nov 02, 2004 at 15:01 UTC | |
by tachyon (Chancellor) on Nov 02, 2004 at 22:53 UTC | |
|
Re^2: Help using ioctl to write a PCI device
by p-rex (Novice) on Nov 02, 2004 at 14:28 UTC |