#656 Failure to correctly translate bytearray to variant in wrapper class

v1.0 (example)
open
nobody
None
5
2014-08-14
2013-08-09
laptop2d
No

I think that the wrapper is not translating the data correctly to a variant to send to the activex control. I've tried sending it data in different ways, each time I get the same error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\win32com\gen_py\98E1A88B-EC78-4F8E-
  9BC4-569EEBB08753x0x1x0.py", line 73, in WritePipe
return self._oleobj_.InvokeTypes(5, LCID, 1, (19, 0), ((12, 1),),buffer)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0,
    -2147024809), None)

This is how I've sent the data:
Calling Writepipe with ctypes in python(2.7.5):

import win32com.client
import pythoncom
from ctypes import *
outByteBuffer1 = c_byte * 12
outByteBuffer = outByteBuffer1(0,0,0,0,9,85,206,172,6,0,0,0)
errorCode = usbApp.WritePipe(outByteBuffer);

I've also tried calling it normally:

import win32com.client
import pythoncom
x = outByteBuffer1(0,0,0,0,9,85,206,172,6,0,0,0)
errorCode = usbApp.WritePipe(x);

Here is the python wrapper function definition

def WritePipe(self, buffer=defaultNamedNotOptArg):
'method WritePipe'
return self._oleobj_.InvokeTypes(5, LCID, 1, (19, 0), ((12, 1),),buffer)

This is how you would call it in C#:

byte[] outByteBuffer2 = new byte[] {0,0,0,0,9,85,206,6,0,0,0};
errorCode = device.WritePipe(outByteBuffer);

Here is the C# wrapper:

[DispId(5)]
uint WritePipe(object buffer);

Discussion

  • laptop2d
    laptop2d
    2013-09-05

    The wrapper is not the problem, I have since discovered that this works in python 3.3 but not in 2.7. It is a problem with pywin32