Message93043
Hi.
I hope I'm in the good thing to expose my problem...
I try to make a script in Python working under ControlDesk, a dSpace
simulator.
In this script I call an ActiveX application given by an external
software, System Monitor, to get some information from my ECU (Engine
Control Unit).
I can access to the ActiveX, I can call functions but only ones which
don't need output argument.
When I use functions which need only input argument, it's working
perfectly.
If I want to use functions which need some output argument, I have a
message error from Python...
========================================================================
Here is an example of a working script:
***************************************
import os
import win32com.client
if __name__ == '__main__':
print ""
Kit = "C:\\U\\TNR_MES_2009\\THR2RAT11BA01.m"
SysMonApp = win32com.client.Dispatch("System Monitor API")
if SysMonApp == None:
print "Pas d'instance System Monitor"
#endif
Err = SysMonApp.SetLiveUpdates(True)
if Err != 0:
print Err
#endif
print "LiveUpdates Actif"
Err = SysMonApp.MatlabImport(Kit)
if Err !=0:
print Err
#endif
print "Import kit .m termine"
SysMonApp = None
print "Fin du script"
#endif
========================================================================
Here is an example of a NON-working script:
import os
import win32com.client
from ctypes import *
if __name__ == '__main__':
print ""
Kit = "C:\\U\\TNR_MES_2009\\THR2RAT11BA01.m"
SysMonApp = win32com.client.Dispatch("System Monitor API")
if SysMonApp == None:
print "Pas d'instance System Monitor"
#endif
#OnlineSt = False
OnlineSt = c_double()
Err = SysMonApp.GetOnline(byref(OnlineSt))
if Err != 0:
print Err
#endif
if OnlineSt == True:
print "ECU Online"
else:
print "ECU Offline"
#endif
SysMonApp = None
print "Fin du script"
#endif
========================================================================
The error message is:
Traceback (most recent call last):
File "C:\Python26\Lib\site-
packages\pythonwin\pywin\framework\scriptutils.py", line 325, in
RunScript
exec codeObject in __main__.__dict__
File "C:\U\TNR_MES_2009\EssaiSysMonSeul_Output_KO.py", line 16, in
<module>
Err = SysMonApp.GetOnline(byref(OnlineSt))
File "<COMObject System Monitor API>", line 2, in GetOnline
TypeError: Objects of type 'CArgObject' can not be converted to a COM
VARIANT
========================================================================
As you can see I use the ctype library to try pass output argument,
using byref.
But I also try to pass argument directly under python, without ctypes:
OnlineSt = False
Err = SysMonApp.GetOnline(OnlineSt)
and I had the folowing error message:
Traceback (most recent call last):
File "C:\Python26\Lib\site-
packages\pythonwin\pywin\framework\scriptutils.py", line 325, in
RunScript
exec codeObject in __main__.__dict__
File "C:\U\TNR_MES_2009\EssaiSysMonSeul_Output_KO.py", line 16, in
<module>
Err = SysMonApp.GetOnline(OnlineSt)
File "<COMObject System Monitor API>", line 2, in GetOnline
com_error: (-2147352571, 'Le type ne correspond pas.', None, 1)
========================================================================
The help for the activeX function explain that the output arguments
need to be pass as pointer:
GetOnline
Returns whether the ECU is online or not.
Arguments:
bool* bResult - whether the ECU is online or offline.
Do you have any idea to solve this problem?
Many thanks
Benjamin |
|
Date |
User |
Action |
Args |
2009-09-23 16:04:44 | benji13 | set | recipients:
+ benji13 |
2009-09-23 16:04:44 | benji13 | set | messageid: <1253721884.72.0.921997932907.issue6979@psf.upfronthosting.co.za> |
2009-09-23 16:04:43 | benji13 | link | issue6979 messages |
2009-09-23 16:04:42 | benji13 | create | |
|