Products for USB Sensing and Control
It is currently Wed May 22, 2013 3:17 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Oct 04, 2010 2:14 pm 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
May be a newbie question, sorry about that, but i have to solve my problem. I want to read /write key - value in the Dictionary and tried the bellow "simple example"
Code:
/*
 * Copyright 2007 Phidgets Inc.  All rights reserved.
 */
package htp_test;

import com.phidgets.*;
import com.phidgets.event.*;

public class Main
{
   public static final void main(String args[]) throws Exception {
      Dictionary dict;
      DictionaryKeyListener listen;

      System.out.println(Phidget.getLibraryVersion());


      dict = new Dictionary();
      listen = new DictionaryKeyListener(dict, ".*");

      listen.addKeyChangeListener(new KeyChangeListener()
      {
         public void keyChanged(KeyChangeEvent e)
         {
            System.out.println(e);
         }
      });

      listen.addKeyRemovalListener(new KeyRemovalListener()
      {
         public void keyRemoved(KeyRemovalEvent e)
         {
            System.out.println(e);
         }
      });

      dict.open("phidgetsbc",5001);
      listen.start();

      System.out.println("Connected: " + dict.isAttached());
      System.out.println("Server: " + dict.getServerAddress() + ":" + dict.getServerPort());

      dict.add("test1", "ok");
      dict.add("test2", "ok", true);
      dict.add("test3", "ok", false);
      dict.add("test4", "ok", true);
      dict.remove("test4");

      System.out.println("Press any key to exit...");
      System.in.read();

      dict.close();
      dict = null;
      System.out.println(" ok");
   }
}


and after the command :

# jamvm -jar /mnt/userspace/userapps/HTP/test/HTP_test.jar

encounter the following error

Code:
Phidget21 - Version 2.1.7 - Built Jun 28 2010 17:04:39
Connected: false
Server: localhost:5001
java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:367)
   at jamvm.java.lang.JarLauncher.main(JarLauncher.java:50)
Caused by: PhidgetException 16 (A connection to the server does not exist.)
   at com.phidgets.Dictionary.nativeAddKey(Native Method)
   at com.phidgets.Dictionary.add(Dictionary.java:142)
   at htp_test.Main.main(Main.java:43)
   at java.lang.reflect.Method.invokeNative(Native Method)
   ...2 more
#


I tried different ways configuring

dict.open("phidgetsbc",5001);

like : -

dict.open("phidgetsbc.local",5001);
dict.open("localhost",5001);
dict.open("192.168.0.90",5001);

etc ....

How can i pass throw this error :

Code:
PhidgetException 16 (A connection to the server does not exist.)


Thanks in advance.


Top
 Profile Send private message  
 
PostPosted: Mon Oct 04, 2010 2:36 pm 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
on a PhidgetSBC ... (forget this "detail")


Top
 Profile Send private message  
 
PostPosted: Mon Oct 04, 2010 2:38 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
You have to wait for isAttached to go true after calling open (poll it). Or you can wait for the dictionary attach event - at any rate, you can't start the listener (listen.start()) until the dictionary is attach, and it won't be when open returns.

-Patrick


Top
 Profile Send private message  
 
PostPosted: Wed Oct 06, 2010 3:23 am 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
Thanks Patrick for your answer. But as things do not progress, i simplified (to the extreme) the code and i'd like to submit it again.

So i am now waiting for isAttached to go true but it does not.

here's my code :

Code:

import com.phidgets.*;
import com.phidgets.event.*;

public class Main {
   public static void main(String args[]) throws Exception {

            Dictionary dict;
            dict = new Dictionary();

            dict.open("phidgetsbc",5001);

            System.out.println("Connected : " + dict.isAttached());

            while (!dict.isAttached()) {
                System.out.print(".");
                Thread.sleep(1000);
            }

            System.out.println("Connected : " + dict.isAttached());

            System.in.read();

            dict.close();
            dict = null;
   }
}



I execute this VERY simple code on a SBC. And get NO connection to the dictionary.

What do i miss ?
What's wrong ?
What concept i don't understand ?
or is there something to check somewhere in the system ? ...

:D


Last edited by serial on Wed Oct 06, 2010 12:35 pm, edited 1 time in total.

Top
 Profile Send private message  
 
PostPosted: Wed Oct 06, 2010 10:23 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
Ok, I see the problem.

You are using the 'open(java.lang.String ipAddress, int port)' method, but you're passing a ServerID as the first parameter instead of an IP address/hostname.

You can do either of these:
Code:
dict.open("phidgetsbc.local", 5001);
dict.open("phidgetsbc");

'phidgetsbc.local' is a hostname - maintained on your local network by Bonjour. 'phidgetsbc' is a ServerID.

-Patrick


Top
 Profile Send private message  
 
PostPosted: Wed Oct 06, 2010 12:26 pm 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
Sorry but i already tried these for the same result.
I noticed that "phidgetsbc" is a servedID where "phidgetsbc.local" is an IP. I respected the parameters asked by the different methods : open() and tried (one by one) :
Code:
dict.open("192.168.0.90", 5001); // Its IP over the network
dict.open("127.0.0.1", 5001);
dict.open("localhost", 5001);
dict.open("phidgetsbc.local", 5001);
dict.open("phidgetsbc");

Still having in command line

Code:
# jamvm -jar /mnt/userspace/userapps/HTP/HTP_test.jar
Connected : false
.....
(ie: a dot is a second in the loop while)

(before this and to be sure, i made a Firmware Upgrade, erased the userspace partition and configuration data), restarted ... So the system is clear ).

