Author Topic: Please Help with vantagepro.dll C++  (Read 4804 times)

0 Members and 1 Guest are viewing this topic.

Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Please Help with vantagepro.dll C++
« on: April 28, 2009, 04:17:53 PM »
Hello to the Group!

This is my first post so I do hope I am posting in the correct place! If not them I do apologies in advance. :-)

I have been taking the time to lean a little C++ (using Dev-C++ compiler) so I thought I would have a go at linking up to my VantagePro 2 via the command prompt on my Vista system. I have managed to get some values returned from the Unit (i.e. Temperature, Barometer) but these are in the default values in Imperial (English) and I would like them to be returned in Metric. To be honest I am a little lost with changing the “struct WeatherUnits” from my main source file.  I am using the latest DLL pack from the Davis website.

Would someone please be kind enough to explain how I do this and at what place in my main file do I put “GetUnits_V” and “SetUnits_V” ? Do I need both?

I would be most grateful for any help! Hope this is enough information?

Most Kindest Regards,

Andrew Hall.
Leipzig, Deutschland.

http://www.sky-signals.com
« Last Edit: January 06, 2014, 05:09:09 PM by ajwhall »
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: Please Help with vantagepro.dll C++
« Reply #1 on: April 28, 2009, 05:08:14 PM »
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline jruys

  • Yo
  • Senior Contributor
  • ****
  • Posts: 221
    • Highlands Ranch Weather
Re: Please Help with vantagepro.dll C++
« Reply #2 on: April 28, 2009, 07:20:34 PM »
From doing a VERY quick overview of the documentation, it looks like you need to use the SetUnits_V function to get the values in metric.  It looks like you have to use the constants defined in the documentation to fill your struct.  So, create your WeatherUnits struct then fill the values like this:
  Temperature = CELSIUS
  Barometer = MB
  Rain = MM
  Wind = KPH or METERS_PER_SECOND
  Elevation = M

I will try to look at some of the examples and see if I can find anything else out.

Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Re: Please Help with vantagepro.dll C++
« Reply #3 on: April 29, 2009, 12:36:36 AM »
Hello again,

Thanks for the help. I will give this a try and come back to let you know how I get on! I guess I have being doing things a little wrong with the struct.

Most Kindest Regards,

Andrew.
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Re: Please Help with vantagepro.dll C++
« Reply #4 on: April 29, 2009, 03:21:18 AM »
Still no Joy!  ](*,)

I understand struct a little but would you create you own or does it need to be linked into the "struct WeatherUnits" in the header file?

so far I tried(this links to the header file):

            WeatherUnits Units;
            Units.TempUnit = CELSIUS;
            Units.BaromUnit = HECTO_PASCAL;
            Units.RainUnit = MM;
            Units.WindUnit = KPH;
            Units.elevUnit = METERS;

with (in MAIN):

WeatherUnits SetUnits_V(WeatherUnits Units);

but it doesn't work!

If I have got this all wrong then please be patient with me as this is a big learning curve for me!! If there is someone who understands this a lot better than me I would be most grateful for an example of how to work this!

jruys, I have visited your site on a number of occasions and am impressed by the work you have done with the vantagepro2. If you could assist me with this I would be forever grateful!!

Most Kindest Regards,

Andrew.
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

Offline wuhu_software

  • Forecaster
  • *****
  • Posts: 689
    • WUHU Software Yahoo Group
Re: Please Help with vantagepro.dll C++
« Reply #5 on: April 29, 2009, 05:57:33 AM »
Still no Joy!  ](*,)

I understand struct a little but would you create you own or does it need to be linked into the "struct WeatherUnits" in the header file?

so far I tried(this links to the header file):

            WeatherUnits Units;
            Units.TempUnit = CELSIUS;
            Units.BaromUnit = HECTO_PASCAL;
            Units.RainUnit = MM;
            Units.WindUnit = KPH;
            Units.elevUnit = METERS;

with (in MAIN):

WeatherUnits SetUnits_V(WeatherUnits Units);

but it doesn't work!

If I have got this all wrong then please be patient with me as this is a big learning curve for me!! If there is someone who understands this a lot better than me I would be most grateful for an example of how to work this!

jruys, I have visited your site on a number of occasions and am impressed by the work you have done with the vantagepro2. If you could assist me with this I would be forever grateful!!

Most Kindest Regards,

Andrew.

