Some confusion about VC++ and LinearTouch

C, C++, and Visual C++
tlwilli4

Some confusion about VC++ and LinearTouch

Postby tlwilli4 » Tue Jun 23, 2009 9:04 am

I'm new to this whole "coding" thing. I've dabbled in C, but never really got anywhere with it because the textbooks I was reading were just irritatingly boring.
To the point, though, I recently became a co-proprietor of a LinearTouch sensor at work, and I've been trying to work this for some time, but I find that VC++ hates me.
I'm trying to write a simple code that will just send me the serial number back, just to prove that everything's in working order. So far, I've come up with:


#include "phidget21.h"
#include "stdio.h"

int main()
{
int serial;
int CPhidgetManager_create (CPhidgetManagerHandle man);
int CPhidgetInterfaceKit_create (CPhidgetInterfaceKitHandle LT);
int CPhidget_open (CPhidgetHandle LT);
int CPhidget_getSerialNumber (CPhidgetHandle LT, int serial);
printf("device SN: %d", serial);
}


And the output, after I build the .exe and run it, comes out saying "Device SN: 2019276528." No matter what. I don't even have it plugged in anymore and it's saying that.
So, obviously, my question is, what am I doing wrong? Any help would be appreciated.

User avatar
Patrick
Lead Developer
Posts: 3052
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Some confusion about VC++ and LinearTouch

Postby Patrick » Tue Jun 23, 2009 9:31 am

You need to call waitForAttachment after calling open.

-Patrick

tlwilli4

Re: Some confusion about VC++ and LinearTouch

Postby tlwilli4 » Tue Jun 23, 2009 10:16 am

...that's...well, that issue was pretty anticlimactic...
Well, the next issue I face is the output in cmd is still the same when I build it. I have no idea how to even google this, but if you could look over the code and lemme know what you think, that'd be great:

#include "phidget21.h"
#include "stdio.h"

int main()
{
int *serial;
int milliseconds = 0;
int CPhidgetManager_create (CPhidgetManagerHandle man);
int CPhidgetInterfaceKit_create (CPhidgetInterfaceKitHandle LT);
int CPhidget_open (CPhidgetHandle LT);
int CPhidget_waitForAttachment (CPhidgetHandle LT, int *milliseconds);
int CPhidget_getSerialNumber (CPhidgetHandle LT, int serial);
printf("device SN: %d", serial);

}


This yields the warning (not error) in build order: "warning C4700: uninitialized local variable 'serial' used."
The headbutt idea still sounds enticing.

User avatar
Patrick
Lead Developer
Posts: 3052
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Some confusion about VC++ and LinearTouch

Postby Patrick » Tue Jun 23, 2009 10:25 am

Code: Select all

#include   "phidget21.h"
#include   "stdio.h"

int main()
{
   int serial;
   int milliseconds = 0;
   CPhidgetInterfaceKitHandle LT;

   CPhidgetInterfaceKit_create(&LT);
   CPhidget_open((CPhidgetHandle)LT);
   CPhidget_waitForAttachment(LT, milliseconds);
   CPhidget_getSerialNumber(LT, &serial);

   printf("device SN: %d", serial);
}


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 2 guests