Problem running functions from a DLL file using ctypes in Object-oriented Python -
I'm sure this will not be an answer already or will not be stupid lately I do programming with several tools Was trying to create a test program to communicate between them. Although I have created some problems with a specific device, when I am trying to call the function, on which I have "masked" with the "docked" device when I use the interactive dragon shell, it is completely (Though lots of word clubbing). But when I implement the function in an object-oriented manner, the program fails, in reality it does not fail, it does not do anything, it is the first method that is called: (ctypes and ctypes.util import Is done)
def init_hardware (self): "" in device "" auto ". Tuner ") VERSION_STRING = create_string_buffer (80) self.error_string = create_string_buffer (80) self.name =" Mori MT982EU "self.write_log (" Tuner DLL path:% s ", find_library ( 'MLibTuners')) self.maury = WinDLL ( 'MlibTuners') self.maury.get_tuner_driver_version (VERSION_STRING) if (version_string.value == ""): self.write_log ( "important: driver error to get the version") and version of self.write_log ( "DLL Number:% S "% version_string.value) self.ThreeTypeLong = c_long * 3
Now that works, everything is fine and I get the right log-entry. But when I I try to move forward a program:
def add_tuner_and_controller (self, name, Siriyl_anmber, Tunr_anmber = 0): "" inside "tuner is added to the object, the controller" self.write_log tuner "" ( "Tuner% d and controller being "% added tuner_number) TempType = self.ThreeTypeLong () self.maury.add_controller (c_short (tuner_number), c_char_p (self.file_path), c_char_p (name), c_int (0), c_int (0 ), c_long (0), c_short (SERIAL_NUMBER), self.error_string) self.maury.add_tuner (c_short (tuner_number), c_char_p (name), c_short (SERIAL_NUMBER), c_short (0), c_short (1), indicator (c_double ()), TempType, indicator (c_double ()), indicator (c_double ()), indicator (c_double ()), self.error_string)
The program suddenly stops working / keeps going, nothing can happen when "self. Silence "-line. When I keep everything in the init_hardware method it works completely, so I guess that there is something with minor memory" error "or purpose-oriented structure. Is there any way to isolate the tasks like this? Or do I have to stop it on a large part of my code?
Edit:
Documentation information :
Add_tuner adds a tuner or updates to the function tuner object.
< pre> Short add_tuner (Short tuner_number, four models [], short SERIAL_NUMBER short Ctlr_num short Ctlr_port, short * no_of_motors, long Max_range [], double * fmin, double * Fmax, double * fcrossover, char [] ERROR_STRING ) Output : no_motors, max_range (array of three numbers), fin, fmx, forocoror, error_string (80+ character long), function Money-return-> Error flag
Adds or updates a controller function in the tuner object
small add_controller (Low controller_number, four driver [], four models [], int timeout, int a, long delay_mms, four error_string [])
output : Error_string, function-return-> error flag
let me know about your exact problem Not sure, but For An Some general tips:
Those functions that you recommended its establishment in outside are calling constructor, I strongly constructor. Once you have declared argtypes
, you should not insert all the arguments into the form of c_short
, c_double
, etc. In addition, if you accidentally pass incorrect logic in a C function, Python will increase a runtime error, instead of crashing within DLL.
One more little information, but you x = 0;
Or maybe (c_double) ()
instead of the pointer (c_double ()) in the tuner and controller.
I am writing some CTIPs in Python 2.6 too. , And I have not seen anything that you are describing. There is apparently no Python bug report from there, either, I strongly believe that there is only one minute description that we both are appearing in your system, which is the problem.
Comments
Post a Comment