Phidg​​et RFID 未连接(ANDROID 和 PHIDGET)

发布于 2024-12-25 09:57:56 字数 5099 浏览 4 评论 0原文

我目前在 Eclipse 中遇到问题,即使我的 Phidg​​et RFID 连接了设备(模拟器)没有连接,我已经在与 Android 无关的普通 Java 类中运行它并且它可以工作。我已经重启过很多次了。

下面是 log cat 报告:

01-06 13:10:18.984: W/System.err(623): PhidgetException 5 (Phidget not physically attached.)
01-06 13:10:19.004: W/System.err(623):  at com.phidgets.RFIDPhidget.setAntennaOn(Native Method)
01-06 13:10:19.016: W/System.err(623):  at myFood.myFood.AddFood.onCreate(AddFood.java:35)
01-06 13:10:19.034: W/System.err(623):  at android.app.Activity.performCreate(Activity.java:4465)
01-06 13:10:19.034: W/System.err(623):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-06 13:10:19.034: W/System.err(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-06 13:10:19.044: W/System.err(623):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-06 13:10:19.054: W/System.err(623):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-06 13:10:19.054: W/System.err(623):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-06 13:10:19.054: W/System.err(623):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 13:10:19.074: W/System.err(623):  at android.os.Looper.loop(Looper.java:137)
01-06 13:10:19.074: W/System.err(623):  at android.app.ActivityThread.main(ActivityThread.java:4424)
01-06 13:10:19.085: W/System.err(623):  at java.lang.reflect.Method.invokeNative(Native Method)
01-06 13:10:19.085: W/System.err(623):  at java.lang.reflect.Method.invoke(Method.java:511)
01-06 13:10:19.085: W/System.err(623):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-06 13:10:19.094: W/System.err(623):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-06 13:10:19.103: W/System.err(623):  at dalvik.system.NativeStart.main(Native Method)

下面是我的代码:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.phidgets.InterfaceKitPhidget;
import com.phidgets.Phidget;
import com.phidgets.PhidgetException;
import com.phidgets.RFIDPhidget;
import com.phidgets.event.TagGainEvent;
import com.phidgets.event.TagGainListener;


public class AddFood  extends Activity {
        /** Called when the activity is first created. */
    RFIDPhidget rfid;

    static String x ="NULL";
    int i = 0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.addfood);
        final TextView mytext=(TextView)findViewById(R.id.widget96);


try
{

        com.phidgets.usb.Manager.Initialize(this);
        rfid = new RFIDPhidget();
        rfid.setAntennaOn(true);
        rfid.setLEDOn(true);

        //Begin the TagGained event, allowing for users to read the RFID values



        rfid.addTagGainListener(new TagGainListener()
        {

            public void tagGained(TagGainEvent oe)
            {


                Object y = (oe.getValue());
                x= y.toString();
            }
        });
        rfid.open(34235);


        long StartTime,RunTime;
        StartTime=System.currentTimeMillis();
        do{

            RunTime=System.currentTimeMillis();
            if (x.equals("NULL")) {

                //Continue waiting for input
                }
            else

            StartTime = 10000; //Overload the result so the loop ends
        }
        while (RunTime-StartTime<5000);

        rfid.close();
        com.phidgets.usb.
        Manager.Uninitialize();

}
catch(PhidgetException e)
{

    e.printStackTrace();
}

        Button mybutton = (Button) findViewById(R.id.Button1);
        mybutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {






        }


        });

}

}

和我的 Android 清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="myFood.myFood"
      android:versionCode="1"
      android:versionName="1.0">
      <uses-feature android:name="android.hardware.usb.host" />
      <uses-sdk android:minSdkVersion="12" />
        <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".myFood"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
   <activity android:name=".AddFood" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
    </application>


</manifest> 

如果任何人有 PHIDGETS 或类似内容的经验,我们将不胜感激。

I am currently having problems in Eclipse, even though my Phidget RFID is attached the the device (emulator) does not, I have run it in normal Java classes that are not android related and it works. I have restarted a number of times.

Below is the log cat report:

