Closed gourdeepti closed 2 years ago
Can someone please help me to resolve my issue.
Thanks
This is an odd bug. It might be related to the device driver write buffer size which is more dependent on the underlying device driver on Linux than on Windows. Please try the following:
Instead of using the simple openPort()
call, instead use openPort(0, 524288, 4096)
which will set the write buffer size to be 512kB (524288 bytes). (If this doesn't work, try different write buffer values, ranging from 1024 to 65536 and see if any of those work for your application).
If changing the write buffer size doesn't work, significantly shorten your chunk size from 512 kB to something around 1-4kB per write. This is still assuming that there is something going awry in the underlying device driver buffer writing.
If that doesn't work, there might be an issue with the application writing to the buffer more quickly than the buffer contents are being sent over the serial port, which would cause a write error. In this case, the only solution would be to slow down your writing in application code. If the device doesn't allow a large enough write buffer to hold all of your serial data at one time, there is no way to overcome this other than altering the application code to write more slowly.
Finally, when testing your code, please use the following library version to ensure that you have the most up-to-date changes that have been introduced since the most recent official release:
https://www.dropbox.com/s/qiotswg6os3bv61/jSerialComm-2.6.1.jar?dl=0
Thank you for solutions, I will test my code with your suggestions and get back to you.
Thanks
Updated version: https://www.dropbox.com/s/96b082qk9nqigxa/jSerialComm-2.6.1.jar?dl=0
Were you able to test the suggestions, and are you still seeing the problem with the latest official release version?
Unfortunately due to COVID-19, I didn't get chance to try with new version of release on Linux environment. Hopefully I will try it soon and get back to you.
Thanks
Hi @hedgecrw today I tried with latest jar but still getting issue
com.fazecast.jSerialComm.SerialPortIOException: No bytes written. This port appears to have been shutdown or disconnected. at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1539) at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1520)
Also change the method openPort(0, 524288, 4096) with other write buffer size as well, but not getting success. every case I am getting same exception
Uploading Bytes index : 0, Bytes size : 512000, Total bytes : 41236263 Uploading chunkSize : 512000 Inside physical layer write only... Command Write on Port Command Write on Port Successful Uploading Bytes index : 512000, Bytes size : 512000, Total bytes : 41236263 Uploading chunkSize : 512000 Inside physical layer write only... Command Write on Port Command Write on Port Successful Uploading Bytes index : 1024000, Bytes size : 512000, Total bytes : 41236263 Uploading chunkSize : 512000 Inside physical layer write only... Command Write on Port Exception == >> com.fazecast.jSerialComm.SerialPortIOException: No bytes written. This port appears to have been shutdown or disconnected.
could you suggest any other way to resolve my issue
Thank you for your help always.
Hi @hedgecrw could you suggest anything more, your support on this issue will be great help for me.
Thanks
Please test the attached library version and see if it works any better for you. There have been a ton of recent changes that have not made it into an actual release yet about the long-term stability of the library. Thanks!
https://drive.google.com/file/d/1hH2hXCEj39WUN1iz3F1TzLrpNvUro_aL/view?usp=sharing
Please actually test using this version of the library (all OS's are now enabled): https://drive.google.com/file/d/1QzWPJg5MU_2YrnsB1MsOWeTbjYD84D2h/view?usp=sharing
Solved in release of jSerialComm v2.8.0. Please open a new issue if you encounter something similar using the more recent library version.
We are using jSerialComm-2.4.2.jar for getting comport serialPort = SerialPort.getCommPort(connection.getPortName());
Opening the port serialPort.openPort();
Then updating the SerialPortParameters serialPort.setComPortParameters(connection.getBaudRate(), connection.getDatabits(),connection.getStopbits(), connection.getParity()); serialPort.setFlowControl(connection.getFlowControlIn() | connection.getFlowControlOut());
getting in and out streams portOut = serialPort.getOutputStream(); portIn = serialPort.getInputStream();
Then adding data listener serialPort.addDataListener(this);
Now we having connected pinpad on a specified port
Now we need to write a file which is 40 MB long,we will write this file in chunks which is 512 kb long 1 chunk = 512 kb
After writing the 2/3 chunks we are getting exception which is "Write Command TimeOut on Port :com.fazecast.jSerialComm.SerialPortIOException: This port appears to have been shutdown or disconnected."
StackTrace of exception:-
com.fazecast.jSerialComm.SerialPortIOException: This port appears to have been shutdown or disconnected. at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1350) at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1331)
After getting this exception we again open the port and make the connection , start writing the chunks, then again after 2/3 chunks getting the same exception.
OS version - SUSE-11
On windows 10 everything working fine, we writing the same file using 512 kb chunk each time.