I am trying to connect to a PLC via a DLL (C API distributed by the PLC manufacturer). I am using Python 3.1, which is built into the scripting environment in other software (x64 - Windows 7).
I managed to get some DLL functions, but now get a "Read Access Violation" which I cannot solve.
DLL function information:
LONG AdsSyncReadReq( PAmsAddr pAddr, ULONG nIndexGroup, ULONG nIndexOffset, ULONG nLength, PVOID pData );
Options:
- pAddr: [in] NetId structure and ADS server port number.
- nIndexGroup: [in] Index group.
- nIndexOffset: [in] The offset of the index.
- nLength: [in] Data length in bytes.
- pData: [out] Pointer to a data buffer that will receive data.
- Return value: returns the error status of the function.
AmsAddr Structure:
typedef struct { AmsNetId netId; USHORT port; } AmsAddr, *PAmsAddr;
AmsNetId Structure
typedef struct { UCHAR b[6]; } AmsNetId, *PAmsNetId;
Python implementation:
# -*- coding: utf-8 -*- from ctypes import *
I hope someone cannot understand what happened. I am only an advanced beginner in Python programming with no experience at all in C
Thank you in advance
source share