Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Curl + KISS in RRF

    Scheduled Pinned Locked Moved
    General Discussion
    3
    26
    2.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JoergS5undefined
      JoergS5 @sinned6915
      last edited by

      @sinned6915 I mean somthing like:

      curl -v -F "file=@"/KS_Wizard.gcode"" http://192.168.0.25/rr_upload?name=gcodes/@"F:\3D_Printer\Kiss_1.6.3\EV2\Preload\KS_Wizard.gcode"

      or if only the output path is expected:

      curl -v -F "file=@"/"" http://192.168.0.25/rr_upload?name=gcodes/@"F:\3D_Printer\Kiss_1.6.3\EV2\Preload\KS_Wizard.gcode"

      (I am offline now. Good luck!)

      1 Reply Last reply Reply Quote 0
      • sinned6915undefined
        sinned6915
        last edited by sinned6915

        @JoergS5 thanks for your help- i am making baby steps...

        curl -v -F "file=@%1" "http://192.168.0.25/rr_upload?name=gcodes/%~nx1"
        

        is parsing the filename out of the path but now i am getting timeouts from the Duet.

        F:\3D_Printer\Kiss_1.6.3>curl -v -F "file=@"F:\3D_Printer\Kiss_1.6.3\EV2\Preload\KS_Wizard(8).gcode"" "http://192.168.0.25/rr_upload?name=gcodes/KS_Wizard(8).gcode"
        *   Trying 192.168.0.25...
        * TCP_NODELAY set
        * Connected to 192.168.0.25 (192.168.0.25) port 80 (#0)
        > POST /rr_upload?name=gcodes/KS_Wizard(8).gcode HTTP/1.1
        > Host: 192.168.0.25
        > User-Agent: curl/7.55.1
        > Accept: */*
        > Content-Length: 2017542
        > Expect: 100-continue
        > Content-Type: multipart/form-data; boundary=------------------------941032cdc9b01eb3
        >
        * Done waiting for 100-continue
        < HTTP/1.1 200 OK
        < Cache-Control: no-cache, no-store, must-revalidate
        < Pragma: no-cache
        < Expires: 0
        < Access-Control-Allow-Origin: *
        < Content-Type: application/json
        < Content-Length: 9
        < Connection: close
        <
        {"err":0}* Closing connection 0
        
        
        JoergS5undefined 1 Reply Last reply Reply Quote 0
        • JoergS5undefined
          JoergS5 @sinned6915
          last edited by

          @sinned6915 was your try in http://www.kisslicertalk.com/viewtopic.php?f=13&t=2263 succesful, so you can compare it to today's try? Possible reasons could then be changed curl version or OS.

          Another idea is, maybe it's possible to set debug mode on Duet side.

          1 Reply Last reply Reply Quote 0
          • sinned6915undefined
            sinned6915
            last edited by

            I was using that script to connect windows 10 to Octoprint- same one i started with and posted above.

            I was not able to get it to connect to duet. One of the posters was using a Mac and the script options are different.

            good idea on trying to enable the debugging! i know M111 P2 (?) sets debug in HTTP. I will try that. P1 is network and floods the terminal buffers

            Currently, I am either getting that 'continue' error or an authentication error. I do not have any password set but something tells me i should try to connect with no password regardless to start the connection.

            JoergS5undefined 1 Reply Last reply Reply Quote 0
            • JoergS5undefined
              JoergS5 @sinned6915
              last edited by JoergS5

              @sinned6915 maybe your timeout is because Duet doesn't close the connection, dc42 has commented in https://forum.duet3d.com/topic/867/duet-wifi-s3d/42 to use additional:
              dc42:
              You may wish to add the following line at the end:
              curl "http://XXX.XXX.XXX.XXX/rr_disconnect"
              This will avoid RRF buffering up messages that S3D isn't going to fetch.

              Another idea:
              Your curl command seems to be ok, the connection reported 100 and 200, which means successful. It transmitted 9 bytes. Are you sure it is not a link which you want to upload (the (8) file), which is only 9 bytes long? And you could try -X POST in the command additionally.

              Edit: the content-length comment was wrong, the 9 bytes are the response. But the sending is about 2 MB, maybe there is a file limit somewhere. E.g. https://forum.duet3d.com/topic/4355/maximum-g-code-file-size/3 the SD card clustered.

              1 Reply Last reply Reply Quote 0
              • sinned6915undefined
                sinned6915
                last edited by

                @JoergS5 I saw the content lengths and thought it was odd, but assumed that it was HTTP not file system.

                I have an overnight print going so I will test it out after it gets done. I remember reading about the cluster size somewhere and it prompted me to seek out the official SD card formatter. I can not remember what I used when i formatted the card. Its worth checking out.

                I did try playing with the -X POST but I thought that it complained about being redundant with the -F option. I am not sure why the syntax changes color on this so much, but the first tan line says POST and I assumed that it was using POST. I will have to double check.

                What I can not figure out is if its waiting for a server response- 'multpart' form boundary.

                JoergS5undefined 3 Replies Last reply Reply Quote 0
                • JoergS5undefined
                  JoergS5 @sinned6915
                  last edited by JoergS5

                  @sinned6915 my last few ideas:
                  to test whether your connection (with authentication) works correctly, you could start a print with curl of an existing file.
                  I saw curl has an alternative to multipart, for post also. You could try this also. But as I understood, curl manages the multipart formatting.
                  Kiss may produce specific gcode, you could try the curl with a little general gcode file.
                  I saw a curl option like --data-binary, maybe this helps.

                  1 Reply Last reply Reply Quote 0
                  • JoergS5undefined
                    JoergS5 @sinned6915
                    last edited by

                    @sinned6915 I just discovered an intersting tool HTTPie: https://github.com/jakubroztocil/httpie#file-upload-forms which allows to run http commands interactively. This may help finding the problem.

                    1 Reply Last reply Reply Quote 0
                    • JoergS5undefined
                      JoergS5 @sinned6915
                      last edited by

                      @sinned6915 I checked the documentation https://github.com/chrishamm/DuetWebControl, the chapter rr_upload says, a response {"err":0} means, that the transfer was successful.

                      So I suspect the target path makes problems.

                      1 Reply Last reply Reply Quote 0
                      • sinned6915undefined
                        sinned6915
                        last edited by

                        So I am making some headway I think-
                        You are right, the transfer is getting initiated, but the payload is empty.
                        Here is the partial output of

                        M111 S1 P2 - https://pastebin.com/UE2ytPLr

                        all it shows is that the connections are initiated and accepted .

                        The gcode file list shows the file is there but with 0 length.

                        JoergS5undefined 1 Reply Last reply Reply Quote 0
                        • JoergS5undefined
                          JoergS5 @sinned6915
                          last edited by JoergS5

                          @sinned6915 I would try using a more current curl version, current is 7.65.1. There were lots of bug fixes since 7.55.1 (list: https://curl.haxx.se/changes.html)

                          1 Reply Last reply Reply Quote 0
                          • A Former User?
                            A Former User
                            last edited by

                            Sure about the quoting?
                            -F "file=@"F:\3D_Printer\Kiss_1.6.3\EV2\Preload\KS_Wizard(8).gcode""
                            Looks like you either need to escape or change the inner qoutes, or more likely remove the outer ones?

                            1 Reply Last reply Reply Quote 0
                            • sinned6915undefined
                              sinned6915
                              last edited by

                              i updated curl to latest version. no luck

                              i played with the quotes, it does not seem to matter.

                              I am using DWC 1.22.6 and curl 7.65.1

                              can i request that someone who uses curl to do this it add the flag for verbose messages and post the output?

                              are you using username and passwd to connect to the DWC or it public?

                              JoergS5undefined 1 Reply Last reply Reply Quote 0
                              • JoergS5undefined
                                JoergS5 @sinned6915
                                last edited by

                                @sinned6915 I just saw another possibility: https://reprap.org/forum/read.php?416,819219

                                sinned6915undefined 1 Reply Last reply Reply Quote 0
                                • sinned6915undefined
                                  sinned6915 @JoergS5
                                  last edited by sinned6915

                                  i finally got this figured out. Windows is a little bit different-

                                  In KISS the script call from the Printer ->Post-Process command is

                                   <KSPATH>\EV2RRF.BAT "<FILE>"
                                  
                                  

                                  the EV2RRF.BAT script contains-

                                  ECHO ON
                                  curl -# -v --data-binary "@%1" -X POST http://192.168.0.25/rr_upload?name=gcodes/%~nx1
                                  curl "http://192.168.0.25/rr_disconnect"
                                  PAUSE
                                  

                                  the %~nx1 is to parse the filename

                                  CAUTION: something does not like dashes / minus signs in the filenames. I have not been able to determine if its KISS or CURL, but its easier to just avoid them all together.

                                  thanks to all who helped me figure this out.

                                  EDIT: The resulting command window will open and show you the progress of the transfer. It will then prompt you to hit any key to close the command window -

                                  
                                  F:\3D_Printer\Kiss_1.6.3>ECHO ON
                                  
                                  F:\3D_Printer\Kiss_1.6.3>curl -# -v --data-binary "@"F:\3D_Printer\Models\Microscope_Stand\files\arm_base.gcode"" -X POST http://192.168.0.25/rr_upload?name=gcodes/arm_base.gcode
                                  Note: Unnecessary use of -X or --request, POST is already inferred.
                                  *   Trying 192.168.0.25:80...
                                  * TCP_NODELAY set
                                  * Connected to 192.168.0.25 (192.168.0.25) port 80 (#0)
                                  > POST /rr_upload?name=gcodes/arm_base.gcode HTTP/1.1
                                  > Host: 192.168.0.25
                                  > User-Agent: curl/7.65.1
                                  > Accept: */*
                                  > Content-Length: 6109076
                                  > Content-Type: application/x-www-form-urlencoded
                                  > Expect: 100-continue
                                  >
                                  * Done waiting for 100-continue
                                  * We are completely uploaded and fine
                                  * Mark bundle as not supporting multiuse
                                  < HTTP/1.1 200 OK
                                  < Cache-Control: no-cache, no-store, must-revalidate
                                  < Pragma: no-cache
                                  < Expires: 0
                                  < Access-Control-Allow-Origin: *
                                  < Content-Type: application/json
                                  < Content-Length: 9
                                  < Connection: close
                                  <
                                  {"err":0}* Closing connection 0
                                  
                                  F:\3D_Printer\Kiss_1.6.3>curl "http://192.168.0.25/rr_disconnect"
                                  {"err":0}
                                  F:\3D_Printer\Kiss_1.6.3>PAUSE
                                  Press any key to continue . . .
                                  
                                  JoergS5undefined 1 Reply Last reply Reply Quote 0
                                  • JoergS5undefined
                                    JoergS5 @sinned6915
                                    last edited by

                                    @sinned6915 nice that you found the reason finally! Could you please post the command line which works for you, in case someone needs the command also. Would be a good documentation project.

                                    1 Reply Last reply Reply Quote 0
                                    • sinned6915undefined
                                      sinned6915
                                      last edited by sinned6915

                                      to send it via command prompt in Windows -

                                       curl  -v -F "file=KS_Wizard.gcode" "http://192.168.0.29/rr_upload?name=gcodes/KS_Wizard.gcode"
                                      

                                      where KS_Wizard.gcode was the filename

                                      JoergS5undefined 1 Reply Last reply Reply Quote 0
                                      • JoergS5undefined
                                        JoergS5 @sinned6915
                                        last edited by

                                        @sinned6915 Thank you, I see, you used the filename without any paths. Good idea. Thank you for documenting. Using curl and rr_ codes is a nice way to connect different hardware or software.

                                        I expect it was some problem of the differences between Windows, Linux and Apple of the path usage which causes the problems, maybe something not defined portable enough. Linux uses /, Windows uses \ and often must be escaped to doubled backslash or some %... value.

                                        1 Reply Last reply Reply Quote 0
                                        • sinned6915undefined
                                          sinned6915
                                          last edited by

                                          it's rough, but it works. if I take out either the -X or POST it goes kerflewie.

                                          the Expect 100-continue seems to be the message while its transfering, and it takes a bit to upload the gcode.

                                          i think part of the original issue is the KISS post-process script is using the double quotes in passing on the filename as the argument.

                                          thanks again for your support

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA