<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Java Samples]]></title>
<link><![CDATA[https://java-samples.com]]></link>
<description><![CDATA[Comments]]></description>
<generator>Commentics</generator>
<item>
<title>Murugesh</title>
<link><![CDATA[https://www.java-samples.com/showtutorial.php?tutorialid=11&cmtx_perm=49#cmtx_perm_49]]></link>
<description><![CDATA[<p></p><div class="cmtx_code_box">// Add an event listener<br /> serialPort.addEventListener(new SerialPortEventListener() {<br /> @Override<br /> public void serialEvent(SerialPortEvent event) {<br /> if (event.isRXCHAR()) { // If data is available<br /> try {<br /> // Read the data<br /> byte[] data = serialPort.readBytes();<br /> System.out.print(new String(data));<br /> } catch (SerialPortException ex) {<br /> System.out.println(&quot;Error reading data: &quot; + ex);<br /> }<br /> }<br /> }<br /> });<br /><br /> } catch (SerialPortException ex) {<br /> System.out.println(&quot;Error opening port: &quot; + ex);<br /> }<br /> }<br />}</div>]]></description>
<pubDate>Tue, 21 May 2024 10:32:07 +0800</pubDate>
<guid isPermaLink="false">item_49</guid>
</item>
<item>
<title>Murugesh</title>
<link><![CDATA[https://www.java-samples.com/showtutorial.php?tutorialid=11&cmtx_perm=48#cmtx_perm_48]]></link>
<description><![CDATA[<p>This code seems to be quite old. Now you can use libraries like Java Simple Serial Connector (jSSC). <a href="https://github.com/scream3r/java-simple-serial-connector/releases" target="_blank" rel="nofollow">https://github.com/scream3r/java-simple-serial-connector/releases</a> </p><p>Add the jSSC library to your project: Download the jSSC library from the GitHub releases page and add it to your project.</p><p>Simple Java Code Using jSSC:</p><p></p><div class="cmtx_code_box">import jssc.SerialPort;<br />import jssc.SerialPortException;<br />import jssc.SerialPortEvent;<br />import jssc.SerialPortEventListener;<br /><br />public class SimpleRead {<br /> public static void main(String[] args) {<br /> String portName = &quot;COM1&quot;; // Replace with your COM port<br /> SerialPort serialPort = new SerialPort(portName);<br /><br /> try {<br /> // Open the port<br /> serialPort.openPort();<br /><br /> // Set the parameters<br /> serialPort.setParams(SerialPort.BAUDRATE_9600,<br /> SerialPort.DATABITS_8,<br /> SerialPort.STOPBITS_1,<br /> SerialPort.PARITY_NONE);<br /><br /> </div>]]></description>
<pubDate>Tue, 21 May 2024 10:29:47 +0800</pubDate>
<guid isPermaLink="false">item_48</guid>
</item>
<item>
<title>Thomas</title>
<link><![CDATA[https://www.java-samples.com/showtutorial.php?tutorialid=11&cmtx_perm=47#cmtx_perm_47]]></link>
<description><![CDATA[<p>Why do I need such a big script, when I can do it in C# in 2 lines?</p>]]></description>
<pubDate>Mon, 20 May 2024 20:51:42 +0800</pubDate>
<guid isPermaLink="false">item_47</guid>
</item>
</channel>
</rss>