Fazecast / jSerialComm

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

jSerialComm 2.4.2 V with Embedded windows Pos Ready 2009 - Facing USB port connection is closing and not able to reopen the connection until I restart the OS system. #458

Closed Vishal0802 closed 1 year ago

Vishal0802 commented 2 years ago

We are using jSerialComm 2.4.2 version to communicate with Verfione Device (Attached with USB Port) on Embedded windows Pos Ready 2009 (32 bit).

We are facing connection closing issues intermediately. I started application and then I am able to connect with Verifone over USB and able to send and receive data. Now intermediately or any point of time when I send the data over USB port then I did not receive anything. So, I tried to close the serial port and connection with USB (eg. - COM9) and try to reconnect & open through USB port again but sometimes I could be able to connect (I got the serial object / input/output stream) and sometimes not (input and output stream object null while getting from serial port object) but in both the cases I could not be able to send and receive the data to Verifone terminal Over USB.

Now any how I would have to sometimes restart my device or application and whole system then only I could be able to connect with my device over usb and able to send & receive the data. I can only suspect that PORT is not closed correctly even calling the right serial port method.

I tried to add and integrate with higher version library - jSerialComm 2.5.3 but I am getting below issue -

Log: NFO|3216/0|22-10-13 09:15:07|java.lang.UnsatisfiedLinkError:C:\Windows\Temp\jSerialComm\1665648907093-jSerialComm.dll: The specified procedure could not be found INFO|3216/0|22-10-13 09:15:07|java.lang.UnsatisfiedLinkError: C:\Windows\Temp\jSerialComm\1665648907093-jSerialComm.dll: The specified procedure could not be found INFO|3216/0|22-10-13 09:15:07| at java.lang.ClassLoader$NativeLibrary.load(Native Method) INFO|3216/0|22-10-13 09:15:07| at java.lang.ClassLoader.loadLibrary0(Unknown Source) INFO|3216/0|22-10-13 09:15:07| at java.lang.ClassLoader.loadLibrary(Unknown Source) INFO|3216/0|22-10-13 09:15:07| at java.lang.Runtime.load0(Unknown Source) INFO|3216/0|22-10-13 09:15:07| at java.lang.System.load(Unknown Source) INFO|3216/0|22-10-13 09:15:07| at com.fazecast.jSerialComm.SerialPort.(SerialPort.java:243)

@hedgecrw @hedgecrw Would require your suggestion. Please help me here. Even port was closed, or any error occur while running the application. But If I am closing that port and trying to open it again so I should be able to communicate further without restarting the system OS or application or device.

Please guide if I would need to change any code with existing code or should I need to use any newer library that can work with this old OS and could be able to solve this issue and way to incorporate into application.

Java_Info System_Info
NorbertSandor commented 2 years ago

Why not try the latest version?

Have you checked https://github.com/Fazecast/jSerialComm#troubleshooting or https://github.com/Fazecast/jSerialComm/wiki/Troubleshooting item 11?

some systems may block execution of libraries from the system temp folder. ... Optionally, the same result can be achieved by running your Java application from the command line and specifying the java.io.tmpdir directory as an additional parameter, e.g.: java -Djava.io.tmpdir=/folder/of/your/choice -jar yourApplication.jar ... On Windows, you may be able to achieve the same result by setting the TMP environment variable ...

Vishal0802 commented 2 years ago

Optionally, the same result can be achieved by running your Java application from the command line and specifying the java.io.tmpdir directory as an additional parameter, e.g.: java -Djava.io.tmpdir=/folder/of/your/choice -jar yourApplication.jar ...

@NorbertSandor Thank you for your prompt response. When I am using jSerialComm 2.4.2, I just placed this in my lib folder and provided in class path to my command line script and it was working fine.

Now as per your suggestion, I created one tmp folder under my application and provided the same path but still facing the same issue.

Any step I am missing or need to change or add?

consider %YESPAY_HOME% = C:\YESEFT

My command -- call "C:\YESEFT"\JavaFinder.bat set classpath= set PATH=%JAVA_HOME%bin;%INSTALL_DIR%;%INSTALL_DIR%bin;%PATH%; java -Djava.io.tmpdir="%YESPAY_HOME%\tmp" -DYESPAY_HOME="%YESPAY_HOME%" -classpath "%YESPAY_HOME%\lib\jSerialComm-2.5.3.jar";"%YESPAY_HOME%\lib\bcprov-jdk14-138.jar";"%YESPAY_HOME%\YESEFTConfig.jar";"%YESPAY_HOME%\properties"; config.YESEFTConfig pause

Error -

image

Thanks.

NorbertSandor commented 2 years ago

Does it fail with jSerialComm 2.9.2 as well?

Vishal0802 commented 2 years ago

@NorbertSandor Thank you for your reply. Yes, Now I tried with 2.9.2 and getting below exception:

I have created "tmp" folder under baseDir/lib/tmp and the jSerialComm-2.9.2.jar placed under lib dir.

consider baseDir/YESPAY_HOME = C:/YESEFT

call "C:\YESEFT"\JavaFinder.bat set classpath= set PATH=%JAVA_HOME%bin;%INSTALL_DIR%;%INSTALL_DIR%bin;%PATH%; java -Djava.io.tmpdir="%YESPAY_HOME%\lib\tmp" -DYESPAY_HOME="%YESPAY_HOME%" -classpath "%YESPAY_HOME%\lib\jSerialComm-2.9.2.jar";"%YESPAY_HOME%\lib\bcprov-jdk14-138.jar";"%YESPAY_HOME%\YESEFTConfig.jar";"%YESPAY_HOME%\properties"; config.YESEFTConfig pause

error :

