|
|
@ -1,29 +1,28 @@ |
|
|
|
package com.dreamworks.boditech.driver.connection; |
|
|
|
import com.fazecast.jSerialComm.SerialPort; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import org.apache.juli.logging.Log; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.nio.ByteBuffer; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class ComSerialPort { |
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(ComSerialPort.class); |
|
|
|
|
|
|
|
@Value("${app.device.connectionType}") |
|
|
|
private String connectionType; |
|
|
|
@Value("${app.device.path}") |
|
|
|
private String path; |
|
|
|
|
|
|
|
@Value("${app.device.baudrate}") |
|
|
|
private int baudRate; |
|
|
|
|
|
|
|
// serial port connection |
|
|
|
private SerialPort port; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init() { |
|
|
|
if ( !this.connectionType.equals("SerialPort") ) { |
|
|
|
return ; |
|
|
|
} |
|
|
|
this.open(); |
|
|
|
} |
|
|
|
|
|
|
|