本文目錄一覽:
- 1、java如何通過串口IC讀卡器讀取IC卡號?
- 2、java如何從串口讀取數據帶GUI
- 3、NFC模組,開發NFC功能 只要幾條指令的事情
- 4、用java從串口讀取數據然後顯示在網頁上,能實現嗎
- 5、java串口,讀取和發送數據
- 6、如何用Java語言向串口讀寫數據
java如何通過串口IC讀卡器讀取IC卡號?
讀取IC讀卡器分很多種,有種最簡單的是直接連電腦,使用串口助手軟件,選定特定的波特率,就可以接收IC卡號(有些是像RFIC的就需要對其解碼)
上面問題解決後,重點的是java如何做一個串口助手,眾所周知,java是運行在虛擬機上,也就是要運行在window的一個進程上,如果要java讀寫串口的話,肯定需要對它進行驅動編寫,而不僅僅是加載個jar包就能解決的。
幸運的是SUN公司已經幫我們解決了這個問題,你可以到sun公司網站上下載javacomm20-win32.zip的壓縮包,裡面就包含了串口的驅動(.dll文件)以及對應的jar包,下載後把.dll文件放到你JDK路徑/bin,通過jar包提供的api你就可以操作串口相關的接口了。這裡一遍關於java串口使用的文章,希望能提供給您:
java如何從串口讀取數據帶GUI
1.導入支持java串口通信的jar包:
在maven項目的pom.xml中添加RXTXcomm的依賴 或者 下載RXTXcomm.jar並導入到項目中。
支持Java串口通信操作的jar包,java.comm比較老,而且不支持64位系統,推薦使用Rxtx這個jar包(32位/64位均支持)。
注意:運行過程中拋出 java.lang.UnsatisfiedLinkError 錯誤或 gnu.io 下的類找不到時,將rxtx解壓包中的 rxtxParallel.dll,rxtxSerial.dll 這兩個文件複製到 C:\Windows\System32 目錄下可解決該錯誤。
2.編寫代碼操作串口:
串口必要參數類:包含連接串口所必須的參數,方便在調用串口時設置和傳遞串口參數。
NFC模組,開發NFC功能 只要幾條指令的事情
實現NFC透明傳輸,內置NFC協議棧,支持UART串口直接讀寫,用於門禁可以同時兼容手機和卡片開門,還能實現動態密鑰,讀到的NFC數據自動串口輸出,會串口就能開發NFC,不需要研究LLCP/NDEF等協議棧。送各種例子源碼,手機對應測試程序源碼,可定製開發,風火輪獨家實現P2P大輸據傳輸。
支持WIN8/WIN7 + android + wince +MCU 單片機 + linux + MAC ……
兼融所有平台,只要你會串口編程!
SMC532模組,是一個集成了MCU+NFC的模組,採用了使用最為廣泛的NFC芯片NXP的PN532作為NFC底層通信鏈路,保證了可靠性的兼容性,然後,MCU採用了ARM-M3的工業級(兼容軍工級)單片機STM32作為主控,風火輪科技工程師傾注大量心血嵌入了完整高效的NFC應用協議棧,使得用戶在開發NFC功能應用時更為簡單,
只需要簡單的串口指令就能實現NFC 讀寫卡\卡模擬\點對點(P2P)通信等等功能
用java從串口讀取數據然後顯示在網頁上,能實現嗎
用java從串口讀取數據然後顯示在網頁上,能實現。
以下是對串口讀寫代碼,來自網友百度知道網友。其它如何傳遞到網頁自己搜索吧。
public static void process() {
try {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)//如果端口類型是串口則判斷名稱
{
if(portId.getName().equals(“COM1”)){//如果是COM1端口則退出循環
break;
}else{
portId=null;
}
}
}
SerialPort serialPort = (SerialPort)portId.open(“Serial_Communication”, 1000);//打開串口的超時時間為1000ms
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);//設置串口速率為9600,數據位8位,停止位1們,奇偶校驗無
InputStream in = serialPort.getInputStream();//得到輸入流
OutputStream out = serialPort.getOutputStream();//得到輸出流
//進行輸入輸出操作
//操作結束後
in.close();
out.close();
serialPort.close();//關閉串口
} catch (PortInUseException e) {
e.printStackTrace();
} catch (UnsupportedCommOperationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
java串口,讀取和發送數據
public static void process() {
try {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)//如果端口類型是串口則判斷名稱
{
if(portId.getName().equals(“COM1”)){//如果是COM1端口則退出循環
break;
}else{
portId=null;
}
}
}
SerialPort serialPort = (SerialPort)portId.open(“Serial_Communication”, 1000);//打開串口的超時時間為1000ms
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);//設置串口速率為9600,數據位8位,停止位1們,奇偶校驗無
InputStream in = serialPort.getInputStream();//得到輸入流
OutputStream out = serialPort.getOutputStream();//得到輸出流
//進行輸入輸出操作
//操作結束後
in.close();
out.close();
serialPort.close();//關閉串口
} catch (PortInUseException e) {
e.printStackTrace();
} catch (UnsupportedCommOperationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
如何用Java語言向串口讀寫數據
public static void process() {
try {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)//如果端口類型是串口則判斷名稱
{
if(portId.getName().equals(“COM1”)){//如果是COM1端口則退出循環
break;
}else{
portId=null;
}
}
}
SerialPort serialPort = (SerialPort)portId.open(“Serial_Communication”, 1000);//打開串口的超時時間為1000ms
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);//設置串口速率為9600,數據位8位,停止位1們,奇偶校驗無
InputStream in = serialPort.getInputStream();//得到輸入流
OutputStream out = serialPort.getOutputStream();//得到輸出流
//進行輸入輸出操作
//操作結束後
in.close();
out.close();
serialPort.close();//關閉串口
} catch (PortInUseException e) {
e.printStackTrace();
} catch (UnsupportedCommOperationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
原創文章,作者:WWJH,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/139427.html