image

NorbertSandor commented 2 years ago

Sorry, I don't have more idea... But it seems that the problem is not with the temporary directory. There is some problem regarding your IA 32-bit architecture and the native DLL part of jSerialComm.

I'm afraid you have to wait for @hedgecrw , he is the real expert... :(

Vishal0802 commented 2 years ago

@NorbertSandor Thank you for your quick support and help.

@hedgecrw I would require your guidance and support here.

Vishal0802 commented 2 years ago

@NorbertSandor Thank you for your quick support and help.

@hedgecrw I would require your guidance and support here.

@hedgecrw I would require your guidance and support here.

hedgecrw commented 2 years ago

@Vishal0802, I'm not totally sure what the issue is since jSerialComm does support 32-bit Windows without problem. I am downloading a copy of the exact Windows version you are using "POSReady 2009 32-bit" and will see if I can figure out what's going on.

hedgecrw commented 2 years ago

Update, I can't even get Java to work on the version of Windows you are using due to it being so out-of-date. I was able to get a 32-bit version of Windows 8 installed, and jSerialComm seems to work fine on that. I will keep trying to get the POSReady Embedded Windows version working so I can test further.

In the meantime, could you try testing the following test program which uses jSerialComm under the hood:

https://www.dropbox.com/t/Yc2pyOH28puLtuyw

This is just the test suite that jSerialComm is put through before each release, so I'm not concerned with whether it actually works as a test suite on your computer, rather I want to see if it is able to load the jSerialComm library. Please post back if you are seeing the same error with this app. Thanks!

Vishal0802 commented 2 years ago

Update, I can't even get Java to work on the version of Windows you are using due to it being so out-of-date. I was able to get a 32-bit version of Windows 8 installed, and jSerialComm seems to work fine on that. I will keep trying to get the POSReady Embedded Windows version working so I can test further.

In the meantime, could you try testing the following test program which uses jSerialComm under the hood:

https://www.dropbox.com/t/Yc2pyOH28puLtuyw

This is just the test suite that jSerialComm is put through before each release, so I'm not concerned with whether it actually works as a test suite on your computer, rather I want to see if it is able to load the jSerialComm library. Please post back if you are seeing the same error with this app. Thanks!

@hedgecrw Thank you so much for your response. I did below steps but getting the same exception -

  1. I have my project working Dir: C:\YESEFT
  2. I have placed this dropbox(jSerialComm-2.9.3-test) jar under C:\YESEFT\lib folder.
  3. I have created "tmp" folder under lib: C:\YESEFT\lib\tmp
  4. Existing Code- import com.fazecast.jSerialComm.SerialPort;

    public String[] getIdentifierWindowsComm() { int n = 0;

    SerialPort ports[] = SerialPort.getCommPorts();
    String portNameArray[] = new String[ports.length];
    for (SerialPort port : ports) {
        String portName = port.getSystemPortName();
        portNameArray[n] = portName;
        n++;
    
    }
    
    return portNameArray;

    }

  5. Used below command to start my application. Here %YESPAY_HOME% = C:\YESEFT

call "C:\YESEFT"\JavaFinder.bat set classpath= set PATH=%JAVA_HOME%bin;%INSTALL_DIR%;%INSTALL_DIR%bin;%PATH%; java -Djava.io.tmpdir="%YESPAY_HOME%\lib\tmp" -DYESPAY_HOME="%YESPAY_HOME%" -classpath "%YESPAY_HOME%\lib\jSerialComm-2.9.3-beta1.jar";"%YESPAY_HOME%\lib\bcprov-jdk14-138.jar";"%YESPAY_HOME%\YESEFTConfig.jar";"%YESPAY_HOME%\properties"; config.YESEFTConfig pause

  1. Then I got the error. Attached here with all the details.
  2. Java version which I am using at Embedded POS ready 2009 - JavaVersionInfo.txt
  3. Error which I got - Error_While_Running.txt
  4. Under /lib/tmp folder "jSerialComm/2.9.3-beta1" folder gets created automatically but there is no file (.dll) or I would say 2.9.3-beta1 folder was empty.

Please let me know any further steps or need to share more Information. Thanks again for your time, response and help.

FYI - If I use the jSerialComm-2.4.2.jar with the same above configuration, it works, and I am able to see some files gets created under tmp folder while running the application without any error. However, with 2.4.2 version generally we do not create the tmp folder and even not set the tmp path but still it works.

Error_While_Running.txt JavaVersionInfo.txt

hedgecrw commented 2 years ago

FINALLY figured out the problem. The library was updated a long time ago to use Windows features that are not supported on versions older than Vista. Since you are using a non-supported version of Windows, I'm not going to try to find workarounds to include newer functionality with older Windows versions, but I'm including a manually compiled version of the library here for you to use:

https://www.dropbox.com/t/YnnoD3mROF41IV42

This should include all modern library functionality except for the ability to retrieve bus-reported device descriptions. Please let me know if this works for you. You also shouldn't need to worry about any of the temporary directory stuff...just use it like you were using the old library version.

hedgecrw commented 2 years ago

Actually went ahead and updated this properly so that WinXP can be supported in the official release. Please test the following and see if it works for you:

https://www.dropbox.com/t/7rKzupjB4Ip9ITLr

Vishal0802 commented 2 years ago

Actually went ahead and updated this properly so that WinXP can be supported in the official release. Please test the following and see if it works for you:

https://www.dropbox.com/t/7rKzupjB4Ip9ITLr

@hedgecrw Thank you so much for your quick help & prompt response & change. I am not doing well Today. So will try the same by next week and will share the result with you.

hedgecrw commented 1 year ago

Fixed with new release v2.9.3