Pages: 1 [2]   Go Down
Author Topic: How to add variable to #define  (Read 2869 times)
0 Members and 1 Guest are viewing this topic.
Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is etherShieldNEW.h and es.ES_client_http_post()/etc your code, or from some standard library that I can't find anywhere?

It's the library I got from Andy (also on this forum) his website: http://blog.thiseldo.co.uk/?p=344

file:
http://blog.thiseldo.co.uk/wp-files/etherShield_pachubeclient.zip

He uses it for sending data to Twitter and Pachube.
I thought that I can use it to send data to my "save.php" file because the other code that I use from "Nuelectronics" doens't work for more then 1 hour: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1219733115/15#15


Quote
What you need is a version of es.ES_client_http_post() that accepts the URL part as a normal string rather than a PSTR.  It MIGHT already exist.  If not, you might want to consider a compromise solution where you have both a PSTR (constant) part of the URL string AND a variable part of the string

Yep, that's exactly what I need. But how to make it...
Like I said, I tried tons of options, the most didn't even compile, while some of it does, and the sketch started, but no update on the php file from the server.

Besides that, I am not that good in all this things.

Therefore I absolutely appreciate the help of you pro guys smiley-grin

With kind regards from the Netherlands,

Atmoz
« Last Edit: November 02, 2009, 02:44:25 am by Atmoz » Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, thanks for that explanation, westfw.

Now, Atmoz...

This means that you need a different approach to fabricating the strings you pass to the EtherShield routine that will change. You have to replace PSTR with the standard C functions for string manipulation (in string.h), which put the result in RAM (so that it can be modified during the run of your program).

So you're back to the approach that westfw and I described earlier in this thread. Is it clear?
Logged

.andy

Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thanks.

It is clear that I have to make my "own" procedure to get this working, but the problem is that I don't know where to start. And second my program skills from the Arduino environment aren't that good.

I prefer Borland Delphi to progam in ;D

In the meanwhile I send another Andy (the maker of the website and library that I mentioned before) a message if he can looks at this.

If he can make a whole working network library, then he probably also can make a procedure to send variable data to a php file 8-)


With kind regards,

Atmoz
Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The reason no one has just written the code for you here in the forum, Atmoz, can be related in an old expression. It goes something like:

"If you give someone a fish you have caught, he eats for a day; if you show him how to fish for himself, he eats for a lifetime."

If you want to do more than simple things in software (your issue is completely independent of Arduino and is a standard C programming language task), it will be good to learn how to do these things, beyond cutting and pasting code fragments together.

We are trying to lead you towards a solution, rather than just writing the code for you. You will have more power if you figure out how to solve this kind of problem, how to approach a solution process, rather than just using other's code.

The code you have there is reasonably complex and it is written in a fairly obtuse style, so it's not easy to unravel what is going on. I don't know Delphi, but it appears to be a visual programming language. So if this is your first C experience, I'm not surprised you are struggling.

If this Arduino stuff interests you, you might want to invest some time in a C language tutorial. Also, Massimo Banzi's book, "Getting Started with Arduino," is a very readable and accessible introduction to Arduino programming.

In the interest of fishing, I will try to spend a little time later working up a simple example that might help you understand the string problem you need to solve.

Apologies if I have underestimated your experience; no offense intended.

.andy
Logged

.andy

Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thanks for your post Andy.
Don't worry, you haven't underestimated my experience.
Like I said, I don't know much about all this things. Thereby, my English isn't that good either. I constantly have to pick a dictionary to find the explanation of some things...

Some therms are so technically, that this is very difficult to understand.

And there are no friends or so that can help me with the electronic stuff because all of them plat football or something instead of it smiley-razz

You're right that I better can invest some time in all this things, but the problem is that this is REALLY nice stuff, and I can't wait to get it working. I spent maybe 10 hours on it, without get it working. Yes, I got something working with fixed text, that was very cool!! But when it's still not working after you tried so many times, it's time to ask for help.

