Closed elicec closed 2 years ago
I try all port,and any port can not opened
To retrieve the native error code and source code location, you can use the functions getLastErrorCode()
and getLastErrorLocation()
, and either post the results back here or look up the location of the error in source code under src/main/c/Windows/SerialPort_Windows.c to see which line causes the open call to fail.
But in this case, I can almost guarantee that there is simply a problem with whatever String you are using to try to call SerialPort.getCommPort(...)
. It looks like you're just passing whatever description is present in some sort of dropdown box, which is incorrect. The ideal way to retrieve the SerialPort object would be to store the array of objects resulting from SerialPort.getCommPorts()
and use the index of whatever is selected in your choice box to retrieve the corresponding SerialPort object from your stored array. If you don't want to store the array of actual SerialPort objects, you will need to translate from whatever String selection you are trying to make to the correct raw system port name (like 'COM1' etc.) for use in getCommPort(...)
.
That's great. You helped me a lot.
openPort failed OS Windows 10 21H2
How to get detailed error information?