Friday, 13 September 2013

write a string to a serial port in java

write a string to a serial port in java

i want to write a string to a serial port, but serial port write method
allows only byte array to write in it...so how can i send whole string to
a port..here is my code...
serialPort.setSerialPortParams(300,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
OutputStream mOutputToPort = serialPort.getOutputStream();
String mValue = "ABCDEFG";
System.out.println("beginning to Write . \r\n");
mOutputToPort.write(mValue.getBytes());
System.out.println("AT Command Written to Port. \r\n");
mOutputToPort.flush();
i dont want to send it one by one char..i want whole at a time... thnxx in
advance

No comments:

Post a Comment