-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
M408 #6970
M408 #6970
Conversation
Out of curiosity, what's the (or your) use case for this? |
.gitignore
Outdated
@@ -136,3 +136,7 @@ CMakeListsPrivate.txt | |||
|
|||
#CLion | |||
cmake-build-* | |||
.pioenvs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the following one are already covered by line 120.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were auto appended with gui
@bgort I would like to create a web interface |
I don't see any reason not to merge this. It's conditionally compiled, and as long as it works, I can't see how it hurts anything. Let's give @thinkyhead a bit longer to comment and then I'll merge it. |
.travis.yml
Outdated
- restore_configs | ||
- opt_enable REPORT_M408_JSON | ||
- build_marlin | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable the option in one of the other tests, rather than requiring an additional build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is more prefered? PRINTCOUNTER ?
Marlin/Marlin_main.cpp
Outdated
SERIAL_PROTOCOLPGM("],\"fraction_printed\": "); | ||
SERIAL_PROTOCOL_F(card.percentDone() * 0.01, 3); | ||
#else | ||
SERIAL_PROTOCOLPGM("]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SERIAL_PROTOCOLCHAR(']');
} | ||
#endif | ||
//skipped standbay & hstat | ||
SERIAL_PROTOCOLPGM("],\"pos\": ["); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These custom print statements that create key/value strings should probably be implemented as a small function taking the key and value. The code will likely end up smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, but don't see good solution yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single key-value output would be…
void floatkey(const char *pstr, const float &val, const bool comma=false) {
SERIAL_CHAR('"'); serialprintPGM(pstr); SERIAL_CHAR('"');
SERIAL_CHAR(':'); SERIAL_ECHO(val);
if (comma) SERIAL_ECHO(',');
}
And a function for XYZ elements…
void xyzkey(const char *pstr, const float val[XYZ], const bool comma=false) {
SERIAL_CHAR('"'); serialprintPGM(pstr); SERIAL_CHAR('"');
SERIAL_ECHO(":[");
SERIAL_ECHO(val[X_AXIS]); SERIAL_CHAR(',');
SERIAL_ECHO(val[Y_AXIS]); SERIAL_CHAR(',');
SERIAL_ECHO(val[Z_AXIS]);
SERIAL_CHAR(']');
if (comma) SERIAL_ECHO(',');
}
Marlin/Marlin_main.cpp
Outdated
if (print_job_timer.isPaused()) | ||
SERIAL_PROTOCOLCHAR('A'); // PAUSED | ||
else | ||
SERIAL_PROTOCOLCHAR('B'); // SOMETHING ELSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put else if
keywords together on the same line. Or use this:
SERIAL_PROTOCOLCHAR(
!planner.blocks_queued() ? 'I' : // IDLING
(IS_SD_PRINTING || print_job_timer.isRunning()) ? 'P' : // SD Printing
print_job_timer.isPaused() ? 'A' : // PAUSED
'B' // SOMETHING ELSE
);
Marlin/Marlin_main.cpp
Outdated
#else | ||
SERIAL_PROTOCOLPGM("]"); | ||
#endif | ||
SERIAL_PROTOCOLLNPGM("}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SERIAL_PROTOCOLCHAR('}');
11934f2
to
f37ed31
Compare
176f7be
to
37e8499
Compare
Something screwy is going on here. The base was changed to Please redo. |
http://reprap.org/wiki/G-code#M408:_Report_JSON-style_response
+802 bytes