PhidgetException 13 & 5: Phidget connected but not really.

Supporting Java SE version 7 and up
pjpac
Phidgetsian
Posts: 5
Joined: Thu Jun 21, 2018 5:20 am
Contact:

PhidgetException 13 & 5: Phidget connected but not really.

Postby pjpac » Sun Jul 01, 2018 10:31 am

Hi There,
Still, new with the system and running into troubles.
With NetBeans, I have been modifying a java program to control sequences of speed, acceleration, and time applied to a stepper motor (NEMA-17 Bipolar 32mm Stepper) connected to a Phidget Stepper Bipolar HC (ID: 1067_0B). It works apparently fine on my laptop, and I am now trying to transfer the program on a Raspberry Pi3 to control it remotely through a wifi connection handled with VNC (today from my laptop, later if time allows from a mobile phone). Regarding the Raspberry Pi3 connection to my laptop, VNC works OK, and I can open smoothly my modified java program jared with the Phidget 21 libraries used by my program.
Still, I have also installed the Phidget libraries (21 and 22) on the Raspberry following the instructions on https://www.phidgets.com/docs/OS_-_Linux. HelloWorld does detect when I plug and unplug the Phidget, which is reassuring but insufficient.
Indeed, when connected to the Pi3, my modified java program opens but does not trigger the stepper motor and with my limited experience, I am running out of idea to check and implement. Any suggestion and comment would be greatly appreciated.

I have tried the approaches listed below. They do show there are problems but with HelloWorld working I guess that it is pointless to keep reinstalling the libraries especially as the relevant ones are jarred with my program… even though I have certainly been doing something wrong. I have tried 4 tests copied the error messages I was getting in case it could help identifying what's wrong :
a- From my modified java program… running "jar -java program.jar"
b- From "/libphidget-2.1.8.20170607/Java"… running "gcc com_phidgets_MotorControlPhidget.c -o MotorControl-simple"
c- From "/phidget21-c-examples-2.1.8.20170607"… running "gcc com_phidgets_ServoPhidget.c -o com_phidgets_ServoPhidget"
d- From "/phidget21-c-examples-2.1.8.20170607"… running "gcc MotorControl-simple.c -o MotorControl-simple"


a- From my modified java program… running "jar -java program.jar"... leads to...
Jun 29, 2018 11:31:28 PM com. program_Pi ButtonConnectActionPerformed
SEVERE: null
PhidgetException 13 (Given timeout has been exceeded.)
at com.phidgets.Phidget.waitForAttachment(Native Method)
at com. program_Pi.ButtonConnectActionPerformed(program_Pi.java:1172)
at com. program_Pi.access$300(program_Pi.java:68)
at com. program_Pi$4.actionPerformed(program_Pi.java:218)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6535)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Jun 29, 2018 11:31:36 PM com. program_Pi ParameterChecks
SEVERE: null
PhidgetException 5 (Phidget not physically attached.)
at com.phidgets.StepperPhidget.getCurrentMax(Native Method)
at com. program_Pi.ParameterChecks(program_Pi.java:897)
at com. program_Pi.Button_startActionPerformed(program_Pi.java:846)
at com. program_Pi.access$1700(program_Pi.java:68)
at com. program_Pi$18.actionPerformed(program_Pi.java:690)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
... same as above...
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Parameter Checks ran smoothly: true
Jun 29, 2018 11:31:36 PM com.program_Pi AccelerationCheck
SEVERE: null
PhidgetException 5 (Phidget not physically attached.)
at com.phidgets.StepperPhidget.getAccelerationMax(Native Method)
at com.program_Pi.AccelerationCheck(program_Pi.java:926)
at com.program_Pi.Button_startActionPerformed(program_Pi.java:847)
at com.program_Pi.access$1700(program_Pi.java:68)
at com.program_Pi$18.actionPerformed(program_Pi.java:690)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
... same as above...
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Acceleration Check ran smoothly: true
Jun 29, 2018 11:31:36 PM com.program_Pi Button_startActionPerformed
SEVERE: null
PhidgetException 5 (Phidget not physically attached.)
at com.phidgets.StepperPhidget.setCurrentLimit(Native Method)
at com.program_Pi.Button_startActionPerformed(program_Pi.java:851)
at com.program_Pi.access$1700(program_Pi.java:68)
at com.program_Pi$18.actionPerformed(program_Pi.java:690)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
... same as above...
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Jun 29, 2018 11:31:46 PM com.program_Pi Button_exitActionPerformed
SEVERE: null
PhidgetException 5 (Phidget not physically attached.)
at com.phidgets.StepperPhidget.setEngaged(Native Method)
at com.program_Pi.Button_exitActionPerformed(program_Pi.java:1051)
at com.program_Pi.access$100(program_Pi.java:68)
at com.program_Pi$20.actionPerformed(program_Pi.java:712)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
... same as above...
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)



b- From "/libphidget-2.1.8.20170607/Java"... running "gcc com_phidgets_MotorControlPhidget.c -o MotorControl-simple"... leads to
"In file included from com_phidgets_MotorControlPhidget.c:21:0:
../stdafx.h:275:25: fatal error: pdictclient.h: No such file or directory
#include "pdictclient.h""

c- From "/libphidget-2.1.8.20170607/Java"... running "gcc com_phidgets_ServoPhidget.c -o com_phidgets_ServoPhidget"... leads to
"In file included from com_phidgets_ServoPhidget.c:21:0:
../stdafx.h:275:25: fatal error: pdictclient.h: No such file or directory
#include "pdictclient.h""

d- From "/phidget21-c-examples-2.1.8.20170607"... running "gcc MotorControl-simple.c -o MotorControl-simple"... leads to
"/tmp/ccaUOG8w.o: In function `AttachHandler':
MotorControl-simple.c:(.text+0x20): undefined reference to `CPhidget_getDeviceName'
MotorControl-simple.c:(.text+0x30): undefined reference to `CPhidget_getSerialNumber'
/tmp/ccaUOG8w.o: In function `DetachHandler':
MotorControl-simple.c:(.text+0x7c): undefined reference to `CPhidget_getDeviceName'
MotorControl-simple.c:(.text+0x8c): undefined reference to `CPhidget_getSerialNumber'
/tmp/ccaUOG8w.o: In function `display_properties':
MotorControl-simple.c:(.text+0x1d4): undefined reference to `CPhidget_getDeviceType'
MotorControl-simple.c:(.text+0x1e4): undefined reference to `CPhidget_getSerialNumber'
MotorControl-simple.c:(.text+0x1f4): undefined reference to `CPhidget_getDeviceVersion'
MotorControl-simple.c:(.text+0x204): undefined reference to `CPhidgetMotorControl_getInputCount'
MotorControl-simple.c:(.text+0x214): undefined reference to `CPhidgetMotorControl_getMotorCount'
/tmp/ccaUOG8w.o: In function `motorcontrol_simple':
MotorControl-simple.c:(.text+0x280): undefined reference to `CPhidgetMotorControl_create'
MotorControl-simple.c:(.text+0x294): undefined reference to `CPhidget_set_OnAttach_Handler'
MotorControl-simple.c:(.text+0x2a8): undefined reference to `CPhidget_set_OnDetach_Handler'
MotorControl-simple.c:(.text+0x2bc): undefined reference to `CPhidget_set_OnError_Handler'
MotorControl-simple.c:(.text+0x2d0): undefined reference to `CPhidgetMotorControl_set_OnInputChange_Handler'
MotorControl-simple.c:(.text+0x2e4): undefined reference to `CPhidgetMotorControl_set_OnVelocityChange_Handler'
MotorControl-simple.c:(.text+0x2f8): undefined reference to `CPhidgetMotorControl_set_OnCurrentChange_Handler'
MotorControl-simple.c:(.text+0x308): undefined reference to `CPhidget_open'
MotorControl-simple.c:(.text+0x320): undefined reference to `CPhidget_waitForAttachment'
MotorControl-simple.c:(.text+0x340): undefined reference to `CPhidget_getErrorDescription'
MotorControl-simple.c:(.text+0x38c): undefined reference to `CPhidgetMotorControl_setAcceleration'
MotorControl-simple.c:(.text+0x3a0): undefined reference to `CPhidgetMotorControl_setVelocity'
MotorControl-simple.c:(.text+0x3c0): undefined reference to `CPhidgetMotorControl_setAcceleration'
MotorControl-simple.c:(.text+0x3d4): undefined reference to `CPhidgetMotorControl_setVelocity'
MotorControl-simple.c:(.text+0x3f4): undefined reference to `CPhidgetMotorControl_setVelocity'
MotorControl-simple.c:(.text+0x408): undefined reference to `CPhidgetMotorControl_setAcceleration'
MotorControl-simple.c:(.text+0x428): undefined reference to `CPhidget_close'
MotorControl-simple.c:(.text+0x434): undefined reference to `CPhidget_delete'
collect2: error: ld returned 1 exit status"

