G
Guest
I've got the following umanaged code that I need to handle in C# code. The
data I read comes from an external device, by Read(ID, &data, REGLEN);
How should the code look for the structs in C# to handle "PULONG Value" in
the function call and the "PktArray[0].pbyBuf = (PUCHAR)®Addr;"
"PktArray[1].pbyBuf = (PBYTE) pValue;" statement in C# so I get read data
from an external device?
*******Code******
typedef struct
{
PBYTE pbyBuf; // Message Buffer
WORD wlen; // Message Buffer Length
LPINT lpiresult; // Contains the result of the operation
} PACKET, *pPack;
typedef struct
{
PACKET *pPack;
Int32 Inumpackets;
} XFER
DLG::Read(USHORT regAddr, PULONG Value, UCHAR regLen)
{
ULONG data;
XFER xferBlock;
PACKET PktArray[2];
INT iResult;
PktArray[0].pbyBuf = (PUCHAR)®Addr;
PktArray[0].wLen = sizeof(UCHAR); // let know how much to transmit
PktArray[0].byRW = RW_WRITE;
PktArray[0].byAddr = m_Base;
PktArray[0].lpiResult = &iResult; // if encounter an error,
// it will write to *iResult.
PktArray[1].pbyBuf = (PBYTE) pValue;
PktArray[1].wLen = regLen; // how much to receive
****App Code****
Read(ID, &data, REGLEN);
data I read comes from an external device, by Read(ID, &data, REGLEN);
How should the code look for the structs in C# to handle "PULONG Value" in
the function call and the "PktArray[0].pbyBuf = (PUCHAR)®Addr;"
"PktArray[1].pbyBuf = (PBYTE) pValue;" statement in C# so I get read data
from an external device?
*******Code******
typedef struct
{
PBYTE pbyBuf; // Message Buffer
WORD wlen; // Message Buffer Length
LPINT lpiresult; // Contains the result of the operation
} PACKET, *pPack;
typedef struct
{
PACKET *pPack;
Int32 Inumpackets;
} XFER
DLG::Read(USHORT regAddr, PULONG Value, UCHAR regLen)
{
ULONG data;
XFER xferBlock;
PACKET PktArray[2];
INT iResult;
PktArray[0].pbyBuf = (PUCHAR)®Addr;
PktArray[0].wLen = sizeof(UCHAR); // let know how much to transmit
PktArray[0].byRW = RW_WRITE;
PktArray[0].byAddr = m_Base;
PktArray[0].lpiResult = &iResult; // if encounter an error,
// it will write to *iResult.
PktArray[1].pbyBuf = (PBYTE) pValue;
PktArray[1].wLen = regLen; // how much to receive
****App Code****
Read(ID, &data, REGLEN);