# More details about COM ports

**URL:** https://discourse.processing.org/t/more-details-about-com-ports/43714
**Category:** Electronics (Arduino, etc.)
**Created:** [January 18, 2024, 1:48pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714 "2024-01-18T13:48:19Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [January 18, 2024, 1:48pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/1 "2024-01-18T13:48:19Z")

</div>

I have a question concerning com ports. A while ago in this thread

> [@How can I get/fetch a response from invoked (launch() ) command?](https://discourse.processing.org/t/how-can-i-get-fetch-a-response-from-invoked-launch-command/43511):
>
> I used launch() to invoke a batch script. The batch script would than launch Arduino-cli to build and upload an arduino program to a board. That was this fine working line. launch("rundll32 SHELL32.DLL,ShellExec\_RunDLL " + sketchPath("") +"\\flashArduino.bat") ; In order to get the correct COM port as well as board model. I would like to fetch the output generated by arduino-cli. This allow me to use the board list command to figure out which COM port I should use. The native processing's Se…

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.

I cannot use this: `Serial.list()`

```auto
[0] "CNCA2"
[1] "CNCB2"
[2] "COM4" 
[3] "COM7" 
[4] "COM8" 
[5] "COM9" 

```

vs OS:

![afbeelding](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/f/5fa298c8015144f72a98854692127f68f224e2b3.png)

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.

Bas

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [January 18, 2024, 4:27pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/2 "2024-01-18T16:27:47Z")

</div>

Have you tried using the cmd-line to list the ports? It’s ` ls /dev/{tty,cu}.*`  
on a Mac; have no idea what’s available on Windows.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [January 19, 2024, 12:44am UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/3 "2024-01-19T00:44:22Z")

</div>

Hello @bask185,

This will provide more details:

> **[jSerialComm](https://fazecast.github.io/jSerialComm/)**
>
> jSerialComm : Platform-independent serial port access for Java

This is the list of COM ports using the _jSerialComm library_:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/7/e74da25fbbbf8f9c497e0fb950b2ef90d027dce0.png)

Those other COM ports are your virtual COM ports:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/c/fc03d145c020e645292a15c243eeb62fcf32a2ba.png)

And your ports:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/7/d70cfe382bd39d5e4c0c44f500e3373eb94615d8.png)

This is the list of COM ports using _Processing Serial library_:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/b/2b40c24d210fe35eca4c56186aa08b42d89ac81c.png)

`:)`

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [January 23, 2024, 1:45pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/4 "2024-01-23T13:45:27Z")

</div>

Thank you, that seems really good.

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.

I tried like 4 different locations.

Where do libraries go in 2024?

Bas

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [January 23, 2024, 1:50pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/5 "2024-01-23T13:50:49Z")

</div>

Did you try creating a folder entitled ‘code’ inside of your sketch folder, then enclosing the .jar file?

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [January 23, 2024, 1:52pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/6 "2024-01-23T13:52:41Z")

</div>

No, that is the common way nowadays? Is it like the arduino src/ directory? imma gonna try it out!

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [January 23, 2024, 1:55pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/7 "2024-01-23T13:55:06Z")

</div>

I’m not familiar with arduino/src, but it is also created with Processing as you probably know. Drag’NDropping .jar file onto editor should also work.

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [January 23, 2024, 2:02pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/8 "2024-01-23T14:02:20Z")

</div>

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! 😉

 ![afbeelding](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/f/4f97088a3273becdcaf2e575ad4ade7f2a044970.png)

Kind regards,

Bas

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [January 23, 2024, 7:48pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/9 "2024-01-23T19:48:55Z")

</div>

An extra reference for visitors to this topic:

> **[How to Use Processing Libraries](https://happycoding.io/tutorials/processing/libraries)**
>
> Learn how to use libraries to expand what Processing can do.

`:)`

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [January 23, 2024, 8:11pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/10 "2024-01-23T20:11:32Z")

</div>

Thnx, I read it. But the ‘code’ subfolder is not mentioned however

---

<div class="post-metadata">

### Author: ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)
#### Post date: [January 23, 2024, 9:12pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/11 "2024-01-23T21:12:28Z")

</div>

On Windows, “mode” lists the com ports. I have in the past used the output of this to detect when a particular port is there for Arduino program load.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [January 24, 2024, 1:06am UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/12 "2024-01-24T01:06:45Z")

</div>

> [@bask185](#):
>
> But the ‘code’ subfolder is not mentioned however

You are correct! It is not.

I did find a reference here to _code folder_:

> **[Library Overview](https://github.com/benfry/processing4/wiki/Library-Overview#another-alternative-using-the-code-folder)**
>
> Processing 4.x releases for Java 17. Contribute to benfry/processing4 development by creating an account on GitHub.

`:)`

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [February 10, 2024, 1:24pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/14 "2024-02-10T13:24:35Z")

</div>

> [@RichardDL](#):
>
> On Windows, “mode” lists the com ports.

This need to be entered in the Command Prompt:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/b/fbc2dbb4a54d97e27d09b02856887fa35411ac63.png)

Additional reference:  
_[MODE - Com1, Com2, Lpt1, con - Windows CMD - SS64.com](https://ss64.com/nt/mode.html)_

`:)`

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [April 3, 2024, 9:52am UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/15 "2024-04-03T09:52:05Z")

</div>

Hello,

I have a follow-up question. I can succesfully identify my Uno board and set up a connection using this code

```auto
    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)

```auto
    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.`

The documentation claims:

> Ability to read and write byte streams via Java’s [InputStream](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/InputStream.html) and [OutputStream](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/OutputStream.html) interfaces

So I thought I could just use the `available()` method just like I can with the ‘default’ serial library.

How am I failing? 🙈

Bas

---

<div class="post-metadata">

### Author: ![bask185](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@bask185](https://discourse.processing.org/u/bask185)
#### Post date: [April 3, 2024, 12:08pm UTC](https://discourse.processing.org/t/more-details-about-com-ports/43714/16 "2024-04-03T12:08:56Z")

</div>

I found it!!

You have to create an `inputStream` object.  
`InputStream inputStream ;`

And couple it to the serial object in the setup using the method `getInputStream()`  
`inputStream = dccNext.getInputStream() ;`

Than you can use the inputStream object with all it’s methods like `print()` print is no input , `read()`, `available()` etc.

Kind regards,

Bas
