|
|
|
@ -2,6 +2,7 @@ package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.fazecast.jSerialComm.SerialPort;
|
|
|
|
|
import com.xydl.cac.service.SerialPortService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -10,6 +11,10 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class SerialPortServiceImpl implements SerialPortService {
|
|
|
|
|
|
|
|
|
|
@Value("${cac.warnport.name}")
|
|
|
|
|
public boolean warnportname;
|
|
|
|
|
|
|
|
|
|
public List<SerialPort> serialPortList;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -52,7 +57,7 @@ public class SerialPortServiceImpl implements SerialPortService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean openSerialPort(SerialPort port) {
|
|
|
|
|
if (port.getSystemPortName().equals("COM6")) {
|
|
|
|
|
if (port.getSystemPortName().equals(warnportname)) {
|
|
|
|
|
int baudRate = 9600; // 波特率
|
|
|
|
|
int parity = SerialPort.EVEN_PARITY; // 校验位
|
|
|
|
|
int dataBits = 8; // 数据位
|
|
|
|
|