Thanks Thanks:  1
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 8 of 8
  1. #1
    3D Printer Noob
    Join Date
    Mar 2018
    Posts
    17
    Post Thanks / Like

    A simple print manager, send file to printer

    As talked about in this thread: http://www.print3dforum.com/showthre...ll=1#post44194

    I have a working python script that can send a file directly to your printer via Ethernet. I tested this on my Cube Pro over wifi and it works for me. I wrote this to work under Linux where I run Cura. It probably works under Windows although you might need to change the first line of the script to invoke python3 in Windows.

    For now you can just send a file like this

    ./print_client.py --file=test_print.cubepro --ip=10.0.10.204

    There is a "help" option for the flags. You should use the address of your printer, no discovery service just yet. There are other bits and pieces in the main that are commented out but work, but I don't need them yet.

    The project is located here: https://github.com/boilerbots/3ds_print_manager

  2. #2
    3D Printer Noob
    Join Date
    Feb 2017
    Posts
    28
    Post Thanks / Like
    thank your for your work
    I tried but its not working on cube 3 I get the following


    Chamans-MacBook-Pro:~ me$ python print_client.py --file=hhh.cube3 --ip=192.168.0.14
    flushing
    Traceback (most recent call last):
    File "print_client.py", line 195, in <module>
    main()
    File "print_client.py", line 184, in main
    printer.method25()
    File "print_client.py", line 128, in method25
    self.sendAndCheck(message)
    File "print_client.py", line 111, in sendAndCheck
    receive_message = self.socket.myreceive().decode()
    File "print_client.py", line 45, in myreceive
    chunk = self.sock.recv(4096)
    socket.timeout: timed out



    any idea 💡

    thanks

  3. #3
    3D Printer Noob
    Join Date
    Mar 2018
    Posts
    17
    Post Thanks / Like
    Comment out line 128 and try again. Maybe the cube doesnít know what method 25 is.

    You can also try to enable the call to get the config and see what happens.

    Looks like you are using a Mac so I would expect python to work fine for you.

  4. #4
    3D Printer Noob
    Join Date
    Feb 2017
    Posts
    28
    Post Thanks / Like
    its work with cube 3 now

    @ boilerbots thank you for sharing this script

    So this works when I Commented some lines ( I wasn't able to find the problem since I don't have any experince with python language but I think the Problem happens in the while not end loop inside def myrecive) :

    Any ways I commented this lines and it works like charm :

    def sendAndCheck(self, message):
    expected_method = json.loads(message[:-1])['header']['msg_method']


    self.socket.flush()
    self.socket.mysend(message)
    # receive_message = self.socket.myreceive().decode()
    # config = json.loads(receive_message)
    # if config['header']['msg_method'] != expected_method:
    # print("Error processing response")
    # print("Received: {}\n".format(receive_message))

    And at the end I added:

    printer.method25()( this packet used to wake up the printer)
    time.sleep(5) ( added time sleep to ensure that the printer is waked up ,, without this some times transfer is fail )
    printer.printFile(args.file)
    time.sleep(15) ( in my case without this printer does not shows the print msg on the printer )
    printer.method11(args.file)

    Nb :
    - I'm using this script under Mac OS
    - I'm using app called CrossOver to open the "cube3-encoder-32bit.cmd" script which generate the .cube file from .bfb
    - you can download the modified version of script from here https://drive.google.com/open?id=190...5byDC7R5kGbZLt
    Last edited by chaman; 05-08-2018 at 10:11 PM.

  5. Thanks bolsoncerrado thanked for this post
  6. #5
    Regular 3D Printer
    Join Date
    Feb 2018
    Posts
    62
    Post Thanks / Like
    <sidetrack warning!> Please ignore if this would get the discussion off track!!

    @boilerbots - What version of Cura are you using to make your .bfb files?

    @chaman - How are you making your print files? CubePrint -- or another slicer?

    Thanks!
    Last edited by JohnTee; 05-09-2018 at 04:10 AM.

  7. #6
    3D Printer Noob
    Join Date
    Mar 2018
    Posts
    17
    Post Thanks / Like
    @chaman It is interesting that you basically have disabled the checking for any return messages from the printer. I wonder if perhaps you have a firewall that blocks the response. I don't have a cube 3 so I don't know what we shoudl expect to see.

    If someone was really wanting to help figure out how to make this work better on a cube 3, they can use wireshark to capture how the cube software send a job to the printer or what happens when they run my script and then save the log and either upload it as a bug issue on github or perhaps attach the file here in this forum. To make the wireshark capture as clean as possible you should use a filter rule such as the following, changing the addresses to your printer's address

    ip.dst == 10.0.10.204 or ip.src == 10.0.10.204

    Just paste that into the filter rule box on wireshark and make sure to select the primary network interface. After you execute a file upload to the printer, press the stop button and then the "Save this capture to a file" button.

    It is nice to also understand that method25 wakes your printer up, I had not figured that out yet.

    - - - - - - - - - -

    Quote Originally Posted by JohnTee View Post
    <sidetrack warning!> Please ignore if this would get the discussion off track!!

    @boilerbots - What version of Cura are you using to make your .bfb files?

    @chaman - How are you making your print files? CubePrint -- or another slicer?

    Thanks!
    When I figure out Cura, I plan on updating the thread I started about it. I am using the latest version of Cura, 3.2 I think. I wanted to get this python script working because I am sending very short hand written g-code files to the printer to test out commands. I hope to spend time on getting Cura working over the next few nights after work.

    - - - - - - - - - -

    Based on the feedback from @chaman I added a --cube3 and a --nocheck option to the script. It would be nice to not need it but people can try those options to see if it helps out. It only adds the time delay and skips checking for a response from the printer.

    - - - - - - - - - -

    Another problem, it seems that files encoded with cube-utils using cubepro-encoder can not be sent over wifi. The file encoding is different and does not contain the file length and other identifying information in the encoded file that the output from CubePro software includes. The files will load from a usb thumbdrive but I can't send them with the python script I just created

    - - - - - - - - - -

    I spoke to soon, if I send to the printer the actual file length instead of extracting it from the cubepro files then I can send our own custom encoded files. The output from CubePro embeds the length in the file that it sends and I though that was special and was taking it from bytes 2-4. Anyway problem resolved, new version pushed to GitHub already.

  8. #7
    3D Printer Noob
    Join Date
    Feb 2017
    Posts
    28
    Post Thanks / Like

    @boilerbots

    I think its not a firewall problem since I turn it off before starting tests
    I tried your new script its work only if you change the header back
    From
    header = (pf_length).to_bytes(
    4
    , byteorder=
    'little'
    )+b
    '\x00\x00\x00\x00'

    To header = pf[4:8]+b'\x00\x00\x00\x00'

    And must use the --nocheck option , also there is something I don't understand when I tried the script with an original .cube fie exported from cube print application its work without need to add --cube3 , but if i use it with .cube file exported from "cube3-encoder" i should add the --nocheck and --cube3 otherwise it will not work.

    here you can find my Wireshark logs ... my printer ip is 192.168.0.14.
    https://drive.google.com/open?id=1BX...f48wt59Xeb_CN_

    thanks

    - - - - - - - - - -

    @JohnTee

    I'm using simplify3d to slice the .stl file then ''cube3-encoder-32bit.cmd" to get the .cube file then I send it to the printer using @boilerbots script

    NB : I'm using @swwinterry profile for simplify3d you can find it here
    https://drive.google.com/file/d/1Ffh...YEy0wNFCI/view

    - - - - - - - - - -

    @boilerbots
    I think it will be very Nice if you can add percentage transfer progress to your script

  9. #8
    3D Printer Noob
    Join Date
    Mar 2018
    Posts
    17
    Post Thanks / Like
    @chaman

    What type of printer specifically do you have?

    When you say that it fails are you talking about a message like "Error processing response" or that it just didn't work. Because I am printing error messages when I receive an unexpected response from the printer but it might have successfully sent the file to the printer. I haven't worked out when the printer replies back with what it does, it seems to sometimes do what it wants. I need to build a more robust parser to decode the received messages, right now the "flush" messages are from my script trying to throw out anything in the input buffer.

    - - - - - - - - - -

    I see you included some output from the terminal, so the failure is an actual TCP timeout. I will take a look at the wireshark logs tomorrow. I spent the night trying to figure out some g-code problems.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •