Send gCode file to printer server

Hi,
I have a gCode as a file and I needed to upload it using the API and send to printer thus it will print, can I achieve this? can you guide me how to do this?
«1

Comments

  • Read this:
    https://www.repetier-server.com/using-simplify-3d-repetier-server/

    it shows how to do this with curl, but same can work with any other solution.
  • I am trying to do everything using API, to one of my customers who is having repetier server. He will upload the gcode file from a third party web app which he develops, and then give a print command, that file should take the data to printer and print. This is the concept, is this something achievable and how?
  • Sure it is possible. Our guis are just web pages and all communication is done using the api. So you of course do anything with a web page/backend that you can do in our gui. Some commands require a websocket for full functionality, e.g. if you need to be informed about events to update your frontend. The api is described here:
    https://www.repetier-server.com/manuals/programming/API/index.html

    For your problem be aware that we have gcode storage and a print queue. Only files in print queue can get printed. If there are multiple files in the queue you need to tell which one to start. You can also store gcode first and tell server to copy from model storage to job queue. That way you have a backup if a print fails or needs to be printed again. As you see in the api you can query these queues and work on them.
  • When I upload a gcode file using curl function to a certain printer, i get the following output, WHat does this mean? Can I take it as success of if it is success what to do next and which API to use. Please clarify 

    HTTP/1.1 200 OK
    Date: Thu, 11 Jun 2020 10:20:26 GMT
    Connection: Close
    Server: 0.93
    Access-Control-Allow-Origin: *
    Content-Type: text/html; charset=utf-8
    Cache-Control: public, max-age=0

    {}
  • HTTP/1.1 200 OK 
    is a success message at least regarding query and you also got a {} response.
    If it is a success is easily visible in server - is the file there or not?

  • OK, after submitting the gcode file, what next? How to initiate printing? which endpoint and parameters to be given? is it a GET or POST, after we issue the printing command will that print automatically or queued for pending? If so how to print a queued job?
    For these questions there is no proper API documentation and instructions, please advice 
  • Get or post is not important. But these are all websocket commands so you normally use a websocket as shown in the javascript demo at the bottom. Or you use for every command the get/post->websocket translation.

    Command "listModels" returns you stored models so you see names and id.
    Command "copyModel" can copy one of these models to print queue and start it automatically if queue was empty.
    Command "listJobs" shows currentyl stored prints queued for printing.
    Command "startJob" will start explicitly one job with given id from listJobs.

    You see all commands are described in API. Also stop, send command, list status, ...
  • OK thank you, in any case, can't we achieve these tasks with API key(without using web socket, use http)?
  • These commands do not need websocket. You can use the api->websocket conversion as described in the api near the top. Just make sure to url encode the data json string parameter.
  • So if we upload a file, how can we find it using listModels unless we have an uploaded id, how to specifically spot our uploaded file?
  • Ids are always growing so it is the one with highest id if you query directly after uploading. You can also compare file length in addition. File name will also be the same in normal cases.
  • when using the /printer/info, it gives printer details along with printer name and slug. The printer name seems the user may change as he wishes, is slug also changeable like this? If we want to keep one field that uniquely identifies a printer that cannot be changed by the user which field can we take out of the fields returned from that specific API?
  • The slug is the folder where server internally stores all printer data and also name of the config file. So that gets set when you define the printer and stays constant until you delete the printer. The name is the user readable version and just stored in config so it is changeable. Also slug must be unique per server instance.
  • How can we identify whether the uploaded gcode file along with id, has finished printed? which api to use along with the gcode id?
  • https://www.repetier-server.com/manuals/programming/API/index.html

    listPrinter

    Parameter: None

    Response

    [ { "active": true, "job": "none", "name": "DeltaTower", "online": 0, "slug": "delta" }, { "active": false, "job": "none", "name": "Azteeg X3 Pro very long name is this", "online": 0, "slug": "delta2" }, { "active": true, "job": "none", "name": "iRapid", "online": 1, "slug": "irapid" }, { "active": false, "job": "none", "name": "iRapid BLACK", "online": 0, "slug": "irapid3" }, { "active": true, "job": "none", "name": "Ordbot", "online": 0, "slug": "Ordbot" }, { "active": false, "job": "none", "name": "Schrotty", "online": 0, "slug": "Schrotty" }, { "active": false, "job": "none", "name": "Test", "online": 0, "slug": "Test" }, { "active": false, "job": "none", "name": "iRapid WHITE", "online": 0, "slug": "white" } ]

    Lists all configured printer with their state.


    If job is "none" printer is not printing. If a job is running you get extra informations per printer:

    1. active: true
    2. analysed: 1
    3. done: 0.07288440013535674
    4. job: "16mm_tube_holder_2_0.2mm_PLA_MK3S_24m"
    5. jobid: 1
    6. linesSend: 28
    7. name: "Fehler"
    8. ofLayer: 50
    9. online: 1
    10. pauseState: 0
    11. paused: false
    12. printStart: 1592578721.344
    13. printTime: 2291.967927547647
    14. printedTimeComp: 866.6666717529297
    15. slug: "Fehler"
    16. start: 1592585921
    17. totalLines: 38417
  • Thank you, I assume that the field Name,Slug are respectively Printer Name and Slug?
  • listModels gives all the uploaded file details. when the uploads grow, the response also will grow, so will the be a problem when receiving the JSON if the JSON body becoming larger?
    and regarding old uploaded gcode files, how long they exist? That means will they disappear after a job is printed or after they are sent to queue?
  • Models stay in model list until they get deleted. You can organize them into groups and add a group filter with parameter
    group (string, optional, default = '*') = group to filter
    but length is not really a problem if you do not want to store 10000th of gcodes. Normally you need them many times then you but them in a proper group or you delete them when not required any more. There is no real need for most gcodes to be stored indefinitively.
  • edited June 2020
    After we call the api copyModel with gcode ID, if the queue is empty it will start to print automatically, otherwise wiil it print automatically when its turn comes at the queue or do we need to manually start the job?
  • listJobs api return 2 fields
    "printed": 0,
    "state": "stored",
    
    What are they and what would be the possible values each fields contain? 
  • removeModel API
    what would be the URL format to be given? GET or POST?

  • When we upload g-code file, it returns a id, then we give copyModel API call, then we start the job, then it will give a job id, is the initial g-code id and job id returned later are referring to the same id or different IDs?
  • job and model ids are different. They are valid for their folder to identify the files. And each folder has it's own numbers.

    If job does not autostart you must start it explicitly with the id - this allows also printing out of order. Order is just how they landed in queue in case a company wants a fifo order.

    "printed" is irrelevant for job. It is in model the count how often it was printed.
    "state" is one of  : "uploading", "stored", "running", "finsihed" (will become finished with next update),"error"

    url format is always retrievied the same way by applying the websocket object to the data parameter as json string and url encoded.
  • "state" is one of  : "uploading", "stored", "running", "finsihed" (will become finished with next update),"error"

    This variable is available in listJob and listModel, how can we interpret the state of the variable in each context?
  • So, I believe that, when we call the copyModel API, the JobID created and can be seen in the listJob?
  • listJobs excludes the running job. So if it does not get printed at the moment, yes.
  • So when a job is finished printing, it will be vanished from the list, until it finishes printing, it will be inside the listJob right?

  • No it vanishes already when print starts. It only gets back if print fails while stopping a print also removes it.
  • If I want to get some feedback from the printer, like one job is printed finished, or printer is stuck or printing is abruptly stopped, I needed to get a notification from Printer, I am sure that it can be done through the socket, so we need to have a login account created with privileges in order to get live feedbacks from Printing job?
Sign In or Register to comment.