The application run natively on a standalone SBC

Code:
Library Version
Phidget21 - Version 2.1.7 - Built Jun 28 2010 17:04:39

List of attached Phidgets
#   Device Name                              Serial Number   Version
0   Phidget InterfaceKit 8/8/8                       46349       826
1   Phidget Temperature Sensor 4-input              166964       100
2   Phidget InterfaceKit 8/8/8                      164027       201
3   Phidget TextLCD                                 164027       201


Sorry to make this not easy ... :/


Top
 Profile Send private message  
 
PostPosted: Wed Oct 06, 2010 12:48 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
No worries. If you run the java app on your PC, can it connect successfully to the SBC? I assume that the phidget webservice is actually running on the SBC?

-Patrick


Top
 Profile Send private message  
 
PostPosted: Wed Oct 06, 2010 1:33 pm 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
Yes, when i run the app on my PC with
Code:
dict.open("phidgetsbc.local",5001);
i got
Code:
C:\HTP\PROJECT\HTP_test\dist>java -jar HTP_test.jar
Server : phidgetsbc.local:5001
Connected : false
.Connected : true
:D

just for info, this
Code:
dict.open("192.168.0.90",5001);
doesn't work on my PC.

Code:
C:\HTP\PROJECT\HTP_test\dist>java -jar HTP_test.jar
Server : 192.168.0.90:5001
Connected : false
...........


and, yes, the webservice is running on the SBC.
There's 4 processes (/usr/bin/phidgetwebservice21 -p 5001 -n phidgetsbc)


Top
 Profile Send private message  
 
PostPosted: Fri Oct 08, 2010 9:27 am 
Offline
Phidgetsian

Joined: Wed Aug 11, 2010 8:31 am
Posts: 8
My mistake, when i run the app on my PC with
Code:
dict.open("phidgetsbc.local",5001);
or
dict.open("192.168.0.90",5001); // its IP over the network
it works !

But still not when i run the app on the SBC.
I encouter the problem only for the dictionnary. I can open my phidgets

Any idea ?


Top
 Profile Send private message  
 
PostPosted: Tue Oct 12, 2010 9:44 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
I will try this here and get back to you.

-Patrick


Top
 Profile Send private message  
 
PostPosted: Tue Dec 07, 2010 3:48 pm 
Offline
Phidgetsian

Joined: Tue Dec 07, 2010 12:43 pm
Posts: 10
Hello, i'm french, excuse me for my poor english but i have exactly the same problem.
In June, I wrote a simple java program that worked correctly on the Phidget SBC with a dictionary. A month ago, I bought the sound card to install on the Phidget SBC. Also, I have to update the driver and since this update, the program does not work. :cry:


Top
 Profile Send private message  
 
PostPosted: Fri Dec 10, 2010 1:30 pm 
Offline
Phidgetsian

Joined: Tue Dec 07, 2010 12:43 pm
Posts: 10
patrick wrote:
I will try this here and get back to you.

-Patrick

Hello, i'm french, excuse me for my poor english but i have exactly the same problem.
In June, I wrote a simple java program that worked correctly on the Phidget SBC with a dictionary. A month ago, I bought the sound card to install on the Phidget SBC. Also, I have to update the driver and since this update, the program does not work. :cry:


Top
 Profile Send private message  
 
PostPosted: Sun Jan 22, 2012 3:16 pm 
Offline
Fresh meat

Joined: Sun Jan 22, 2012 1:59 pm
Posts: 4
Hello, I know that the thread is quite old.. but was there a solution? I am encountering the same problem. I can connect through my computer (to my local dictionary and the SBC dictionary). But none can be connected when I load the program into the SBC (as jar)...

Other functions such as opening LEDController and etc works.

I have tried different combinations which uses the serverID or (serverid.local, port) and etc..


Top
 Profile Send private message  
 
PostPosted: Wed Jan 25, 2012 4:47 pm 
Offline
Fresh meat

Joined: Sun Jan 22, 2012 1:59 pm
Posts: 4
I have kept on trying since then.. but it still cannot connect to the dictionary!

I have updated the firmware of the SBC to the latest 23rd Jan and also reinstalled my webservice on my computer..

When i make the jar program on the sbc to try to connect to my LAPTOP's Dictionary and i enable the verbose output, this is the log:


[801] - INFO: Accepted new connection
[802] - INFO: Started new pds_session_serve thread
[803] - WARN: Error in pd_getline: WSA error 0
[804] - WARN: Authentication failed or bad version - closing connection
[805] - INFO: done - session closed
[806] - INFO: Exiting pds_session_serve thread
[807] - INFO: Accepted new connection
[808] - INFO: Started new pds_session_serve thread
[809] - WARN: Error in pd_getline: WSA error 0
[810] - WARN: Authentication failed or bad version - closing connection
[811] - INFO: done - session closed
[812] - INFO: Exiting pds_session_serve thread
[813] - INFO: Accepted new connection
[814] - INFO: Started new pds_session_serve thread
[815] - WARN: Error in pd_getline: WSA error 0
[816] - WARN: Authentication failed or bad version - closing connection
[817] - INFO: done - session closed
[818] - INFO: Exiting pds_session_serve thread

Anyone knows what does "pd_getline: WSA error 0" means?


Top
 Profile Send private message  
 
PostPosted: Wed Jan 25, 2012 5:11 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
Do you have a password set? It's saying auth failed or bad version - I'm assuming you have the newest release on both the sbc and your computer.

If you are using a password, see if it will work with no password.

WSA Error 0 is probably not a real error message - 0 usually indicated success.

-Patrick


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group