-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
sscanf compilation error #488
Comments
You need os_scanf and not os_sprintf On Mon, Jun 29, 2015, 7:04 PM nicjohnston notifications@github.com wrote:
|
Thanks for the reply, however I just tried os_scanf, and it threw the following error
|
what are you trying to do ? void setup() { Serial output should be : Starting Also, don't forget that sprintf on arduino doesnt support float or double. Just in case you wanted to use these types. |
I am attempting to extract an integer value from a char buffer into a variable; I probably should have specified this sooner. |
Ok, so this might be a dirty hack, but can you try : char *buff2 = "24"; Worked fine for me even tho it made a warning. |
String is a class not a type. char buff2[] = "24";
int i = String(buff2).toInt();
Serial.println(i); |
Thanks for reminding me about toInt, however the toInt function doesn't support parsing multiple variables from a char array. |
completely agree with @nicjohnston, we should implement |
Any news about sscanf? |
I'm looking to parse an HTTP Date header - "Thu, 15 Oct 2015 08:57:03 GMT" - into day, hours, minutes etc - I'd like sscanf too. |
any ideas for a workaround yet? |
@lighthousebulb, I guess current ugly workaround is to use Arduino String. |
@a-andreyev How do you suppose to use String instead of sscanf? |
+1 for |
Same issue. I'd need |
+1.Same issue. I'd need sscanf, too. |
while this triggers wdt resets: void setup() {
Serial.begin(115200);
Serial.println("starting");
char *data = "1234";
int i = 0;
sprintf(data,"%d", &i);
Serial.println(i);
}
void loop() { } this doesn't: void setup()
{
Serial.begin(115200);
Serial.println("starting");
char data[20];
int i = 0;
sprintf(data, "%d", &i);
Serial.println(i);
}
void loop()
{
} |
@Duality4Y "1234" is |
i am just saying that sprintf works, but the way nicjohnston was using it (probably) was with a const char * and that doesn't work. I assumed he just replaced his sscanf with sprintf. |
|
I see my mistake :) sorry for the confusion! if I understand it correctly he wants to convert a series of comma seperated values to series of ints. but yea sscanf would be nice to have! |
ok here is a thing i copy pasted together (me being way lazy), this works on your case. |
Implemented in #1752 |
Woohoo, thank you! |
Merged and available in git version. |
I would really like to use this, how can I try it out? I checked out the latest |
@igrr Has sscanf() been implemented in the latest build? I still get |
please see #3120 (comment) |
@Duality4Y Thanks Robert! This helped in the meantime. It doesn't work as is (compilation errors due to some strange blank characters in that file). I've cleaned it up at put it here for anyone who needs it: sscanf.h & sscanf.cpp. Cheers 👍 |
With arduino IDE while using NODEMCU variables are defined as 32 bit ( only "int" ) may be anyone defined it as int16_t or anything else. I used 32 bit and that solved my problem with sscanf |
I recently tried to use sscanf, however the compiler threw an undefined reference error.
Replacing sscanf with os_sprintf as recommended in issue #404 did not solve it, instead it created a watchdog timer reboot.
Here is the code I was using:
Any suggestions would be appreciated.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: