Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
新增安装包
Browse files Browse the repository at this point in the history
  • Loading branch information
kcqnly committed Feb 7, 2020
1 parent d25941a commit 9b24677
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 37 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
![kcqnly](https://ly-object-1259106193.cos.ap-chengdu.myqcloud.com/github/SerialAssistant-2.png)

# 使用说明
## 直接使用jar
要把 rxtxSerial64.dll 和 rxtxParallel64.dll
分别放到 jdk1.8.0_211\jre\bin 和 jdk1.8.0_211\jre\lib\ext 文件夹里
这两个文件我放到了项目的dependences文件夹下

## 使用.exe
直接安装,自带jre

# 已解决的问题
- 无法选择波特率
Expand Down
Binary file added SerialPortAssistant_windows-x64_1_5.exe
Binary file not shown.
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
<artifactId>rxtxcomm</artifactId>
<version>2.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.scream3r</groupId>-->
<!-- <artifactId>jssc</artifactId>-->
<!-- <version>2.8.0</version>-->
<!-- </dependency>-->

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>

</dependencies>


Expand Down
19 changes: 7 additions & 12 deletions src/main/java/SerialAssistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import lombok.Getter;
import lombok.Setter;


import java.io.UnsupportedEncodingException;
import java.util.List;
Expand Down Expand Up @@ -63,18 +62,15 @@ public void onActionOpenBtn(ActionEvent actionEvent) {
if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
String str = null;
try {
str = new String(serialController.readData(),"GBK");
str = serialController.readData();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String finalStr = str;
Platform.runLater(() -> {
if(receiveText.getLength()<4100)
{
String finalStr = str;
Platform.runLater(() -> {
if (receiveText.getLength() < 4000) {
receiveText.appendText(finalStr);
}
else
{
} else {
receiveText.deleteText(0, finalStr.length());
receiveText.appendText(finalStr);
}
Expand All @@ -99,8 +95,7 @@ public void onActionSendBtn(ActionEvent actionEvent) {
/**
* 清除接收框
*/
public void clear(ActionEvent actionEvent)
{
public void clear(ActionEvent actionEvent) {
receiveText.clear();
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/SerialController.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import gnu.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;

import java.io.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
Expand Down Expand Up @@ -78,14 +76,14 @@ public void close() {
public void sendData(String data) {
PrintStream printStream = null;
try {
printStream = new PrintStream(serialPort.getOutputStream(),true,"GBK"); //获取串口的输出流
printStream = new PrintStream(serialPort.getOutputStream(), true, "GBK"); //获取串口的输出流
printStream.print(data);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (printStream != null) {
printStream.close();
}
if (printStream != null) {
printStream.close();
}
}
}

Expand All @@ -94,15 +92,16 @@ public void sendData(String data) {
*
* @return 返回串口数据
*/
public byte[] readData() {
public String readData() throws UnsupportedEncodingException {
InputStream is = null;
byte[] bytes = null;
try {
is = serialPort.getInputStream(); //获取输入流
int bufflenth = is.available(); //获取数据长度
while(bufflenth != 0) {
while (bufflenth != 0) {
bytes = new byte[bufflenth];
int read = is.read(bytes);
// int read = is.read(bytes);
is.read(bytes);
bufflenth = is.available();
}
} catch (IOException e) {
Expand All @@ -113,7 +112,8 @@ public byte[] readData() {
} catch (IOException e) {
e.printStackTrace();
}
return bytes;
String str=new String(bytes, "GBK");
return str;
}


Expand Down
Binary file added 串口助手.jar
Binary file not shown.
Binary file removed 串口调试助手.jar
Binary file not shown.

0 comments on commit 9b24677

Please sign in to comment.