GithubHelp home page GithubHelp logo

rm5248 / javaserial Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 3.0 517 KB

Use serial ports from Java using standard IO methods.

License: Apache License 2.0

C 46.08% Java 51.93% CMake 0.57% Shell 1.43%
java serial-ports

javaserial's People

Contributors

rm5248 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

javaserial's Issues

Methods do not declare that they throw IOException

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:

  • Declare all methods to throw IOException
  • Don't throw IOException?

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).

there is a fatal bug!

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....

Closing a SerialPort causes an IOException to be thrown

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.

native library does not work on raspberry pi

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.

Way to enumerate the ports (Not a bug but a question)

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

Way to enumerate the ports (Not a bug but a question) This time with a better answer than 'yes'

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).

Add 19200 rate

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.

java.lang.NoClassDefFoundError: Could not initialize class gnu.io.CommPortIdentifier

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]

Cleanup enums

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:

  • BaudRate
  • DataBits
  • StopBits
  • Parity
  • Flow Control

possible bug found

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

JavaSerial lib can't be used in Eclipse equinox OSGi plug-in

  1. Create a simple Eclipse 3.x RCP application with the wizard of new plug-in project. Name it as app plugin.
  2. Run app plugin and make sure the simple view defined in the plug-in appear.
  3. Create a plug-in project with the wizard of "Plug-in from existing JAR archives", choose JavaSerial-0.7.jar as external JAR. Name this plug-in as JavaSerial-3rd-lib.
  4. Turn to app plugin, open plugin.xml file and add JavaSerial-3rd-lib plugin as required plug-ins.
  5. Open the View.java file in app plugin, replace the return statement of createInitialDataModel() method with: return Arrays.asList(SerialPort.getSerialPorts());
  6. In the Run configurations -> plug-ins tab, check JavaSerial-3rd-lib plug-in, run it.
  7. Errors occured:

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)

  1. create another plug-in project with the wizard of "Plug-in from existing JAR archives", choose jssc-2.8.0.jar (https://github.com/scream3r/java-simple-serial-connector) as external JAR. Name this plug-in as jssc-3rd-lib.
  2. Add jssc-3rd-lib plugin to the required plugins of app plugin project.
  3. Open the View.java file in app plugin, replace the return statement of createInitialDataModel() method with: return Arrays.asList(SerialPortList.getPortNames());
  4. In the Run configurations -> plug-ins tab, checkjssc-3rd-lib plug-in, run it. The available serial ports list in the view and no error occured.

GetSerialPorts returning Empty

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

open: No such device or address

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?

Add baudrate 57600

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.

Possible bad write size on OSX

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.