⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkdll.java

📁 RFID读写器调用实例程序。RFID读写器是远望谷804系列。通过JNI调用远望谷API。 提供读
💻 JAVA
字号:
package hfut.wispy;

public class LinkDll
{
	public byte[] EPCCharArray = new byte[17];
	
	public native int XCOpen ( String lsCfgFile, String lsCfgItem );
	public native int XCPowerOn ( int hCom );
	public native int XCIdentify (int hCom, byte AntennaID, byte scantimes, byte ReadTimes);
	public native int XCReport (int hCom, byte[] EPCCode);
	public native int SayHello();
	public native int SayWorld(String str);
	public native int XCPowerOff(int hCom);
	public native int XCClose();
	public native int GethCom();
	public native int GetPowerState();
	
	static 
	{	
		System.out.println(System.getProperty("java.library.path"));
		System.loadLibrary("CYWGDLLA");
		
	}
	
	 /**
	   *
	   * @param b byte[]
	   * @return String
	   */
	  public static String Bytes2HexString(byte[] b) {
	    String ret = "";
	    for (int i = 0; i < b.length; i++) {
	      String hex = Integer.toHexString(b[i] & 0xFF);
	      if (hex.length() == 1) {
	        hex = '0' + hex;
	      }
	      ret += hex.toUpperCase();
	    }
	    return ret;
	  }

	   /**
	   * 将两个ASCII字符合成一个字节;
	   * 要在HexString2Bytes中用到;
	   * 如:"EF"--> 0xEF
	   * @param src0 byte
	   * @param src1 byte
	   * @return byte
	   */
	  public static byte uniteBytes(byte src0, byte src1) {
	    byte _b0 = Byte.decode("0x" + new String(new byte[]{src0})).byteValue();
	    _b0 = (byte)(_b0 << 4);
	    byte _b1 = Byte.decode("0x" + new String(new byte[]{src1})).byteValue();
	    byte ret = (byte)(_b0 ^ _b1);
	    return ret;
	  }

	   /**
	   * 将指定字符串src,以每两个字符分割转换为16进制形式
	   * 如:"2B44EFD9" --> byte[]{0x2B, 0x44, 0xEF, 0xD9}
	   * @param src String
	   * @return byte[]
	   */
	  public static byte[] HexString2Bytes(String src){
	    byte[] ret = new byte[8];
	    byte[] tmp = src.getBytes();
	    for(int i=0; i<8; i++){
	      ret[i] = uniteBytes(tmp[i*2], tmp[i*2+1]);
	    }
	    return ret;
	  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -