-
-
Notifications
You must be signed in to change notification settings - Fork 7k
please enhance Serial by a printf() method like ANSI C printf! #3586
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
Comments
@cmaglie, I'll leave this one for you...
You should be using backticks (same key as the tilde ~), not normal quotes. I corrected them for you. |
thanks a lot, then it's just about the first part (the printf thing) yet... ;) |
This has been discussed a lot in Developer mailist: https://groups.google.com/a/arduino.cc/forum/#!searchin/developers/printf/developers/7KpdLDgFsO0/IdW9tSmnCAQJ |
I don't see there if or how the issue has been fixed meanwhile, but Serial.printf() by multiple parameters and multiple formats is important to be provided (not just a single "%f" but all of the formatters by a multi-format string!)
it's currently extremely annoying that if one wants to write a line containing multiple strings and multiple numbers one has to write each single string and each single number individually by a mound of a billion single Serial.print()'s |
sprintf() is a nominal workaround |
theoretically there are many workarounds conceivable, but my topic is about the issue, not about a workaround. |
I implemented Serial.printf() on Teensy. If Arduino ever wants to implement this feature, it's only a small amount of open source code.
I agree, it is annoying to write several lines, when you know how to do it with a single printf() line. But Arduino's design decision is about other people reading the code, especially those not familiar with the complexities of printf format strings. For them, reading sketches with complex syntax is annoying. So is having to learn a cryptic syntax before being about to write similar lines. I imagine you're unmoved by this thinking, but my point it not to convince you. My point is to explain why Arduino has resisted Serial.printf(). If you better understood Arduino's point of view, perhaps you could compose a more compelling argument? Obviously you don't yet understand their point of view, because the best argument you've been able to muster is that you, personally, as an experienced C programmer, are annoyed by having to write multiple simple lines. You're rather compose 1 complex line of code. Can you at least try to imagine how that must sound to a group of designers who overriding goal is simplicity for a novice-oriented system that priorities ease-of-learning above all else? |
@PaulStoffregen What do you think about https://github.com/arduino/Arduino/issues/3546 (and #3551) ? |
I have mixed feelings regarding both of those. Likewise, I believe printf() is great for experts, but I also recognize the Arduino Team's concerns. I do not have all the answers to these sorts of tough design trade-offs! |
printf is not for experts, it's just for C programmers who are used to stdio.h, and it's just the same for sprintf() which is already implemented by Sketch (apart from this effing float formatting issue for AVRs). |
Ok then, I guess that's a "no", you can't try to understand Arduino's point of view? |
not quite, |
I think the point, why we often talk at cross purposes, is: |
For anyone else who wants Serial.printf(), please understand these 2 arguments do NOT work:
In closing this issue, I want to give some guidance to those who will inevitably being up Serial.printf() again and again. Please, do yourself a favor, try to express your argument from a viewpoint of understanding Arduino's design goals. |
I am not experienced in C - I understand that Arduino implements beginner-friendly API functions, but that does not mean that Arduino has to exclude and drop and abandon all basic C facilities such as stdio.h functions in return. The C concept is based on libraries which can be optionally #included or not in order to decide which funtionality is wanted and which one not.
|
This is another approach: http://www.arduiniana.org/libraries/streaming |
I don't see whether this has anything to do with my intention of my TOP! I hate it having to write each parameter one by one and being unable to format numbers adequately and suitably ! Serial.printf ("Characters: %c %c \n", 'a', 65); |
Does this help? http://playground.arduino.cc/Main/Printf |
thank you, but the installation guide is very complicated, and moreover they say: |
please enhance Serial by a Serial.printf() method like ANSI C printf()!
The current output features are far too poor!
So output should be possible by a formatstring and a multi-format-multiple-argument list, including e.g.,
just as shown here:
http://www.cplusplus.com/reference/cstdio/printf/
OT:
I'm really curious why this effing code block formatting does not work! What a poor editor!
The text was updated successfully, but these errors were encountered: