I am trying to recreate a DLL function call in Python. The code uses a DLL file to set the laser parameters for various material setting. Here is the original C# code:
public bool ApplyLasFile(string strLasFile)
{
if (!File.Exists(strLasFile))
{
//MessageBox.Show("File not found", "Error", MessageBoxButtons.OK);
return false;
}
Char[] arr = strLasFile.ToCharArray();
ApplyLAS(arr, strLasFile.Length);
return true;
}
Here is my python code:
def setLaserSettings(input):
#laserSettings(power (0-1000), speed (0-1000), height (0-4000), ppi (0-1000))
input=input.upper()
if(input=="ABS"):
settings=laserSettings(825, 1000)
elif(input=="STAINLESS"):
settings=laserSettings(1000, 84)
elif(input=="TITANIUM"):
settings=laserSettings(1000, 84)
else:
return False
charList=[]
for x in range (0, len(settings)): #convert string into c_char[]
charList.append(c_char(settings[x]))
#print charList
print ULSLib.ApplyLAS(charList, len(settings))
The DLL call ULSLib.ApplyLAS(charList, len(settings))
is returning the error ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1
. I started out with just using list(settings)
to stand in for ToCharArray()
, and when that didn't work I built a c_char array per the Python ctypes man page. However, I am still getting that error. Does anybody see what I am missing? Thanks for any help you can offer.
Edit: I have also tried list(string)
and list(charList)
and both return the same error.