jSSC does not find the USB ports of my PC

Asked

Viewed 78 times

1

I am doing a project in Java using the jSSC library, but when I use the method of listing the ports nothing appears. I tested on another computer and worked perfectly, but on my personal computer does not work.

I’ve seen videos of how to activate the COM port, but none worked when using the method.

String[] portNames = SerialPortList.getPortNames();                
for(int i = 0; i < portNames.length; i++){
    System.out.println(portNames[i]);
}  

When I run the code below it does not pass the Serial.openPort().

Note: I used "COM1" because through research I discovered that it is the standard port of W10.

Serial = new SerialPort("COM1");
try {
    Serial.openPort();
}
catch (SerialPortException e) {
    System.out.println(e);
}

Error:

jssc.SerialPortException: Port name - COM1; Method name - openPort(); Exception type - Port not found.

1 answer

2

Just to clarify that we are talking about the same thing, the JSSC library is used for communication SERIAL, it will not communicate with your USB devices unless this device simulates a serial port on that USB (like Arduino for example).

So first check if your computer has any active serial port.
Open the run and type

compmgmt.Msc

You should open the Computer Management window, then in the left side menu go to "Device Manager".
On the right side will appear all the devices of your computer, almost at the end of the list have "Ports (COM and LPT)", click to expand the item and see if you have any COM on your computer, see image below.

postas COM

If your computer does not display any by COM then your project is right, it generates error because there really is nothing for it to communicate.

  • Which library is indicated to communicate with USB ports?

  • 1

    @Cypherpotato as far as I know java does not have an official API library for USB, but there are some independent alternatives like usb4java

  • Yes, it is connected to COM1 port in Device Manager

  • @Luan could give more details about the project? Which device are you trying to communicate? Which output when you have list the doors with the command SerialPortList.getPortNames();? Which version of the JSSC lib you are using?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.