Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've been searching for days to figure out why I'm having this problem and I have yet to find a solution. From everything I've read, this shouldn't be a problem at all, but for some reason it doesn't seem to be working correctly. My debug code is posted below, dest->outTemp and dest->dewpoint are both defined as floats. Initially I was passing those straight into a function, but through my testing, my debug code has evolved into what you see below:
Does anybody have any ideas why a float of 88.339996 would convert to -2147483648 as a double?
I should also mention that I have tried using (double), for example "DTemp = (double)CurTemp;" which produced the same results.
Any help would be much appreciated. I don't have much experience programming with c or c++, but I understand most of the logic. Most of my programming experience is with vb.net.
Thanks for any help,
Andy
Edit: I should note that I'm using CentOS 5.3 with an AMD Athlon 1500+ processor.
Ah, that makes sense. Thanks!
I was told (incorrectly apparently) to use %f for floats and %d for doubles. %f seems to give me the correct result for everything.
Next problem I'm having is these values don't seem to be getting passed correctly into a function I wrote.
Here's the function call:
I have a weather station and I'm using wview to create and upload a web page for the station. One of the problems with my station is that it has indoor himidity, but not outdoor. I'm making the assumption (which is one heck of an assumption and usually incorrect) that indoor and outdoor dewpoint are the same. So I calculate the indoor dewpoint and use that and the outside temperature to calculate the relative humidity outside, which gets used in other calculations too.
temp = 88.339996
dewpt = 55.805176
TempC = 31.299998
DewptC = 13.225098
Es = 45.574062
E = 15.182085
Result = 33.312994
I don't know what the prob is either! What distro are you using? C++ I presume, what version?
The reason that I asked what you were doing is that I have a Davis Vanage Pro II that I communicate with via a serial port. I have written c++/qt code to retrieve data from the console, put it on the screen and to store the data in a mysql database.
Wish I could afford a Vantage Pro2, I've been looking at it for quite awhile. For now, I settled on what I think is the cheapest station I could find that would give me wind direction & speed, temperature, and rainfall. It was kind of an impulse buy too, just popped up on woot.com one day for $60. It's a Thermor BIOS BW976.
Wview doesn't naively support support this station, but a patch is available from the ws9xxd project on sourceforge. I applied that and decided I wanted a little more information, so I started modifying it.
I'm not sure exactly what I'm using as far as compiling. I assume it's c and not c++, I think all it required was gcc. I don't really have anything good to debug this, I've just been using vi, so it's been a bit rough. I've been using putty to access the machine, nothing graphical. If you know of something I can use to debug it with putty, I'd love to give it a try. Other than that, I've just been doing the usual make and make install every time I make a code change, then looking at my output files to see what I've got.
So I'm wondering if this could be the problem (wouldn't think it would be though). The code that calls the function is in ../stations/BW9xx/bw9xx.c and the actual function is in ../common/wvutils.c. I'm wondering if something could be happening between those points, though I don't know why it would. I'm going to try moving the function to the bw9xx.c file and see if it makes a difference.
Thanks for looking into this, I do appreciate it.
I'm with you on the cost of the Vantage Pro II. I had been wanting one for quite a while but just couldn't justify the expense. Mine was a gift from my daughter; a combination birthday-father's day gift and pay back for some repair work to her house.
I'll take a look at the wview files you listed and see if I can spot anything.
Before ya get too far... I just found something that I had missed. There are 2 places where I call that function, one of them is inside the wvutils.c. I separated everything out and found that the first call, which is the one I was posting about, actually works correctly, but the second one was overwriting the file. So that one works, I gotta take a look at the other one and see what's going on.
See if this one makes sense to you. The code for the relative humidity function is below. If I set a variable defined as a USHORT equal to that function, I get the correct value. However, if I assign a float to it, I get a value of 1.0000000. Any ideas?
alright, ignore the previous post, I seem to have it working correctly now.
I don't know what that external stuff does, but I checked out that sysdefs.h file and added my functions to it and it seems to be fixed now.
Thanks again for your help.
The extern keyword is used to inform the compiler about variables declared outside of the current scope. Variables described by extern statements will not have any space allocated for them, as they should be properly defined elsewhere.
Extern statements are frequently used to allow data to span the scope of multiple files.
If you have more problems, send me a visitor message and I'll try to help.
Norm
Last edited by norobro; 05-25-2009 at 06:45 PM.
Reason: pasted definition twice
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.