Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.34k stars 287 forks source link

javax.comm Implementation #246

Closed Bodyash closed 5 years ago

Bodyash commented 5 years ago

Hi, just found this awesome library

Trying to write some kind of javax.comm Implementation using this library, so my implementation will be like wrapper.

https://docs.oracle.com/cd/E17802_01/products/products/javacomm/reference/api/javax/comm/SerialPort.html

Task is not so easy, cause of javax.comm API. There is a lot of strange methods that should be implemented.

https://imgur.com/eh40C8v

I have questions about:

  1. isRI() missing
Ring Indicator DCE has detected an incoming ring signal on the telephone line.
  1. // Sends a break of millis milliseconds duration. public void sendBreak(int millis) { //javax.comm //TODO: internalSP.setBreak // task set internalSP.clearBreak after millis??? }

  2. set and get input\output stream buffer size

  3. recieveTimeout, recieveThreshold, recieveFraming

Thanks for your work!

hedgecrw commented 5 years ago

Hi there! In response to your questions, please use the following updated version of the library for your testing: https://www.dropbox.com/s/kjlc2i2eh836p1h/jSerialComm-2.5.3.jar?dl=0

1) I implemented a method called getRI() that should solve this problem. 2) Yes, the code you posted should be the correct way to do this...i.e. call setBreak(), sleep, then call clearBreak(). If you want to do this asynchronously in a separate thread, you may need to implement some sort of semaphore/mutex locking functionality, so implementing it synchronously is probably easier. 3) I added methods called getDeviceReadBufferSize() and getDeviceWriteBufferSize() to help you with this. Note that these are highly OS/driver-dependent calls, so they are not guaranteed to always provide the correct result, but this is already specified in the javax.comm documentation. 4) For receiveTimeout, you will need to do some sort of logic involving getReadTimeout() and the actual read timeout mode specified to return a logical value. I have no idea what receiveThreshold even means! For receiveFraming, I'm assuming this is if you used something similar to the SerialPortMessageListener functionality of jSerialComm to specify one or more delimiter/framing values. Unfortunately, none of these correspond exactly to the jSerialComm API, so you will have to just make an executive decision on what these things should mean in your particular implementation.

Hope that helps!

Bodyash commented 5 years ago

Thanks for reply! It might help