<font size="4">Hi all,</font><div style="text-align:left"><font size="4">I'm writing a script to control a <font color="#333333"><em style="line-height:14px;font-style:normal;font-family:arial,sans-serif">PCMCIA</em> </font>device, the driver provided by the vendor is a dll file. I just want to call functions in it, but <span style="font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17px;text-align:left;background-color:rgb(255,255,255)">i just don't know why I keep getting a <i>[</i></span><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><span style="line-height:17px"><i><b>The instruction at "0x7c9108d3" referenced memory at "0xfffffff8". The memory could not be "read"</b></i></span></font><span style="background-color:rgb(255,255,255);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17px;text-align:left"><i>]. </i>Here is the documents say:</span></font></div>
<div style="text-align:left"><span style="background-color:rgb(255,255,255);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17px;text-align:left"><br></span></div><div style="text-align:left">
<span style="background-color:rgb(255,255,255);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17px;text-align:left"><i>//declaration</i></span></div><div style="text-align:left">
<span style="background-color:rgb(255,255,255);text-align:left;font-size:14px;line-height:17px"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><i>XLstatus xlGetDriverConfig(XLdriverConfig *pDriverConfig) </i></font></span></div>
<div style="text-align:left"><span style="background-color:rgb(255,255,255);text-align:left;font-size:14px;line-height:17px"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><i><br></i></font></span></div>
<div style="text-align:left"><span style="background-color:rgb(255,255,255);text-align:left"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><div><span style="font-size:14px;line-height:17px"><i>typedef struct s_xl_driver_config  { </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned int      dllVersion; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int      channelCount;  </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int      reserved[10]; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    XLchannelConfig   channel[XL_CONFIG_MAX_CHANNELS]; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>} XLdriverConfig; </i></span></div><div><span style="font-size:14px;line-height:17px"><i><br>
</i></span></div><div><span style="font-size:14px;line-height:17px"><i>//types</i></span></div><div><span style="font-size:14px;line-height:17px"><i>typedef struct s_xl_channel_config { </i></span></div><div><span style="font-size:14px;line-height:17px"><i><br>
</i></span></div><div><span style="font-size:14px;line-height:17px"><i>    char            name [XL_MAX_LENGTH + 1]; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned char   hwType; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned char   hwIndex;  </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned char   hwChannel; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned short  transceiverType;  </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned int    transceiverState; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned char   channelIndex;    </i></span></div><div>
<span style="font-size:14px;line-height:17px"><i><br></i></span></div><div><span style="font-size:14px;line-height:17px"><i>    XLuint64      channelMask;      //here  </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  channelCapabilities; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned int  channelBusCapabilities; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned char isOnBus; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  connectedBusType; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    XLbusParams   busParams; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  driverVersion; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  interfaceVersion; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned int  raw_data[10]; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  serialNumber; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  articleNumber; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    char          transceiverName [XL_MAX_LENGTH + 1]; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  specialCabFlags; </i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    unsigned int  dominantTimeout; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned int  reserved[8]; </i></span></div><div><span style="font-size:14px;line-height:17px"><i>} XLchannelConfig; </i></span></div>
<div style="font-size:14px;line-height:17px"><i><br></i></div><div><div><span style="font-size:14px;line-height:17px"><i>typedef unsigned __int64 XLuint64;</i></span></div><div style="font-size:14px;line-height:17px"><i><br>
</i></div></div><div><div><span style="font-size:14px;line-height:17px"><i>typedef struct {                                                                         </i></span></div><div><span style="font-size:14px;line-height:17px"><i>  unsigned int busType;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>  union {</i></span></div><div><span style="font-size:14px;line-height:17px"><i>    struct {</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned int bitRate;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>      unsigned char sjw;</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned char tseg1;</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned char tseg2;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>      unsigned char sam;  // 1 or 3</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned char outputMode;</i></span></div><div><span style="font-size:14px;line-height:17px"><i>    } can;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    struct {</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned int  activeSpeedGrade;</i></span></div><div><span style="font-size:14px;line-height:17px"><i>      unsigned int  compatibleSpeedGrade;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>    } most;</i></span></div><div><span style="font-size:14px;line-height:17px"><i>    unsigned char raw[32];</i></span></div><div><span style="font-size:14px;line-height:17px"><i>  }data;</i></span></div>
<div><span style="font-size:14px;line-height:17px"><i>} XLbusParams; </i></span></div><div style="font-size:14px;line-height:17px"><br></div></div></font></span></div><div style="text-align:left"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif" size="4"><span style="line-height:17px">There is my python script below:</span></font></div>
<div style="text-align:left"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><span style="font-size:14px;line-height:17px"><br></span></font></div><div style="text-align:left"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><i><div>
<span style="font-size:14px;line-height:17px">from ctypes import *</span></div><div><span style="font-size:14px;line-height:17px">vxlapi = WinDLL("vxlapi.dll")</span></div><div><span style="font-size:14px;line-height:17px">PyxlGetDriverConfig = vxlapi.xlGetDriverConfig</span></div>
<div><span style="font-size:14px;line-height:17px"><br></span></div><div><div><span style="font-size:14px;line-height:17px">class PyXLchannelConfig(Structure):</span></div><div><span style="font-size:14px;line-height:17px">    _fields_ = [("Pyname",c_char*32),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyhwType",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyhwIndex",c_ubyte),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyhwChannel",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PytransceiverType",c_ushort),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PytransceiverState",c_ushort),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyconfigError",c_ushort),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PychannelIndex",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PychannelMask",c_longlong),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PychannelCapabilities",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("PychannelBusCapabilities",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                </span></div><div><span style="font-size:14px;line-height:17px">                ("PyisOnBus",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyconnectedBusType",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PybusParams",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                </span></div><div><span style="font-size:14px;line-height:17px">                ("PydriverVersion",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyinterfaceVersion",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("Pyraw_data",c_uint*10),</span></div>
<div><span style="font-size:14px;line-height:17px">                </span></div><div><span style="font-size:14px;line-height:17px">                ("PyserialNumber",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyarticleNumber",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                </span></div><div><span style="font-size:14px;line-height:17px">                ("PytransceiverName",c_char*32),</span></div><div><span style="font-size:14px;line-height:17px">                </span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyspecialCabFlags",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("PydominantTimeout",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PydominantRecessiveDelay",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyrecessiveDominantDelay",c_ubyte),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyconnectionInfo",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PycurrentlyAvailableTimestamps",c_ubyte),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyminimalSupplyVoltage",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PymaximalSupplyVoltage",c_ubyte),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PymaximalBaudrate",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("PyfpgaCoreCapabilities",c_ubyte),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PyspecialDeviceStatus",c_ubyte),</span></div><div><span style="font-size:14px;line-height:17px">                ("PychannelBusActiveCapabilities",c_ushort),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PybreakOffset",c_ushort),</span></div><div><span style="font-size:14px;line-height:17px">                ("PydelimiterOffset",c_ushort),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("Pyreserved",c_uint*3)</span></div><div><span style="font-size:14px;line-height:17px">                ]</span></div><div><span style="font-size:14px;line-height:17px"><br>
</span></div><div><span style="font-size:14px;line-height:17px">class PyXLdriverConfig(Structure):</span></div><div><span style="font-size:14px;line-height:17px">    _fields_ = [("PydllVersion",c_uint),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("PychannelCount",c_uint),</span></div><div><span style="font-size:14px;line-height:17px">                ("Pyreserved",c_uint*10),</span></div>
<div><span style="font-size:14px;line-height:17px">                ("Pychannel",PyXLchannelConfig*64)</span></div><div><span style="font-size:14px;line-height:17px">                ]</span></div></div><div style="font-size:14px;line-height:17px">
<br></div></i></font></div><div style="text-align:left"><span style="background-color:rgb(255,255,255);text-align:left;line-height:17px"><font face="Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif"><div style="font-size:14px;font-style:italic">
if __name__ == "__main__":</div><div style="font-size:14px;font-style:italic">    drivercfg = PyXLdriverConfig()</div><div style="font-size:14px;font-style:italic">    PyxlGetDriverConfig(byref(drivercfg))</div>
<div style="font-size:14px;font-style:italic"><br></div><div><font size="4">Could you  help me out of this, Thank you very much!</font></div></font></span></div><div><div><br></div>-- <br><div>Best Regards</div>
<div>Edward</div><br>
</div>