You did not show the actual call in main()....

            WeatherUnits Units;
            Units.TempUnit = CELSIUS;
            Units.BaromUnit = HECTO_PASCAL;
            Units.RainUnit = MM;
            Units.WindUnit = KPH;
            Units.elevUnit = METERS;

            if (SetUnits_V(&Units)==0) {
               // Success
            }


Also, this should be called after calls to OpenCommPort_V() and InitStation_V().



Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Re: Please Help with vantagepro.dll C++
« Reply #6 on: April 29, 2009, 07:05:08 AM »
Dear wuhu_software,

That done the trick!

if (SetUnits_V(&Units)==0) {
               // Success
            }

If I am honest it would have taken me weeks to work that out even though I have read a bit about calling in the book I have!  #-o

The values came back with more than one decimal place so I did a bit of google-ing and sorted that with "setprecision" .

They only final question I have is that when I run the EXE from cmd and then run it again say a few minutes later nothing happens other than the cursor flashes. To cure this I have to close and reopen the cmd box and run the EXE again. Could this be something to do with loading and unloading (constructor/deconstructor)?

Sorry!

Most kindest Regards,

Andrew.
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

Offline jruys

  • Yo
  • Senior Contributor
  • ****
  • Posts: 221
    • Highlands Ranch Weather
Re: Please Help with vantagepro.dll C++
« Reply #7 on: April 29, 2009, 11:23:05 AM »
My guess is that the COM port is not being closed when you are finished executing the program, and when you try to execute the program again and it attempts to re-open the COM port it fails.  You may want to put a check in to see if the COM port is open before you try to open it and return a message if it is.  At least that may point you in one direction or another.  If you do not have a debug mode with the tool you are using to write your code, the thing that I do is start spitting out messages to the console everywhere you may get an error to pin point where your code is failing.

Offline wuhu_software

  • Forecaster
  • *****
  • Posts: 689
    • WUHU Software Yahoo Group
Re: Please Help with vantagepro.dll C++
« Reply #8 on: April 29, 2009, 04:22:43 PM »

I am not sure what your program does, but before it exits, you should call:

       CloseCommPort_V();

Are you saying that it locks up between polls to the station?

It would be much easier to look at your source.

If you want, send me a copy wuhu_software at yahoo.com.


Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Re: Please Help with vantagepro.dll C++
« Reply #9 on: April 30, 2009, 01:57:48 AM »
Hello again,

Okay, I beleive I have found what was causing the problem! In my excitement of getting the Metric read out working with "wuhu_software's" help I must have inadvertently deleted the "return 0" at the end of main!  What I did to check if this was now all okay was to use sleep.exe to run my exe every 5 minutes and thankfully all ran fine (so far!).

Thank you for your offer "wuhu_software" but I don't think it is necessary to take any of your time up with this!.

What I am trying to do is have my program just excess the station get some readings then put those readings into an RRD database.  The graphs that can be made with the RRDtool are quite amazing!

Hopefully I shoud be fine now but I would like to say many thanks to the members who have help me with this small project!

Most Kindest Regards,

Andrew.
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

Offline wuhu_software

  • Forecaster
  • *****
  • Posts: 689
    • WUHU Software Yahoo Group
Re: Please Help with vantagepro.dll C++
« Reply #10 on: April 30, 2009, 05:55:00 AM »

I am not familiar with the RRD tools / database.

Can you post an example chart after you collect some data?

I might be interested in add the feature to my application.

Thanks.


Offline andrewjwhall

  • Member
  • *
  • Posts: 20
  • Amateur Meteorologist, Time Lapses & Photography.
    • YouTube Channel - Andrew J.W. Hall
Re: Please Help with vantagepro.dll C++
« Reply #11 on: April 30, 2009, 07:42:25 AM »
Hello wuhu_software,

The RRD tool is a free application for both Windows and Linux and can be found at the following website:

http://oss.oetiker.ch/rrdtool/


I use a pre-compiled version which is available through the RRDtool website which is for Windows using Active Pearl. 

Look here

http://oss.oetiker.ch/rrdtool/gallery/index.en.html

and you will find various examples of graphs styles that people have produced.  The site is fully documented for helping with getting started on how to use the RRDtool.  This is a fantastic piece of kit in my view. 


I hope this helps you with finding out more but I am still learning myself about the RRDtool although I have been using it to produce graphs showing my network connection on my PC.  All in all the applications for using RRD tool are almost endless!

Most Kindest Regards,

Andrew. 
Twitter: @andrewjwhall
YouTube: @andrewjwhall

Davis Vantage Pro 2 | Davis Vantage Vue | WeatherLink Live | WeatherLinkIP | WiFiLogger

 

anything