01-06 13:10:18.984: W/System.err(623): PhidgetException 5 (Phidget not physically attached.)
01-06 13:10:19.004: W/System.err(623):  at com.phidgets.RFIDPhidget.setAntennaOn(Native Method)
01-06 13:10:19.016: W/System.err(623):  at myFood.myFood.AddFood.onCreate(AddFood.java:35)
01-06 13:10:19.034: W/System.err(623):  at android.app.Activity.performCreate(Activity.java:4465)
01-06 13:10:19.034: W/System.err(623):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-06 13:10:19.034: W/System.err(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-06 13:10:19.044: W/System.err(623):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-06 13:10:19.054: W/System.err(623):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-06 13:10:19.054: W/System.err(623):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-06 13:10:19.054: W/System.err(623):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 13:10:19.074: W/System.err(623):  at android.os.Looper.loop(Looper.java:137)
01-06 13:10:19.074: W/System.err(623):  at android.app.ActivityThread.main(ActivityThread.java:4424)
01-06 13:10:19.085: W/System.err(623):  at java.lang.reflect.Method.invokeNative(Native Method)
01-06 13:10:19.085: W/System.err(623):  at java.lang.reflect.Method.invoke(Method.java:511)
01-06 13:10:19.085: W/System.err(623):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-06 13:10:19.094: W/System.err(623):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-06 13:10:19.103: W/System.err(623):  at dalvik.system.NativeStart.main(Native Method)

Below is my code:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.phidgets.InterfaceKitPhidget;
import com.phidgets.Phidget;
import com.phidgets.PhidgetException;
import com.phidgets.RFIDPhidget;
import com.phidgets.event.TagGainEvent;
import com.phidgets.event.TagGainListener;


public class AddFood  extends Activity {
        /** Called when the activity is first created. */
    RFIDPhidget rfid;

    static String x ="NULL";
    int i = 0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.addfood);
        final TextView mytext=(TextView)findViewById(R.id.widget96);


try
{

        com.phidgets.usb.Manager.Initialize(this);
        rfid = new RFIDPhidget();
        rfid.setAntennaOn(true);
        rfid.setLEDOn(true);

        //Begin the TagGained event, allowing for users to read the RFID values



        rfid.addTagGainListener(new TagGainListener()
        {

            public void tagGained(TagGainEvent oe)
            {


                Object y = (oe.getValue());
                x= y.toString();
            }
        });
        rfid.open(34235);


        long StartTime,RunTime;
        StartTime=System.currentTimeMillis();
        do{

            RunTime=System.currentTimeMillis();
            if (x.equals("NULL")) {

                //Continue waiting for input
                }
            else

            StartTime = 10000; //Overload the result so the loop ends
        }
        while (RunTime-StartTime<5000);

        rfid.close();
        com.phidgets.usb.
        Manager.Uninitialize();

}
catch(PhidgetException e)
{

    e.printStackTrace();
}

        Button mybutton = (Button) findViewById(R.id.Button1);
        mybutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {






        }


        });

}

}

and my Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="myFood.myFood"
      android:versionCode="1"
      android:versionName="1.0">
      <uses-feature android:name="android.hardware.usb.host" />
      <uses-sdk android:minSdkVersion="12" />
        <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".myFood"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
   <activity android:name=".AddFood" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
    </application>


</manifest> 

If anyone has any experience with PHIDGETS or anything like this all help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

二智少女猫性小仙女 2025-01-01 09:57:56

使用 Phidg​​et WebService,我将 open() 更改为 open(IP,PORT)。效果很好。

Using the Phidget WebService I changed the open() to open(IP,PORT). Worked perfectly.

美煞众生 2025-01-01 09:57:56

尝试使用 rfid.openAny();
并在 phidget 插入的机器上插入 ip 地址,

例如 rfid.openAny("192.168.10.1", 34325);
这样您的 Android 设备就可以通过网络读取数据并与之交互

Try using rfid.openAny();
and also insert the ipaddress on the machine the phidget is plugged into

e.g rfid.openAny("192.168.10.1", 34325);
That way your android device can read and interact with it over the network

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文