我必須連接RFID閱讀器和我的java項目。我爲此設備安裝了所有必需的驅動程序,並導入了所有必需的庫。我使用Eclipse程序來編寫我的Java項目。 初學者使用RFID閱讀器。下面的代碼不起作用。請幫幫我。連接R1240IB qID穿戴式藍牙UHF RFID條碼閱讀器與Java程序通過USB?
package com.caen.RFIDLibrary;
import com.caen.RFIDLibrary.CAENRFIDException;
import com.caen.RFIDLibrary.CAENRFIDLogicalSource;
import com.caen.RFIDLibrary.CAENRFIDPort;
import com.caen.RFIDLibrary.CAENRFIDReader;
import com.caen.RFIDLibrary.CAENRFIDReaderInfo;
import com.caen.RFIDLibrary.CAENRFIDTag;
public class reader_com {
public static void main (String[] args) throws CAENRFIDException{
CAENRFIDReader MyReader = new CAENRFIDReader(); //Create myObject
CAENRFIDReaderInfo Info = MyReader.GetReaderInfo(); // Create Object for reader info
String Model = Info.GetModel(); //Get info about model
String SerialNumber=Info.GetSerialNumber(); // Get info about serialNumber
String FWRelease = MyReader.GetFirmwareRelease(); // Get info about FW
MyReader.Connect(CAENRFIDPort.CAENRFID_USB, "COM13"); // Open a connection
CAENRFIDLogicalSource MySource = MyReader.GetSource("Source_0, Source_1"); // Choose Source 0-->RFID tags 1-->Barcode
MySource.SetQ_EPC_C1G2(3); // set Q Value
CAENRFIDTag[] MyTags = MySource.InventoryTag();
if (MyTags.length > 0){
System.out.println(Model);
System.out.println(SerialNumber);
System.out.println(FWRelease);
}
MyReader.Disconnect();
}
}
而且我回來這個錯誤:
Exception in thread "main" java.lang.NullPointerException
at com.caen.RFIDLibrary.CAENRFIDReader$IOBuffer.access$1800(CAENRFIDReader.java:228)
at com.caen.RFIDLibrary.CAENRFIDReader$CAENRFIDOutPacket.AddHeader(CAENRFIDReader.java:2701)
at com.caen.RFIDLibrary.CAENRFIDReader.GetReaderInfo(CAENRFIDReader.java:3183)
at com.caen.RFIDLibrary.reader_com.main(reader_com.java:20)
「不工作」是不是非常有幫助的 - 你可以更具體一點嗎? –
我回來這個錯誤 – user3386169
在線程異常 「主」 顯示java.lang.NullPointerException \t在com.caen.RFIDLibrary.CAENRFIDReader $ IOBuffer.access在com.caen.RFIDLibrary.CAENRFIDReader $ 1800(CAENRFIDReader.java:228) \t $ CAENRFIDOutPacket.AddHeader(CAENRFIDReader.java:2701) \t在com.caen.RFIDLibrary.CAENRFIDReader.GetReaderInfo(CAENRFIDReader.java:3183) \t在com.caen.RFIDLibrary.reader_com.main(reader_com.java:20) – user3386169