User avatar
mparadis
Site Admin
Posts: 585
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: PhidgetException 13 & 5: Phidget connected but not really.

Postby mparadis » Tue Jul 03, 2018 10:12 am

If the program works on your desktop, then it's probably a hardware issue. Raspberry Pis have notoriously low current on their USB ports, and if the Phidget isn't getting enough power it may not appear to be connected. Try using a powered USB hub connected to the Pi.

pjpac
Phidgetsian
Posts: 5
Joined: Thu Jun 21, 2018 5:20 am
Contact:

Re: PhidgetException 13 & 5: Phidget connected but not really.

Postby pjpac » Fri Jul 20, 2018 5:02 am

Hi.
Thanks for the feedback. Based on comment that the Raspberry Pis have low current on their USB ports, I have tried to increase it by adding max_usb_current=1 to the boot/config.txt file... no luck though.
I have ordered an Anker Hub Ultra 4 Ports USB 3.0 with a 10W Charger which was eventually delivered but I have reached the same negative outcome everything works fine on my laptop but once connected to the Raspberry, HelloTheWorld sees the phidget but the java program does not go beyond stepperPhidget.waitForAttachment. I have tried 15s and 1 min, I have also tried a shorter USB to miniUSB cable to connect the Raspberry and the the Phidget but it was one more set of disappointing results.
I was concerned that I was running the program from NetBeans on my laptop but directly from a .java file on the Raspberry so that I have installed NetBeans on the Raspberry but only to achieve the same lack of positive result : the step motor stands still when connected to a Raspberry.

I'd be happy to follow up on any suggestion as I feel rather stuck with a phidget-raspberry system that has not delivered much yet. There is got to be something that I clearly do wrong but I have no clue as to how to identify and fix it.

Best wishes

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

Re: PhidgetException 13 & 5: Phidget connected but not really.

Postby Patrick » Fri Jul 20, 2018 3:20 pm

You're probably running into permissions issues on the Raspberry Pi. Did you install the udev rule? Have you tried running the program as root?

Also, if you enable logging in your app, it will likely gives some clues as to what's going wrong.

-Patrick

pjpac
Phidgetsian
Posts: 5
Joined: Thu Jun 21, 2018 5:20 am
Contact:

Re: PhidgetException 13 & 5: Phidget connected but not really.

Postby pjpac » Mon Aug 06, 2018 1:35 pm

Hi Patrick
Many thanks for the feedback and suggestions.
To take a fresh start, I have formatted the SD card and re-install everything.
I had actually not installed the udev rule, which I have now addressed with "sudo cp /usr/local/lib/libphidget-2.1.8.20170607/udev/99-phidgets.rules /etc/udev/rules.d".
From "/user/local/phidget21-examples", I ran "gcc HelloWorld.c -o HelloWorld -lphidget21" and "sudo ./HelloWorld" leading to print “Hello Device Phidget Bipolar Stepper Controller 1-motor, Serial Number: 423793”.
Next, I tried "sudo gcc Stepper-simple.c -o Stepper-simple -lphidget21" followed by "sudo ./Stepper-simple" and the step motor did respond in both directions.
Connections and mounting are then possible. The 2 tests suggest that the installation is relatively OK. From Netbeans, the program opened OK but the phidget still did not connect. Similarly, from the command line "java -jar /home/pi/Desktop/SpinKo-WinPi3/dist/SpinKo-WinPi3.jar", the program opened OK but the phidget did not connect.

Your last suggestion turned out to be the solution... I copied the debugged program from the netbeans folder "sudo cp /home/pi/Desktop/Prog/dist/* -r /root" and started it with the command line
"sudo java -jar /root/Prog.jar"... and it worked !!! :) The stepper connected, was mounted and could spin while following the command of Prog.jar.

So the program is OK, it seems that I "just" need to have it in the root. From a broader learning point of view, I am not sure why the program needs to be in the root whereas Stepper-simple can be started from anywhere. It is a bit frustrating. I guess that there are some settings I don’t know about yet and which have to be adjusted. I can move the project forwards from the root but if anyone has an idea about the root requirement, I'd be happy to learn.

Cheers


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest