sxj1121
-
Posts
16 -
Joined
-
Last visited
-
Days Won
2
Content Type
Forums
Events
3D Prints
Posts posted by sxj1121
-
-
Refer to this post. It also works in PHP and python scripts.
-
I have the same issue as yours. Do you also use the latest firmware? Right now, I could send G-Code as 'ultimaker'. But as 'root', the dbus part doesn't work. I searched by Google, it looks like dbus needs a correct interface, or some other problem leads to this. If you find out any solutions, please share. Thanks!
-
11 hours ago, zaaf77 said:
@sxj1121... .. Many thanks for your help and is much much appreciated! Thanks for the piece of code just above as well as a reference to your PHP7, Would you be kind enough to share the link to this.... I mean PHP7 you just mentioned above....
Much appreciated once again and thankyou so very much...
Have a nice day!
you could download and install xampp, it would be easier for you to start programming. https://www.apachefriends.org/index.html
- 1
-
3 hours ago, zaaf77 said:
@sxj1121
any chance you got your printing done with PHP, would you like to share some more on it then? I am working on the same thingy, actually I want to authorize the user to print GCODE files from my website to directly to their 3DPrinter say ( ultimaker S5). I also want to restrict the number of prints as well but that's second step. More interested into the process of printing a GCODE directly from my website to the 3D printer, have you any thoughts on it? Waiting on you and thanking you in advance!
I am sorry that I can't directly share my code with you due to the restrictions of our lab. You could try to start from posting a gcode file on windows cmd by curl.
In my PHP code, I also use curl to send gcode file. You could refer to my previous post.
For PHP7, it is:
$data_array = array(
'jobname' => 'file',
"file" => new \CURLFile($filedata)
);
If you want develop a perfect website. You need to develop a PHP file for using Get, Put, Post to call the API. Then develop another PHP file to receive the file which is uploaded from the front-end. Next save the file to local (You don't really need this step, but I don't know how to skip it). Then upload this file from local to API by Post.
For restricting the number of prints, you could use AJAX to get the real-time print process. If it's not Not Found, then disable the upload function. But I think if 3D printer starts printing, then keep uploading files won't make any changes.
- 1
-
For ultimaker 3 extended, I upgraded the firmware to the latest version and then set the ip address of it as static. Then I tried to use ssh to send G-Code.
It works perfectly for:
ssh ultimaker@ip
password ultimaker
sendgcode G28.
But if I login as root, and go to the /usr/share/griffin/command_util.py. Then all commands except "help" don't work and it returns error as the following pictures. How to fix this problem? Or is there any way to downgrade the firmware version to 4.3.2?
Any help would be appreciated!
-
Is there any way to show the G-Code that is running? I went to the API Documentation, but it looks like that it only shows whole G-Code command. Or is the printrun through USB the only solution? Any help would be appreciated!
-
120 hours ago, sxj1121 said:
I tried to realize this by PHP or Python as the following code. But after running that py file, any command doesn't work. Do you have any idea about how to fix this? Thank you very much!
<?phpset_include_path('C:/xampp/htdocs/phpseclib1.0.15');include('Net/SSH2.php');$ssh = new Net_SSH2('ip');if (!$ssh->login('root', 'ultimaker')) {exit('Login Failed');}echo $ssh->exec('python3 /usr/share/griffin/command_util.py && help');?>#import paramiko# realize transporttrans = paramiko.Transport(('ip', 22))# connectiontrans.connect(username='root', password='ultimaker')# Specify the transport of the sshclient object as the above transssh = paramiko.SSHClient()ssh._transport = trans# execute commandstdin, stdout, stderr = ssh.exec_command('python3 /usr/share/griffin/command_util.py \n sendgcode G28')print(stdout.read().decode())# close connectiontrans.close()Just delete "&&" in PHP or "\n", then it would work.
-
I figured out the reason. Just delete "&&" in PHP or delete"\n" and it would work.
-
Is there any other way to send gcode to the 3d printer?
-
I tried to send gcode to my 3d printer by PHP and Python. The following code could connect to it, but couldn't execute any command after running that py file. Any help would be appreciated!
<?php set_include_path('C:/xampp/htdocs/phpseclib1.0.15'); include('Net/SSH2.php'); $ssh = new Net_SSH2('ip'); if (!$ssh->login('root', 'ultimaker')) { exit('Login Failed'); } echo $ssh->exec('python3 /usr/share/griffin/command_util.py && help'); ?>
# import paramiko # realize transport trans = paramiko.Transport(('ip', 22)) # connection trans.connect(username='root', password='ultimaker') # Specify the transport of the sshclient object as the above trans ssh = paramiko.SSHClient() ssh._transport = trans # execute command stdin, stdout, stderr = ssh.exec_command('python3 /usr/share/griffin/command_util.py \n sendgcode G28') print(stdout.read().decode()) # close connection trans.close()
-
11On 2/8/2018 at 9:25 AM, gr5 said:
Well the Um2 is simpler. You can control it through USB (it's not officially supported but it works pretty well). It has Marlin firmware which is on hundreds of different types of printers (most printers out there). There is software called "octoprint" that allows you to control printers through USB or you can simply send gcodes with any software you want to write.
The um3 indeed has a linux stack. You can log in with ssh username and password is root/ultimaker. You have to put the printer into developer mode first (it's a menu option on the printer).
Everything is in python so the source code is all visible and commented on the printer itself. Well some of it is in json files (javascript).
Once in you can go to the /usr/share/griffin folder and do this:
python3 command_util.py
Then do "sendgcode" followed by the gcode you want to send. This might be too slow (not real time enough for you) so you might want to create some kind of web service. If you do *please* share.
I tried to realize this by PHP or Python as the following code. But after running that py file, any command doesn't work. Do you have any idea about how to fix this? Thank you very much!
<?phpset_include_path('C:/xampp/htdocs/phpseclib1.0.15');include('Net/SSH2.php');$ssh = new Net_SSH2('ip');if (!$ssh->login('root', 'ultimaker')) {exit('Login Failed');}echo $ssh->exec('python3 /usr/share/griffin/command_util.py && help');?>#import paramiko# realize transporttrans = paramiko.Transport(('ip', 22))# connectiontrans.connect(username='root', password='ultimaker')# Specify the transport of the sshclient object as the above transssh = paramiko.SSHClient()ssh._transport = trans# execute commandstdin, stdout, stderr = ssh.exec_command('python3 /usr/share/griffin/command_util.py \n sendgcode G28')print(stdout.read().decode())# close connectiontrans.close() -
On 5/18/2019 at 5:31 AM, Daid said:
That shouldn't happen, a id+key should remain valid unless the machine is factory reset. So you only need it once. (On HTTP Digest level things do expire, but I would expect PHP to handle this for you seamlessly)
Thank you very much! I solved this POST print_job problem. There are several syntax errors of PHP code.
-
Finally solved it. It's just some PHP syntax error.
'file' => "@$filedata" doesn't work for PHP7. Besides, this file must be a local file.
There is no need to set CURLOPT_HTTPHEADER.
CURLOPT_HEADER must be set as 0
- 1
-
I developed a web application by PHP. If I want to use POST print_job, do I need to generate new id and key every time? Because I found that a previous authorized id and key would be unauthorized next time. By the way, do I need to set api key? Thank you very much!
- 1
-
Our team is working on developing a web application for accessing The UM3E remotely in PHP, We tried implementing the POST print_job part using the multipart/form-data but it doesn't work. It shows no file received. Here is the code. Any help is appreciated!$curl = curl_init();$filedata = $_FILES["fileToUpload"]["tmp_name"];$data_array = array("jobname" => "test","file" => "@$filedata");$headers = array("Content-Type:multipart/form-data");$options = array(CURLOPT_URL => $url,CURLOPT_HTTPAUTH => CURLAUTH_DIGEST,CURLOPT_USERPWD => $username . ":" . $password,CURLOPT_HEADER => true,CURLOPT_POST => 1,CURLOPT_HTTPHEADER => $headers,CURLOPT_POSTFIELDS => $data,CURLOPT_RETURNTRANSFER => true);curl_setopt_array($curl, $options);$result = curl_exec($curl);
Troubleshooting in Developer mode
in Firmware
Posted
For us, we just want to provide a way for users to learn G-Code and coordinate system by 3D printer.