jssc

how to read data frome serialport using jssc in java?

ぃ、小莉子 提交于 2021-02-19 06:39:06
问题 I used jssc library to read and write data from serial port. package serial; import jssc.*; public class Serial { public static void main(String[] args) { String[] portNames = null; portNames = SerialPortList.getPortNames(); for (String string : portNames) { System.out.println(string); } if (portNames.length == 0) { System.out.println("There are no serial-ports"); } else { SerialPort serialPort = new SerialPort("com2"); try { serialPort.openPort(); serialPort.setParams(SerialPort.BAUDRATE

Get Device Descriptor of SerialPort using jssc

↘锁芯ラ 提交于 2021-02-17 22:20:30
问题 How to get the Device Descriptor of a SerialPort using jssc ( java-simple-serial-connector) ? The getPortName() method gives port name ( e.g. COM2 ), but descriptor would be more helpful. If it's necessary to patch this opensource API to get the Device Descriptor how can it be done? 回答1: Look at gohai/java-simple-serial-connector, the SerialPortList class has a getPortProperties(String portName) method to get the port properties, unfortunately is not implemented yet for windows but is easy to

Reading from serial port gives split up string

偶尔善良 提交于 2021-01-29 06:57:52
问题 I am using the JSSC class to receive a string from an Arduino Uno. The Arduino is connected to my computer via COM3. In the setup void on the Arduino, it sends a string to the java program saying that the Arduino is ready to read serial data. What happens is when the java program reads the serial port, it splits up the string from the Arduino onto multiple lines with spaces. I imagine it is that java program is printing the data when its received instead of waiting for the full string. How

My SerialPortEvent does not receive data using jSSC in a continous loop

痞子三分冷 提交于 2019-12-25 04:31:46
问题 I have been trying to use serial communication with my Arduino Uno and have used the library jSSC-2.6.0. I am using a SeriaPortEvent listener to receive bytes from the Serial Port (Arduino) and store them in a linked list. public synchronized void serialEvent(SerialPortEvent serialPortEvent) { if (serialPortEvent.isRXCHAR()) { // if we receive data if (serialPortEvent.getEventValue() > 0) { // if there is some existent data try { byte[] bytes = this.serialPort.readBytes(); // reading the

close my ports programatically using netbeans

我怕爱的太早我们不能终老 提交于 2019-12-25 02:48:12
问题 I am using server program to connect with arduino board I am using hc-05 bluetooth in my arduino board so that it is wireless and then scratch program will open which will display some output.I am using serial port communication where I am displaying COM ports and it displays well.I will select one com port from the combobox and when i press the connect button scratch file will open. This works fine for the first time. When I again run my application my program throws an exception " gnu.io

jSSC Not Sending Data to Arduino

半世苍凉 提交于 2019-12-23 02:01:40
问题 I have a problem with writing function of jSSC. My Arduino Uno board seems not getting data from my Java program. I have a stepper motor controlled by Arduino Uno board. I made a simple program that has 2 buttons. One is for CW rotation and the other is CCW rotation. CW button sends 'H' char and CCW button sends 'L' char. Now I have: I checked from Arduino IDE serial console my Arduino program works correct. When I send 'H' the motor turns CW and with 'L' the motor turns CCW. I made a program

Read Complete Line Java Serial Port

被刻印的时光 ゝ 提交于 2019-12-12 03:59:11
问题 I have implmented JSSC API so I can communicate with the Com Port. I send a command like "N\r\n" and what i receive in a normal hyperterminal should look like this: 0100071CA79215021803164442180000 0100071C9F5415021803164514520000 0100071CDF5115022106142956600000 NOK But when i do the same with the JSSC API i receive this (only the first code) 010 0071CA79 2150218 0316444 218 The Problem is that i randomly receive bit parts and at the end of the code i lose some parts. But thats not important

jssc getInputStream() getOutputstream()

耗尽温柔 提交于 2019-12-12 01:44:46
问题 I'm using jssc library for communicating with device over serial port. In standard java SerialComm library there are two methods getInputStream() and getOutputStream(). Why I need this? I want to implement Xmodem according to this example and xmodem constructor requires two params: public Xmodem(InputStream inputStream, OutputStream outputStream) { this.inputStream = inputStream; this.outputStream = outputStream; } Xmodem xmodem = new Xmodem(serialPort.getInputStream(),serialPort

Can Java JSSC library detect a lost connection?

北慕城南 提交于 2019-12-11 04:23:59
问题 I know serial ports are not so good but still a little hope... I am using JSSC library for communication. Does the JSSC library have a method to detect when an established connection is lost due to hardware removal? 回答1: The jssc does not have hot plug or device removal like mechanism. Give details of your hardware and we may think of some work around. 来源: https://stackoverflow.com/questions/40629180/can-java-jssc-library-detect-a-lost-connection

When requesting com port returns the same request

可紊 提交于 2019-11-27 05:33:00
I`m trying to send AT-command via COM-port, but reseived only the same command. package SerialConnections; import jssc.SerialPort; import jssc.SerialPortEvent; import jssc.SerialPortEventListener; import jssc.SerialPortException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static ru.telemetria.qa.utils.Utilities.waitTime; public class M234Serial { private static Logger log = LoggerFactory.getLogger(M234Serial.class); private SerialPort serialPort; private byte[] receivedData; private boolean isReceived; public M234Serial() throws Exception { serialPort = new SerialPort(