Notifications
Clear all

What happened with `printf` and its family?

39 Posts
6 Users
9 Likes
1,875 Views
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 5883
 

@frogandtoad Go watch Bills video, nothing to do with browser plugins, no need to keep session alive, simply doesn't work that way.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 5883
 

@frogandtoad Understood.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 4 years ago
Posts: 1506
 

@zander

Posted by: @zander

@frogandtoad Go watch Bills video, nothing to do with browser plugins, no need to keep session alive, simply doesn't work that way.

Where's themz goggles of yours? πŸ™‚

From the ~6 min mark, he shows that you need to set up an account, and then the next step is to install an "agent" which constantly runs in the background (this could be considered a plugin or extension), and is exactly what I was talking about... this is the means of creating an open session between your workstation and the cloud itself, providing access to libraries etc...


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 5883
 

@frogandtoad Whatever, I do recall needing to install an 'agent'. No idea what for or why but if Bill says it's needed to make it work then of course I do it. I just looked and there is no browser extension, I don't see anything relevant running in my dock. I assume I installed it but no trace now and now just for chuckles I tried logging in with a browser I don't normally use and it also works so whatever the agent is it isn't attached to a specific browser. I don't know or care, it just works.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 4 years ago
Posts: 1506
 

@zander

Posted by: @zander

@frogandtoad Whatever, I do recall needing to install an 'agent'. No idea what for or why but if Bill says it's needed to make it work then of course I do it. I just looked and there is no browser extension, I don't see anything relevant running in my dock. I assume I installed it but no trace now and now just for chuckles I tried logging in with a browser I don't normally use and it also works so whatever the agent is it isn't attached to a specific browser. I don't know or care, it just works.

Well, I did say I have never used it, and prefer not to... I made an educated guess that it might be a browser plugin/extension, but either way, my point was that you "did need to install something" to enable a communicating session, and it just so happens to be a stand alone agent instead (which is nothing more than an executable running in the background), in this case an agent creating a type of web network socket through which it communicates with the cloud, and other agents on that side of the fence.

Anyway, these are important details that you're leaving out... so you should care πŸ™‚


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 3 years ago
Posts: 5883
 

So sorry, I thought this was my thread. My mistake, now I will update my question as solved.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
frogandtoad reacted
ReplyQuote
Inq
 Inq
(@inq)
Noble Member
Joined: 2 years ago
Posts: 1842
 
Posted by: @ronsmitsnl

I have programmed a lot in C and C++, not on embedded controllers but on unix machines writing servers and drivers. One of the functions I used a lot was the `printf` family:

char temp[40];
float aFloat = 10.0
int anInt = 5
char *str = "a test string";
sprintf (temp, "%f %d %s", aFloat, anInt, str);

I notice that in a lot of sketches two or even three Serial.print and Serial.println are used to convey some information to the console. Is there a reason the printf family is not used?

Β 

RonS

This must be MPU dependent.Β  I remember the, "three Serial.print and Serial.println" Mickey Mouse when using Arduino's.Β  Don't know if they still have that problem.Β  I'd bet it is because of the limited memory on them.Β  But haven't used Arduino's in years since switching to ESP8266.Β  The printf has always worked on the ESP8266 for most things.Β  Up till some time a year ago, the %f, %G types didn't work.Β  Now, they do.Β  I haven't used every aspect of printf, but all that I use including float and double formats work except 64bit integers.Β Β 

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
(@ronsmitsnl)
Eminent Member
Joined: 2 years ago
Posts: 20
Topic starter  

@inq I dont know if it is MPU dependent or framework dependent. The printf functions I mentioned work for me using platform.io with the arduino framework. Ugly I know but it worked for what I wanted.

char buffer[120];
    sprintf(buffer, "{\"hum\":%.2f, \"temp\":%.2f, \"soilPercent\":%d, \"pump\":%s, \"delay\":%d}", hum, temp, soilPercent, pump ? "true" : "false", sensorMillis / MINUTE);


   
ReplyQuote
Inq
 Inq
(@inq)
Noble Member
Joined: 2 years ago
Posts: 1842
 
Posted by: @ronsmitsnl

@inq I dont know if it is MPU dependent or framework dependent. The printf functions I mentioned work for me using platform.io with the arduino framework. Ugly I know but it worked for what I wanted.

char buffer[120];
    sprintf(buffer, "{\"hum\":%.2f, \"temp\":%.2f, \"soilPercent\":%d, \"pump\":%s, \"delay\":%d}", hum, temp, soilPercent, pump ? "true" : "false", sensorMillis / MINUTE);

I'm using the plain ole Arduino IDE from Arduino.cc.Β  Under it, it is MPU dependent.

  • If I select an ESP8266 board, both printf and sprintf work just as you expect them.
  • I just pulled an old UNO out of a dusty box 😉 and printf won't compile and sprintf works with integers (%d), but does not work correctly with floats (%f).

I no longer use platform.ioΒ with native or Arduino framework.

VBR,

Inq

Β 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
Page 3 / 3