Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
85d87383
Commit
85d87383
authored
Jun 03, 2012
by
Michael Andresen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP parser
Added a little parser for the XML status returned by pronterface.
parent
4dc43e4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
parser.php
php/parser.php
+35
-0
No files found.
php/parser.php
0 → 100644
View file @
85d87383
<?php
$pronterfaceIP
=
"192.168.0.102:8080"
;
//Format: ip:port
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLINFO_HEADER_OUT
,
true
);
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$curl
,
CURLOPT_CONNECTTIMEOUT
,
1
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
1
);
curl_setopt
(
$curl
,
CURLOPT_URL
,
"http://"
.
$pronterfaceIP
.
"/status/"
);
$data
=
curl_exec
(
$curl
);
if
(
curl_errno
(
$curl
)
||
empty
(
$data
))
{
die
(
"Printer offline"
);
}
curl_close
(
$curl
);
try
{
$xml
=
new
SimpleXMLElement
(
$data
);
echo
"State: "
.
$xml
->
state
.
"<br />"
;
echo
"Hotend: "
.
round
(
$xml
->
hotend
,
0
)
.
"°c<br />"
;
echo
"Bed: "
.
round
(
$xml
->
bed
,
0
)
.
"°c<br />"
;
if
(
$xml
->
progress
!=
"NA"
)
{
echo
"Progress: "
.
$xml
->
progress
.
"%"
;
}
}
catch
(
Exception
$e
)
{
echo
"ERROR:
\n
"
.
$e
->
getMessage
()
.
" (severity "
.
$e
->
getCode
()
.
")"
;
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment