Page 1 of 1

Errors when compiling VoltageRatioInputExample.c ?

Posted: Wed Nov 21, 2018 12:47 pm
by maperrone
Hi there! I've been trying to get the Phidgetbridge to work on Raspbian but something's not quite right. Anyone know what's going on? My notes are below.

When I compile with

cc -ggdb3 -Wall -o VoltageRatioInputExample VoltageRatioInput_Example.c ../Common/PhidgetHelperFunctions.c -I../Common -lphidget22


(The command produced from make) I get


VoltageRatioInput_Example.c: In function ‘onAttachHandler’:
VoltageRatioInput_Example.c:38:40: warning: passing argument 2 of ‘Phidget_getChannelClassName’ from incompatible pointer type [-Wincompatible-pointer-types]
prc = Phidget_getChannelClassName(ph, &channelClassName);
^
In file included from VoltageRatioInput_Example.c:4:0:
/usr/local/include/phidget22.h:723:20: note: expected ‘const char **’ but argument is of type ‘char **’
PhidgetReturnCode Phidget_getChannelClassName (PhidgetHandle phid, const char **channelClassName);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
VoltageRatioInput_Example.c: In function ‘onDetachHandler’:
VoltageRatioInput_Example.c:117:40: warning: passing argument 2 of ‘Phidget_getChannelClassName’ from incompatible pointer type [-Wincompatible-pointer-types]
prc = Phidget_getChannelClassName(ph, &channelClassName);
^
In file included from VoltageRatioInput_Example.c:4:0:
/usr/local/include/phidget22.h:723:20: note: expected ‘const char **’ but argument is of type ‘char **’
PhidgetReturnCode Phidget_getChannelClassName (PhidgetHandle phid, const char **channelClassName);

but it still generates an executable. When I run that with a phidget bridge attached to a USB on the Raspberry Pi, and a load cell attached to channel 2 on the phidget bridge, I get the following results for various inputs:

533575 (serial#)
n (not VINT hub)
2
n (no network)
timed out

533575 (serial#)
y (VINT hub)
-1
n (not hub port)
2
n (not network)
timed out

533575 (serial#)
n (not VINT hub)
2
y (yes network)
y (enable network discovery)
timed out
(I would expect this to fail, since I haven't set up a network server yet)

533575 (serial#)
y (yes VINT hub)
-1
y (yes hub port)
n (not network)
timed out

When I plug the phidget bridge into the Raspberry Py, dmesg | tail gives the usual stuff, so it recognizes the thing clearly. When I plug it into a windows machine I can read the data coming off the load cell easily with the GUI, so I suspect the issue is with that problem during code compilation.

I also had some errors come up when I tried to install the libphidgetjava stuff, mostly to do with redundant definitions of things. Can only one be installed at a time? C or java but not both? Also the above compilation errors above don't seem to mention redundant definitions, though that could explain a change from const char ** to char **, and the executable mostly works, but it just doesn't connect. Plus it ought to work just fine with Char ** as long as that's not getting changed by the connection process? Though maybe that's not a fair assumption.

Re: Errors when compiling VoltageRatioInputExample.c ?

Posted: Wed Nov 21, 2018 5:33 pm
by jdecoux
You are seeing warnings about the compiler expecting channelClassName to be declared as const char*, but in the examples it has been declared as char*. This issue has been fixed for the next release.

However, these are only warnings, and the code will work properly despite them, so your real problem is elsewhere.

I recommend running the Manager / HelloWorld C example to verify that your Raspberry Pi recognizes your Bridge Input. You can find that in our list of C Examples. That program will list all Phidgets on your machine.

For the time being, also make sure no other Phidgets-related programs are running when you run the example to be certain the device is not being used by another program. Multiple Phidgets programs can run at the same time, but devices cannot be shared between them (unless they are used over the network).

And to confirm, is the device you are using the 1046 BridgeInput?

Re: Errors when compiling VoltageRatioInputExample.c ?

Posted: Mon Nov 26, 2018 9:35 am
by maperrone
Hi jdecoux,

Thanks for the quick reply and hope you had a happy Thanksgiving!

The hello world example does not list the PhidgetBridge, no other phidget devices are attached, and yes it's 1046_0B. It seems to work just fine with the Windows GUI.

dmesg | tail shows in the log that the Raspberry Pi recognizes the device as a phidgetbridge though, which suggests it's not the usb driver?

Re: Errors when compiling VoltageRatioInputExample.c ?

Posted: Mon Nov 26, 2018 10:10 am
by maperrone
Looks like my issue was addressed in the thread started by ChristianE

viewtopic.php?f=2&t=8393&p=27746&hilit= ... d.c#p27746