Samples: TcJavaToAds The existing connection is used to release the handles. The parameters for the sum command consist of IndexGroup (0xf081) - call of the sum command, IndexOffset (0x2) - number of subcommands, ReadLength (cbRelRes) - size specification of the data to be read, ReadData (pBuffRelRes) - memory that accepts read data, WriteLength (cbRel) - size specification of the data to be sent and WriteLength (pBuffRel) - memory that contains data to be sent. Finally, the handles must be released and the port closed.
// Release handles - Second task cleared err = AdsCallDllFunction.adsSyncReadWriteReq( addr, 0xf081, // ADS list-write command 0x2, // number of ADS-sub commands relResBuffSize, // we expect an ADS-error-return-code for // each ADS-sub command jniRelResBuff, // provide space for the response containing // the return codes relBuffSize, // send 32 bytes (IG1, IO1, Len1, IG2, IO2, // Len2, Data1, Data2) jniRelBuff); // buffer with data // Check return codes if (err != 0) { System.out.println("Error: Release handles:
0x" + Long.toHexString(err)); } else { ByteBuffer relResBuff = ByteBuffer.wrap(jniRelResBuff.getByteArray()); relResBuff.order(ByteOrder.LITTLE_ENDIAN); // Extract error codes from response (see picture 4) // Pattern is: err1, .., errN int rel1Err = relResBuff.getInt((Integer.SIZE / Byte.SIZE) * 0); int rel2Err = relResBuff.getInt((Integer.SIZE / Byte.SIZE) * 1); if (rel1Err != 0) { System.out.println("Error: Release handle1: 0x" + Integer.toHexString(rel1Err)); } else if (rel2Err != 0) { System.out.println("Error: Release handle2: 0x" + Integer.toHexString(rel2Err)); } else { System.out.println("Success:
Release handles!"); } } System.out.println("\nPress enter to continue.."); System.in.read(); } catch (Exception ex) { ex.printStackTrace(); } finally { // Close communication err = AdsCallDllFunction.adsPortClose(); if (err != 0) { System.out.println("Error: Close communication: 0x" + Long.toHexString(err)); } else { System.out.println("Success: Close communication!"); } } } } In response we get an ADS error code for each handle we try to release. TX1000 51 Version: 1.1