PhidgetSBC2 and LCD interface program in ANSI C

C, C++, and Visual C++
n1849778
Phidgeteer!
Posts: 58
Joined: Thu Oct 21, 2010 5:22 pm
Contact:

PhidgetSBC2 and LCD interface program in ANSI C

Postby n1849778 » Thu Jul 12, 2012 7:34 am

Hi,

I just bought a PhidgetTextLCD Display 20x2 and want to write an ANSI C program in the PhidgetSCB2 to allow me to write texts in the PhidgetTextLCD. I have the PhidgetSBC2 connected to PhidgetTextLCD via USB. I found an example program for the LCD (TextLCD-simple.c) in your corporate website in "Programming Resource" (phidget21-c-examples_2.1.8.20120514.tar.gz).

When I complie the programing, I get the following error.

root@xter:/usr/uCLCD# gcc x.c -lphidget21
x.c: In function 'display_properties':
x.c:53: warning: passing argument 2 of 'CPhidget_getDeviceID' from incompatible pointer type
/usr/include/phidget21.h:122: note: expected 'enum CPhidget_DeviceID *' but argument is of type 'enum CPhidget_DeviceClass **'
x.c:64: warning: comparison between pointer and integer
root@xter:/usr/uCLCD#

I have not amended the program in any shape or form except for renaming it from "TextLCD-simple.c" to "x.c"

I have attached the "x.c" file in this post.

Is there anything wrong I am doing that I might have blind sighted? Thanks.
Attachments
x.c
(5.47 KiB) Downloaded 208 times

fraser
Engineering
Posts: 262
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: PhidgetSBC2 and LCD interface program in ANSI C

Postby fraser » Thu Jul 12, 2012 8:50 am

Yes there was a typo in our sample code.

You can fix the problem by replacing

Code: Select all

CPhidget_DeviceClass *name;

with

Code: Select all

CPhidget_DeviceID name;

in the display properties function.

Thanks for identifying the problem.

n1849778
Phidgeteer!
Posts: 58
Joined: Thu Oct 21, 2010 5:22 pm
Contact:

Re: PhidgetSBC2 and LCD interface program in ANSI C

Postby n1849778 » Thu Jul 12, 2012 9:17 am

Hi Fraser,

Thanks for your prompt reply. I have made the changes but I still get one more warning. The warning is as shown below.

root@xter:/usr/uCLCD# gcc x.c -lphidget21
x.c: In function 'display_properties':
x.c:53: warning: passing argument 2 of 'CPhidget_getDeviceID' from incompatible pointer type
/usr/include/phidget21.h:122: note: expected 'enum CPhidget_DeviceID *' but argument is of type 'enum CPhidget_DeviceClass *'
root@xter:/usr/uCLCD#

I have attached the modified "x.c" code.

Thanks.
Attachments
x.c
(5.47 KiB) Downloaded 206 times

fraser
Engineering
Posts: 262
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: PhidgetSBC2 and LCD interface program in ANSI C

Postby fraser » Thu Jul 12, 2012 10:51 am

make sure you use CPhidget_DeviceID not CPhidget_DeviceClass as well as remove the * from name

n1849778
Phidgeteer!
Posts: 58
Joined: Thu Oct 21, 2010 5:22 pm
Contact:

Re: PhidgetSBC2 and LCD interface program in ANSI C

Postby n1849778 » Thu Jul 12, 2012 12:55 pm

Oops! My bad as soon as I changed "CPhidget_DeviceClass" to "CPhidget_DeviceID", worked like a charm.

Thanks a bunch! :D


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 1 guest