Arduino Create Agent - Close serial port is slower than open serial port

Hello there,

I have an HTML script using a button to call my function to close serial port onclick.

        <button onclick="closePort()">Close Port</button>

        ....
        ....
        ....

        <script>
        function closePort() {
            var portName = document.getElementById('ix-dd-com').value;
            socket_.emit('command', 'close ' + portName);
        }
        </script>

This will take about 1.5 to 2 seconds later before the web socket will notify me that my COM3 serial port has been successfully closed. Whereas for opening of serial port, the websocket's response is almost instantaneous.

This is kind of frustrating because when it comes to changing the baud rate of the serial port. The agent will attempt to open the same serial port with a different baud rate before it closes.

I've attached the codes. it's an HTML script using JavaScript and socket.io. Really appreciate if anybody can help me out here. Thanks.

EDIT 1: Arduino forum doesn't allow uploading files in .HTML format. So I re-upload in .txt instead.

myIndex.txt (4.11 KB)

Is this related to the Arduino online EDITOR or the CREATE agent ?
Are you trying to interface directly to CREATE or the AGENT ?

Or is it more related to a different topic / area ?

Hi Ballscrewbob,

I would say this is more of the CREATE agent than the online EDITOR. I'm trying to use the CREATE agent to output my serial log onto an HTML page from my Arduino Uno.

Apologies if my post is off-topic here.

No it certainly is not off topic.

However it is a new type of question and possibly the first use of the agent in a different way.