Alfred
Alfred

Reputation: 41

pythonnet in C# dll arguments

I'm using python3.7 and pythonnet version: 2.4.0,and I use the C# dll, the prototype is

bool = Read(byte, byte, byte, ref byte[], ref string)

I using ctypes but it always show TypeError: No method matches given arguments for Read the same code can run in Python2.7 and pythonnet 2.0.0 should I modified where, thanks a lot.

Read(0xB0, 0, 1, [], "")

I have tried:

data_array = ctypes.c_byte * 1
Read(0xB0, 0, 1, data_array, "")

or

data_array = ctypes.pointer((ctypes.c_byte * 1)())
Read(0xB0, 0, 1, data_array, "")

but it still show that TypeError: No method matches given arguments for Read

Upvotes: 2

Views: 1912

Answers (1)

Alfred
Alfred

Reputation: 41

I tried below and it works

import clr
from System import *
from System import Array
slave_addr = Byte(0xB0)
data_addr = Byte(0x21)
bytes_to_read = Byte(0x02)
data_array = Array[Byte]([0] * 2)
script_view = String("")
Read(slave_addr, data_addr, bytes_to_read, data_array, script_view)

Upvotes: 2

Related Questions