我试图将库从C++转换为Java。我有一个指针问题..
来自C++的代码是:
int DECL2 daveSetBit(daveConnection * dc,int area, int DB, int byteAdr, int bitAdr) {
int a=1;
return daveWriteBits(dc, area, DB, 8*byteAdr+bitAdr, 1, &a);
}和daveWriteBits声明是:
daveWriteBits(daveConnection * dc,int area, int DB, int start, int len, void * buffer)我怎样才能将其转换成java?我不知道如何将指针& a转换为java语言..
public int SetBits(
int area,
int DBnum,
int byteAdr,
int bitAdr) {
int a=1;
return writeBits(area, DBnum, 8*byteAdr+bitAdr, 1, ??? )
}更新:
我忘了在Java中添加WriteBits函数的一部分..
public int writeBits(
int area,
int DBnum,
int start,
int len,
byte[] buffer) {
int errorState = 0;
semaphore.enter();
PDU p1 = new PDU(msgOut, PDUstartOut);
p1.prepareWriteRequest();
p1.addBitVarToWriteRequest(area, DBnum, start, len, buffer);
errorState = exchange(p1);
if (errorState == 0) {
PDU p2 = new PDU(msgIn, PDUstartIn);
p2.setupReceivedPDU();
if (p2.mem[p2.param + 0] == PDU.FUNC_WRITE) {
if (p2.mem[p2.data + 0] == (byte) 0xFF) {
if ((Nodave.Debug & Nodave.DEBUG_CONN) != 0)
System.out.println("writeBytes: success");
semaphore.leave();
return 0;
}
} else {
errorState |= 4096;
}
}
semaphore.leave();
return errorState;
}