Welcome to Our Community

Some features disabled for guests. Register Today.

Tech support for Javascript Macros in CONTROL

Discussion in 'Control Software' started by sharmstr, Jan 4, 2021.

  1. Alain JBT

    Alain JBT Well-Known
    Builder

    Joined:
    Apr 23, 2023
    Messages:
    56
    Likes Received:
    40
    Hi @Misterg
    Happy to see you again, thank you for your answer
    If you tested the BIG THING I will test it as if it were Christmas :)
    And as the proverb says with us "everything comes in time for who knows how to wait":thumbsup:
    Thank you very much and take care !
     
    Misterg likes this.
  2. BASt_NL

    BASt_NL New
    Builder

    Joined:
    Sep 9, 2022
    Messages:
    27
    Likes Received:
    4
    Question; if you have the doorsensor enabled in the firmware.
    When you run a job, it will succesfully trigger.
    But when youre not running anything, you wont see anything, but controls are locked and the console will state: [14:59:10] [ ] [MSG:Check Door]
    Would it be possible to have a json macro to trigger a popup either when the door is triggered (although that doesnt show in the console), or show a popup when that Check Door message is returned?
    (I dont always have the console in view, so i wont see it otherwise)
     
  3. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,495
    Likes Received:
    4,420
    You should be able to yes,those statusses are available in that laststatus global object inside CONTROL (look at laststatus.comms.runStatus)

    https://github.com/gnea/grbl/wiki/Grbl-v1.1-Interface

    upload_2025-2-24_16-20-36.png

    Here's how we parse it for the bottom bar, we do show door status there:

    upload_2025-2-24_16-23-39.png



    https://github.com/OpenBuilds/OpenB...fa2d2ff082edb4c/app/js/websocket.js#L643-L664

    (use laststatus in place of status if copying above)
     
  4. BASt_NL

    BASt_NL New
    Builder

    Joined:
    Sep 9, 2022
    Messages:
    27
    Likes Received:
    4
    That does state " upload_2025-2-24_15-37-20.png indeed, completely missed that, thx
     
    Peter Van Der Walt likes this.
  5. wienans

    wienans New
    Builder

    Joined:
    Yesterday
    Messages:
    2
    Likes Received:
    0
    Hey Guys,

    i have the following use case. I want to have only one PC controlling multiple Blackbox X32 in parallel. For that i found that normally the CONTROL Software only streams the data and i need to use the SD Card.

    Currently i have this:

    Code:
    let fileInput = document.createElement("input");
    fileInput.type = "file";
    fileInput.style.display = "none";
    document.body.appendChild(fileInput);
    
    fileInput.addEventListener("change", async function() {
        if (fileInput.files.length === 0) {
            console.log("No file selected.");
            return;
        }
        
        let file = fileInput.files[0];
        let formData = new FormData();
        
        // Add the path parameter
        formData.append("path", "/");
        
        // Add the file size (adjust key name as needed)
        formData.append(file.name + "S", file.size);
        
        // Append the file with correct field name and MIME type
        formData.append("myfiles", file, file.name);
        console.log(formData);
        try {
            let response = await fetch("http://192.168.0.56/sdfiles?t=" + Date.now(), {
                method: "POST",
                mode: "no-cors",
                headers: {
                    "Accept": "*/*",
                    "Origin": "http://192.168.0.56",
                    "Referer": "http://192.168.0.56/",
                    "Pragma": "no-cache",
                    "Cache-Control": "no-cache"
                },
                body: formData
            });
            console.log(response);
            if (!response.ok) {
                throw new Error("Upload failed with status " + response.status);
            }
            
            let result = await response.text();
            console.log("Upload successful:", result);
            alert("File uploaded successfully!");
        } catch (error) {
            console.error("Error uploading file:", error);
            alert("File upload failed: " + error);
        }
    });
    
    let uploadButton = document.createElement("button");
    uploadButton.textContent = "Upload File to SD Card2";
    uploadButton.addEventListener("click", function() {
        fileInput.click();
    });
    $("#controlBtnGrp").before(uploadButton);
    The biggest problem now is CORS as i get the opaque response from the WebUI Plugin. I found that the Web UI can be build with CORS Enabled, is there a reason why you ship the WEB UI in your Firmware without CORS, i think the risk is minimal as it is a local application and would enable easy access for more advanced usecases?

    Additionally the IP Address is hardcoded as you can see. I didn't find documentation about what variables might be usable. Is there a variable which already stores the ip address of the currently connected board, so i can easily use it here?

    Maybe is there a other way to upload data to the SD Card? Maybe such macros already exist but i couldn't find it?

    Thanks in advance
     
  6. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,495
    Likes Received:
    4,420
    We just use the standard download from https://github.com/grblHAL/Plugin_WebUI when preinstalling, and certainly encourage you to build with any custom options you need and upgrade WebUI every so often too (it is seperate from firmware update)


    Not that we know of at this time. For us its mainly CONTROL-over-Telnet OR SD/WebUI - never really meant to be mixed together, so nothing like that already exists

    Should be in laststatus too https://github.com/OpenBuilds/OpenB...3097f467e5933861fa2d2ff082edb4c/index.js#L501
     
    wienans likes this.
  7. wienans

    wienans New
    Builder

    Joined:
    Yesterday
    Messages:
    2
    Likes Received:
    0
    Hi Peter, thanks for your quick reply.

    As the Firmware Flashing Tool looks to be used for your Main firmware is there any chance that there is documentation on how to upload the new WebUI?
     
  8. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,495
    Likes Received:
    4,420
    See https://github.com/grblHAL/Plugin_WebUI for instructions (upload latests index.gz via web interface)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice