Created
          January 29, 2018 22:30 
        
      - 
      
 - 
        
Save HashRaygoza/624f3d81d85eccb91d4929e9d8c24928 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package mx.hash.print; | |
| import jssc.SerialPort; | |
| import jssc.SerialPortException; | |
| public class PrinterTest { | |
| public static void main(String[] args) { | |
| SerialPort serialPort = new SerialPort("COM7"); | |
| try { | |
| // Esto funciona | |
| serialPort.openPort();//Open serial port | |
| serialPort.setParams(SerialPort.BAUDRATE_9600, | |
| SerialPort.DATABITS_8, | |
| SerialPort.STOPBITS_1, | |
| SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0); | |
| for (int i = 0; i < 10; i++) { | |
| serialPort.writeBytes("¡¡Hola Mundo!!\n".getBytes());//Write data to port | |
| } | |
| serialPort.closePort();//Close serial port | |
| } catch (SerialPortException ex) { | |
| System.out.println(ex); | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment