import com.example.serial.SerialPort;
public class SerialCommunicationExample {
public static void main(String[] args) {
SerialPort serialPort = new SerialPort("COM1", 9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.open();
byte[] data = serialPort.read();
System.out.println("Received data: " + new String(data));
byte[] sendData = "Hello, World!".getBytes();
serialPort.write(sendData);
System.out.println("Sent data: " + new String(sendData));
serialPort.close();
}
}