But anyway, I took a look at the procedure again and found:


Code:
     // ----- http get
      void ES_client_browse_url(prog_char *urlbuf, char *urlbuf_varpart, prog_char *hoststr,void (*callback)(uint8_t,uint16_t));
      // The callback is a reference to a function which must look like this:
      // void browserresult_callback(uint8_t statuscode,uint16_t datapos)
      // statuscode=0 means a good webpage was received, with http code 200 OK
      // statuscode=1 an http error was received
      // statuscode=2 means the other side in not a web server and in this case datapos is also zero
      // ----- http post
      // client web browser using http POST operation:
      // additionalheaderline must be set to NULL if not used.
      // method should be used if default POST to be overridden set NULL for dfault
      // postval is a string buffer which can only be de-allocated by the caller
      // when the post operation was really done (e.g when callback was executed).
      // postval must be urlencoded.
      void ES_client_http_post(prog_char *urlbuf, prog_char *hoststr, prog_char *additionalheaderline, prog_char *method, char *postval,void (*callback)

(uint8_t,uint16_t));
      // The callback is a reference to a function which must look like this:
      // void browserresult_callback(uint8_t statuscode,uint16_t datapos)
      // statuscode=0 means a good webpage was received, with http code 200 OK
      // statuscode=1 an http error was received
      // statuscode=2 means the other side in not a web server and in this case datapos is also zero

All the parameters are prog_char (not possible to insert variables during run time) except postval, that one is a (normal?) char. Maybe I can fix something with that...

Regards,

Atmoz
Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
my English isn't that good either
No worries, your English is absolutely fine! You live in a very beautiful city, in a wonderful country, also. I used to work for Philips in the USA and traveled to The Netherlands often. Sadly, I never learned much of your language because you Dutchmen make it so easy for us English-speakers.

I understand your enthusiasm and eagerness to get things working. You are doing very well on your own; keep at it. (There are also some good tutorials, by the way, on ladyada's adafruit.com site: http://www.adafruit.com/index.php?main_page=tutorials.)

But back to your program. Do you have a link to the documentation for that code you are trying to use? Oh, I see it in your earlier post, never mind.
« Last Edit: November 02, 2009, 12:18:10 pm by ahdavidson » Logged

.andy

Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thanks Andy!!

Nice website what you told me.
Can be very useful in the future *bookmarked* smiley-grin

Oh, you know the "neighborhood" here a little?! smiley-wink
It's indeed not to far from the Philips buildings (Eindhoven) where I live.
+/- 50 minutes driving...

In the meanwhile I hoped that the other Andy (from the library that I use) had a solution, but I think he's to busy at the moment. I'll ask him after a week or so.

I go further reading some nice tutorials about this stuff 8-)

Greets,

Atmoz
Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I visited Eindhoven many times, although that was many years ago by now. Maastricht is far more beautiful, of course!

I haven't forgotten your software problem, but have been busy the last few days. I'll try to get to it soon and see if I can help you.

.andy
Logged

.andy

Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


You know the south of the Netherlands very well smiley-grin

Thank you for your help Andy, I appreciate it!!
Take your time, I'm not in a hurry.
In a few hours I fly to "Gran Canaria" for a few day's vacation.
So all this Arduino stuff has to wait anyway :smiley 8-)

Happy weekend in advance!!

Regards,

Atmoz
Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I explored a lot of your wonderful country whenever I traveled there.

Enjoy your vacation!
Logged

.andy

Maastricht, The Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Techno!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you smiley

I'm back in business.
The mini vacation was absolutely great!!

I've made some pictures of this beautiful island:
http://home.kpn.nl/fjmlumig/Gran-canaria2009/

Anyway... back to normal life...
Tomorrow an old friend is coming by, he is a good programmer (not with Arduino but I should give it a try) and ask him to look at my "problem". So maybe this week the whole thing is going to work smiley-grin

Have a nice weekend everybody!!

Greetz,

Atmoz
Logged

Pages: 1 [2]   Go Up
Jump to: