Hello,

I don't know how to do something with the win32com module (or maybe with 
another...).
I post my problem on stack overflow but I didn't get any reply.

I do that piece of code for a project in my job for testing some possibilities 
of a zebra scanner, I chose python because it's interpreted and very easy for 
doing tests and because I know it a bit and I didn't want to invest time and 
money in Visual studio.

I'm trying to discuss with a Zebra RFID/bar code scanner using the WMI provider 
as recommended in dev guides, it runs fairly well with properties, I got method 
names and parameters too, but I didn't reach to make run method with byref 
parameter e.g. method(inpar, outpar) both parameters are strings (xml message), 
the function returns a status code correctly, see code below.

I searched on the net without finding solution, I give the corresponding .net 
c# code to call the method after python code (from the prog examples of the SDK 
guide for scanner), if it can help you to help me

Python code
# -*- coding: utf-8 -*-
import win32com.client

objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
strComputer = "."
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
oos = objSWbemServices.ExecQuery("SELECT * FROM Symbol_BarcodeScanner")
oo = oos[0]

# list all object properties
for op in oo.Properties_:
    print(op.Name, op.Value)

# list all object methods
for om in oo.Methods_:
    out_parameter_names = []
    in_parameters_names = []
    if om.OutParameters:
        out_parameter_names = [(i.Name, i.IsArray) for i in 
om.OutParameters.Properties_]
    if om.InParameters:
        in_parameters_names = [(i.Name, i.IsArray) for i in 
om.InParameters.Properties_]
    print('func : ',om.Name)
    print('In : ',in_parameters_names)
    print('Out : ',out_parameter_names)

inxml="<attrib_list>533,534</attrib_list>"
outxml=""
oo._FlagAsMethod('GetAttributes')
a =  = oo.GetAttributes(inxml,outxml)

.net C# code to call a method.

               ManagementObject o = new ManagementObject();
                o.Scope = mgmtScope;
                o.Path = new 
ManagementPath("Symbol_BarcodeScanner.PartNumber='" + strPartNumber + 
"',SerialNumber='" + strSerialNumber + "'");

          // Create ManagementBaseObject and get the parameters to the Method 
"GetAttributes"
                        inParams = o.GetMethodParameters("GetAttributes");
                        // Fill the Parameter "attNumberList" with the 
attributeList string
                        inParams["attNumberList"] = attributeList;

                        // Invoke the "GetAttributes" Method and save the 
result to a new ManagementBaseObject
                        outparams = o.InvokeMethod("GetAttributes", inParams, 
null);

Thanks for your help

Regards.

Pascal.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to