C# dll 参数中的 pythonnet
pythonnet in C# dll arguments
我用的是python3.7和pythonnet版本:2.4.0,我用的是C#dll,原型是
bool = Read(byte, byte, byte, ref byte[], ref string)
我使用 ctypes 但它总是显示 TypeError: No method matches given arguments for Read
相同的代码可以 运行 in Python2.7 和 pythonnet 2.0.0
是不是应该修改哪里呢,非常感谢
Read(0xB0, 0, 1, [], "")
我试过:
data_array = ctypes.c_byte * 1
Read(0xB0, 0, 1, data_array, "")
或
data_array = ctypes.pointer((ctypes.c_byte * 1)())
Read(0xB0, 0, 1, data_array, "")
但它仍然显示 TypeError: No method matches given arguments for Read
我在下面尝试过并且有效
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)
我用的是python3.7和pythonnet版本:2.4.0,我用的是C#dll,原型是
bool = Read(byte, byte, byte, ref byte[], ref string)
我使用 ctypes 但它总是显示 TypeError: No method matches given arguments for Read 相同的代码可以 运行 in Python2.7 和 pythonnet 2.0.0 是不是应该修改哪里呢,非常感谢
Read(0xB0, 0, 1, [], "")
我试过:
data_array = ctypes.c_byte * 1
Read(0xB0, 0, 1, data_array, "")
或
data_array = ctypes.pointer((ctypes.c_byte * 1)())
Read(0xB0, 0, 1, data_array, "")
但它仍然显示 TypeError: No method matches given arguments for Read
我在下面尝试过并且有效
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)