Hi,
I have a .c library which I want to use through my python code. The c function that I am calling is:
But when I write in my python code as follows:
I have a .c library which I want to use through my python code. The c function that I am calling is:
crc32Word(uint32_t crc, const void *buffer, uint32_t size)
.But when I write in my python code as follows:
from ctypes import * so_file = "/home/pi/serial_communication/crc.so" crc = CDLL(so_file) INTERRUPT_GPIO=12 #We only have SPI bus 0 available to us on the Pi bus = 0 #Device is the chip select pin. Set to 0 or 1, depending on the connections device = 0 # Enable SPI spi = spidev.SpiDev() # Open a connection to a specific bus and device (chip select pin) spi.open(bus, device) # Set SPI speed and mode spi.max_speed_hz = 4000000 spi.mode = 0 pi = pigpio.pi() if not pi.connected: exit() pi.set_mode(INTERRUPT_GPIO, pigpio.INPUT) C=0 def output_file_path(): return os.path.join(os.path.dirname(__file__), datetime.datetime.now().strftime("%dT%H.%M.%S") + ".csv") def spi_process(gpio,level,tick): print("Detected") data = [0]*1024 #spi.xfer([0x02]) with open(output_file_path(), 'w') as f: t1=datetime.datetime.now() for x in range(1): spi.xfer2(data) values = struct.unpack("<" +"I"*256, bytes(data)) C = crc.crc32Word(0xffffffff,data,1024) f.write("\n") f.write("\n".join([str(x) for x in values])) t2=datetime.datetime.now() print(t2-t1) print(C) input("Press Enter to start the process ") print("SM1 Process started...") spi.xfer2([0x01]) cb1=pi.callback(INTERRUPT_GPIO, pigpio.RISING_EDGE, spi_process) while True: time.sleep(1)I get error as
<class 'typeerror'>: don't know how to convert parameter 2
. Can anybody help how can I solve this issue? Thank you.