-
Notifications
You must be signed in to change notification settings - Fork 28
Example
aesirot edited this page Dec 8, 2014
·
5 revisions
package custis.packhaus.modem;
import gnu.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
public class Application {
public static void main(String[] args) throws IOException, InterruptedException, PortInUseException, NoSuchPortException, UnsupportedCommOperationException {
CommPortIdentifier real = CommPortIdentifier.getPortIdentifier("COM9");
CommPort commPort = real.open("ymodem", 4000);
try {
if (commPort instanceof SerialPort) {
SerialPort serialPort = (SerialPort) commPort;
//serialPort.setBaudBase(115200);
serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
//serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
Thread.sleep(10);
YModem modem = new YModem(serialPort.getInputStream(), serialPort.getOutputStream());
//modem.receiveFilesInDirectory(Paths.get("."));
modem.send(Paths.get("RNTMP.FLD"), Paths.get("RNTMP.DAT"));
}
}
finally {
commPort.close();
}
}
}