I have a question concerning com ports. A while ago in this thread
I managed to use arduino-cli.exe in order to get me more details about COM ports. It works really well. I can also find me boards with Ch340 chips. But if I export an application I don’t want to ship a copy of arduino-cli and deal with associated problems.
The output from Serial.list() is not satisfactory. It prints more COM ports than my OS can find and there are no details.
Are there besides arduino-cli.exe more lightweight tools (which may or may not be natively installed on windows) which I can launch from processing and use to get me a more acurate list of COM ports with some more detailing.
I have one question. Despite being an electronics engineer I cannot find how to bloody install a library. I google searched…
I tried putting the jar file in my sketch folder
I tried putting the jar file in my sketchbook folder under libraries.
Yeah I know. The content of the src/ directory within an arduino sketch is compiled with your project. Usually you can dump whatever cpp and h files in your main sketch folder and you are good. If you have that much files that you want to use subfolder structure than the subfolder hast to be named “src”. It was not always like this. iirc one could name their subfolders however they liked.
I read on internet that you could drop a .jar file in a sketch folder. I don’t know if that used to be the case in the past??
Anyways. It seems to work now! I can compile and find my arduino. Thanks alot folks!
I have a follow-up question. I can succesfully identify my Uno board and set up a connection using this code
SerialPort[] serialPorts = dccNext.getCommPorts() ;
for (SerialPort port: serialPorts)
{
if( port.getDescriptivePortName().contains("Uno")
|| port.getDescriptivePortName().contains("CH340"))
{
println("dccNext found") ;
try
{
dccNext = port ; // copy the for-loop's local object tot he global serial port object.
dccNext.setBaudRate( 115200 ) ;
if( dccNext.openPort() ) println("Serial port opened!") ;
else println("Serial port opening !!!FAILED!!!") ;
}
catch (NullPointerException e)
{
println("NullPointerException") ;
}
}
}
I can also succesfully write data to the Arduino.
However the reading part, does not work.
What I usually do in void draw/loop is to to wait for the serial object to contain atleast 1 byte. Than I add small quick and dirty delay to allow more bytes to fill the buffers before processing the data.
( I am not sure if the delay will work in processing like I think it will)
if( dccNext.available() > 0 )
{ delay(100);
byte len = dccNext.available() ; // should have received entire message by now
string s = "" ; // make empty string
for( int i = 0 ; i < len ; i ++ )
{
s += (char)dccNext.read() ; // add received bytes to string
}
println(s) ; // go print string to terminal
receivedText = s ; // copy local string to global string
}
The problem is in this line: if( dccNext.available() > 0 )
(dccNext is declared as: SerialPort dccNext ; )
The compiler error: dccNextGUI.pde:58:0:58:0: The function available() does not exist.