Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions to add hardware flow control and XML escape #8

Open
doingnz opened this issue May 20, 2021 · 0 comments
Open

Suggestions to add hardware flow control and XML escape #8

doingnz opened this issue May 20, 2021 · 0 comments

Comments

@doingnz
Copy link

doingnz commented May 20, 2021

Great terminal application. Nice and simple for quick understanding of the Serial Api.

When testing with my device which that outputs upto 100K xml text, I quickly ran into problems with buffer overruns and lost characters. I turned on hardware flow control as follows as my device supports RTS & CTS handshake. Other samples suggest checkboxes for hardware flow control on/off. For a quick test I was happy to hardcode it.

            await port.open({
                baudRate: document.getElementById("baud").value,
                flowControl: "hardware", rtsCts: true,
                dataBits: 8, stopBits: 1, parity: "none",
                bufferSize: 2560
            });

As my device outputs XML, I had to define

    function escapeXml(unsafe) {
        return unsafe.replace(/[<>&'"]/g, function (c) {
            switch (c) {
            case '<': return '&lt;';
            case '>': return '&gt;';
            case '&': return '&amp;';
            case '\'': return '&apos;';
            case '"': return '&quot;';
            }
        });
    }

and then change append to escape the string being stuffed into the page for all characters to be rendered in a readable form.

// value is a string. escape characters as needed 
appendToTerminal(escapeXml(value));
@doingnz doingnz changed the title Suggestions to add hardware flow control and HTML escape Suggestions to add hardware flow control and XML escape May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant