rm5248 / javaserial Goto Github PK
View Code? Open in Web Editor NEWUse serial ports from Java using standard IO methods.
License: Apache License 2.0
Use serial ports from Java using standard IO methods.
License: Apache License 2.0
Complete solution is working perfectly fine in my local windows 10 machine after adding RXTXComm.jar and rxtxserial.dll into java path.
But the same solution when we deployed on Linux server throwing an error.
Servlet.service() for servlet [dispatcherServlet] in context with path [/wto-microservice] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class gnu.io.CommPortIdentifier] with root cause
2018-06-25T15:47:39.34+0530 [APP/PROC/WEB/0]OUT java.lang.NoClassDefFoundError: Could not initialize class gnu.io.CommPortIdentifier
2018-06-25T15:47:39.34+0530 [APP/PROC/WEB/0]OUT at com.ge.combo.controller.RailwayController.readData(RailwayController.java:69) ~[app/:na]
When opening up a serial port, if the baud rate is unable to be set an IOException can be thrown. When this happens, the native resources are not cleaned up properly and can potentially lead to resource exhaustion if it continues forever.
A similar issure as I pointed out in JSSC:
https://github.com/scream3r/java-simple-serial-connector/issues/123
Is there a way to receive an event when a device is connected (plugged in) or do I need to poll - periodically call SerialPort.getSerialPorts()?
Socat can be used to create a serial port(pty) on Linux. When this is the case, we will fail to open up the serial port properly, as getSerialLineStateInternalNonblocking
throws an error, presumably because TIOCMGET is not implemented on these ports.
See also: https://stackoverflow.com/questions/14830739/where-is-tiocmget-supposed-to-be-implemented
Since Java enums can have values associated with them, we can cleanup the code a bit and make it less likely to fail if we simply give the enums an actual value.
Enums to update:
I'm trying list the available ports on my system, but I'm getting this error.
The Error:
open: No such device or address ERROR: This is a very bad thing that should never happen SerialPortImpl.c:1724 errno:22 open: No such device or address ERROR: This is a very bad thing that should never happen SerialPortImpl.c:1724 errno:6
The code:
import com.rm5248.serial.SerialPort;
import java.util.Arrays;
import java.util.List;
public class ReadingFromPortTest {
public static void main(String[] args) {
List<String> serialPorts = Arrays.asList(SerialPort.getSerialPorts());
serialPorts.forEach(System.out::println);
}
}
Any idea what it might be?
Is there a way to enumerate the serial ports on the system? I would like my app to find the correct serial port without user engagement.
I have no idea what the names of the serial ports could be. Better to find all and analyze each one to see which one is correct.
I see an answer 'yes' and then closed. Not helpful. From the Javadoc API there is no clear way to do it.
In the jserialComm library there is a method
SerialPort.getCommPorts()
where I do not have to provide a name (which I do not know).
Hello,
I used you library and had some problems when I was reading from the InputStream retrieved from the SerialPort and at the same time catched an InterruptedException. I believe that the problem is in the read method from the class BufferedSerialInputStream. When an InterruptedException is catched, you only print the exception but I believe that you should restore the interrupted status after catching InterruptedException. So, changing the code "e.printStackTrace();" with the following code "Thread.currentThread().interrupt();" seems to fix the problem.
Best regards,
Juanan
Only the first result can be obtained,100% cpu usage, and the program will get stuck.The same is true for another open source project jSerialComm
orangepi zero url:http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero.html
Add 19200 baud rate to supported baud rates on the Java side.
The native code supports it, but for some reason it's not in our enum on supported baud rates.
Possible issue with OSX: not all characters are being written to the serial port at once in our write() call. When testing the other week, I noticed that OSX only seemed to send the first two characters of the string.
Is there a way to enumerate the serial ports on the system? I would like my app to find the correct serial port without user engagement.
I have no idea what the names of the serial ports could be. Better to find all and analyze each one to see which one is correct.
Thanks
I noticed the other day that an IOException can be thrown by certain methods, but on the Java side the methods are not declared as throwing an IOException.
We have a few options:
Related to not throwing IOException, we can throw an IOException if we mess up something on the JNI side - if we can't find our handle we will throw an IOException, whereas we should really throw something like BadProgrammingException(subclass of RuntimeException).
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: com/rm5248/serial/SerialPort
Caused by: java.lang.NoClassDefFoundError: com/rm5248/serial/SerialPort
at javaserialportosgitest.View.createInitialDataModel(View.java:70)
at javaserialportosgitest.View.createPartControl(View.java:57)
Hello,
Thank you for this library.
I want to get every serial port of my system and save it in somewhere.
String[] ports = SerialPort.getSerialPorts();
always return empty;
How I can fix that?
I used
com.rm5248 JavaSerial 0.9
If possible, I would appreciate to use a baudrate of 57600 (linux).
I use JavaSerial to test some modems. One (NewWay 27) seems to detect the baudrate well on the first start, but on restart it seems to stick to 57600.
On Windows, the control line state( DTR and RTS ) is a static variable, so if there are multiple serial ports open then when the state of one line changes they will all change.
When closing a SerialPort, the thread that is currently reading the port will come back with an IOException. This occurs at least on Windows using a BufferedSerialInputStream, but not using a SimpleSerialInputStream.
Also, when closing a serialport that is using a SimpleSerialInputStream, a 0 gets returned when the serial port closes - it should be -1, as that is what an InputStream uses to say that there is an EOF.
The native code for Linux ARM does not work on the raspberry pi. It fails with a SIGILL. Probably because the arch was set to be a v7 ARM processor, while the pi appears to only be v6 compatible.
when you send data,this JavaSerial sometime will receive 4 time as i send.
like:
when send AA BB CC . it will receive AA BB CC AA BB CC AA BB CC AA BB CC 。mostly ,when set 128 bytes recve buffer .it will fill ful of that buffer with AA BB CC....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.