private void init() {
try {
if (m_out == null) {
m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPort); // Tomamos el puerto
m_CommPortPrinter = m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto
m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura
if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_SERIAL) {
((SerialPort)m_CommPortPrinter).setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Configuramos el puerto
} else if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
((ParallelPort)m_CommPortPrinter).setMode(1);
}
}
} catch (Exception e) {
m_PortIdPrinter = null;
m_CommPortPrinter = null;
m_out = null;
m_in = null;
// } catch (NoSuchPortException e) {
// } catch (PortInUseException e) {
// } catch (UnsupportedCommOperationException e) {
// } catch (IOException e) {
}
}
CommStream.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:micro-Blagajna
作者:
评论列表
文章目录