Loading...
Welcome,
Guest
. Please
login
or
register
.
June 19, 2013, 04:46:33 pm
|
Arduino Forum
::
International
::
Français
(Moderators:
Jean-François
,
Snootlab
) :: Sprintf
« previous topic
next topic »
Pages: [
1
]
Go Down
Print
Author
Topic: Sprintf (Read 244 times)
0 Members and 1 Guest are viewing this topic.
saraza
Offline
Newbie
Karma: 0
Posts: 36
Sprintf
«
on:
January 05, 2013, 10:27:03 am »
Bigger
Smaller
Reset
Bonjour,
Je rencontre un souci en utilisant sprintf.
Voici mon code :
Code:
long lat2, lon2;
Serial.println(lat2);
Serial.println(lon2);
sprintf(adresse,"AT+HTTPPARA=\"URL\",\"site.fr/val.php?id=1&lat=%d&long=%d\"",lat2,lon2);
Serial.print(adresse);
mySerial.println(adresse);
Et ce que j'obtiens sur mon Serial :
Code:
449205
21367
AT+HTTPPARA="URL","site.fr/val.php?id=1&lat=29753&long=7"
Je ne comprend d'où viennent ce 29753 et ce 7...
J'ai dû faire une erreur quelque part mais je la vois vraiment pas.
Logged
fdufnews
France
Offline
Edison Member
Karma: 13
Posts: 1841
There is an Arduino for that
Re: Sprintf
«
Reply #1 on:
January 05, 2013, 10:44:52 am »
Bigger
Smaller
Reset
Code:
sprintf(adresse,"AT+HTTPPARA=\"URL\",\"site.fr/val.php?id=1&lat=%d&long=%d\"",lat2,lon2);
449205
21367
AT+HTTPPARA="URL","site.fr/val.php?id=1&lat=29753&long=7"
Quote
Je ne comprend d'où viennent ce 29753 et ce 7...
lat2 et lon2 sont définis comme des long. Il faudrait le préciser dans la ligne du sprintf
Code:
sprintf(adresse,"AT+HTTPPARA=\"URL\",\"site.fr/val.php?id=1&lat=%ld&long=%ld\"",lat2,lon2); // il faut ajouter l devant le d pour indiquer que c'est un long
Logged
saraza
Offline
Newbie
Karma: 0
Posts: 36
Re: Sprintf
«
Reply #2 on:
January 05, 2013, 10:49:20 am »
Bigger
Smaller
Reset
Merci beaucoup, c'était ça !
Logged
skywodd
France
Offline
Faraday Member
Karma: 36
Posts: 4451
Arduino Hacker
Re: Sprintf
«
Reply #3 on:
January 07, 2013, 12:47:37 pm »
Bigger
Smaller
Reset
Bonjour,
Au passage tu remarqueras qu'une grande partie de ta chaine est statique
Seule la partie verte change :
Quote
sprintf(adresse, "AT+HTTPPARA=\"URL\",\"site.fr/val.php?id=1&lat=
%ld&long=%ld\
"", lat2, lon2);
Tu peut donc gagner en vitesse et en RAM en faisaint comme ceci :
Code:
Serial.print(F("AT+HTTPPARA=\"URL\",\"site.fr/val.php?id=1&lat="));
Serial.print(lat2);
Serial.print(F("&long="));
Serial.print(lon2);
Serial.println(adresse);
Plus besoin de sprintf (qui est super lourd et gourmand en ressource).
Logged
Des news, des tuto et plein de bonne chose sur
http://skyduino.wordpress.com
!
Pages: [
1
]
Go Up
Print
« previous topic
next topic »
|
Arduino Forum
::
International
::
Français
(Moderators:
Jean-François
,
Snootlab
) :: Sprintf
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
-----------------------------
Using Arduino
-----------------------------
=> Installation & Troubleshooting
=> Project Guidance
=> Programming Questions
=> General Electronics
=> LEDs and Multiplexing
=> Displays
=> Audio
=> Motors, Mechanics, and Power
=> Sensors
=> Networking, Protocols, and Devices
=> Interfacing w/ Software on the Computer
-----------------------------
Topics
-----------------------------
=> E-Textiles and Craft
=> Robotics
=> Science and Measurement
=> Home Automation and Networked Objects
=> Device Hacking
=> Education and Teaching
=> Interactive Art
=> Product Design
-----------------------------
Development
-----------------------------
=> Suggestions for the Arduino Project
=> Other Hardware Development
=> Other Software Development
-----------------------------
Community
-----------------------------
=> Website and Forum
=> Products and Services
=> Gigs and Collaborations
=> Workshops and Events
=> Local Groups
=> Exhibition / Gallery
=> Bar Sport
-----------------------------
International
-----------------------------
=> Deutsch
=> Español
=> Français
=> Italiano
=> Portugues
=> Scandinavia
-----------------------------
Forum 2005-2010 (read only)
-----------------------------
===> Uno Punto Zero
===> Bar Sport
===> Frequently-Asked Questions
===> News
===> Exhibition
===> Workshops
===> Interfacing
===> Bugs & Suggestions
===> Development
===> Troubleshooting
===> Portugues
===> Deutsch
===> Español
===> Français
===> Italiano
===> Scandinavia
===> Development
===> Interfacing
===> Syntax & Programs
===> Bugs & Suggestions
===> Troubleshooting
===> Report Spam at Arduino.cc
===> Forum
===> Playground Wiki
=> General
=> Hardware
=> Software
=> International
=> Web/Forum/Email/Spam
-----------------------------
Using Arduino
-----------------------------
=> Storage
=> Microcontrollers
-----------------------------
International
-----------------------------
===> Humor y Debate
===> Talleres, Encuentros, ...
===> Tutoriels et cours
===> Réalisations et Projets Finis
===> Le bar
=> Nederlands
===> Software
===> Hardware
===> Proyectos
===> Documentación
=> India
===> Hardware
===> Software
===> Megatopic
-----------------------------
Products
-----------------------------
=> The Arduino Starter Kit
=> Arduino Due
-----------------------------
International
-----------------------------
===> Generale
-----------------------------
Products
-----------------------------
=> Arduino Esplora
=> Arduino GSM Shield
-----------------------------
Maker Faire Rome - The European Edition
-----------------------------
=> Makers
=> Events and Tour
Loading...