标签: usb

AndroidStudio USB:EXTRA_PERMISSION_GRANTED 返回 false - 始终

我想使用以下代码 (AndroidStudio Chipmunk) 将 USB CDC 设备(FTDI 芯片或 CD2010 或定制芯片)连接到我的 Galaxy A12 (Android SDK 30):

\n
public class MainActivity extends AppCompatActivity {\npublic static final String ACTION_USB_PERMISSION = "com.example.usbtestapp.USB_PERMISSION";\nstatic final int intentFlags = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ? PendingIntent.FLAG_IMMUTABLE : 0;\nstatic final int MY_CAMERA_PERMISSION_CODE  = 100;\nprivate Context ContextofMainAcitivity;\npublic IntentFilter USBconnectdisconnect_intentFilter;\npublic Intent GetEXTRA_PERMISSION_GRANTEDIntent;\npublic PendingIntent current_usbpermissionIntent;\npublic UsbDevice current_usbdevice;\npublic UsbManager current_usbManager;\nprivate static final String TAG = "usbtestapp";\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n    ContextofMainAcitivity = this;\n    current_usbManager = (UsbManager)getSystemService(Context.USB_SERVICE);\n    USBconnectdisconnect_intentFilter = new IntentFilter();\n    USBconnectdisconnect_intentFilter.addAction(ACTION_USB_PERMISSION);\n    USBconnectdisconnect_intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);\n …
Run Code Online (Sandbox Code Playgroud)

usb android cdc

3
推荐指数
1
解决办法
1619
查看次数

Linux上的USB软件环回设备

我需要编写一个客户端 - 服务器应用程序,其中一个小型服务器放在USB小工具上,并与主机上的客户端应用程序通信.

我之前没有做过这类事情,但我已经完成了webapps,通常,它们都是使用lo环回网络接口在本地机器上开发和调试的.这可能影响了我的思维方式,我正在寻找一种在我的机器上模拟USB主机和小工具的方法,这样我就可以在我的PC上完全构建应用程序的两端,然后再深入了解实际的小工具并获得事情进行着.

这是正确的方法吗?我意识到USB协议是不对称的,并且在这里找到了一些参考,但它似乎是最自然的方式来实现它.

如果这是正确的方式,我该如何从这样的事情开始,是否存在其他人都知道我可能会偶然发现的潜在问题?

更新

我之前从谷歌搜索中找到的参考文献.有Linux内核模块(我的Ubuntu安装的一部分)似乎能够模拟主机和小工具端(分别是dummy_hcd和gadgetfs).我的想法是简单地拥有类似的东西

Host application (client) on PC <-> device file 0 <-> Loopback device <-> device file 1 <-> Gadget application (server) also on PC (will be moved to gadget).
Run Code Online (Sandbox Code Playgroud)

embedded usb client-server protocols

2
推荐指数
1
解决办法
2979
查看次数

WriteFile返回错误代码87

我正在编写一个正在写入HID设备的程序,并且在WriteFile函数上收到错误87,无效参数.我从Jan Axelson的USB Complete中获得了功能,所以我不确定为什么我会收到错误.我用它来找到我的设备:

private void USBInit()
    {
        IntPtr deviceInfoSet;
        Int32 memberIndex = 0;
        SP_DEVICE_INTERFACE_DATA MyDeviceInterfaceData = new SP_DEVICE_INTERFACE_DATA();
        Int32 bufferSize = 0;
        IntPtr detailDataBuffer;
        Boolean success = false;
        deviceFound = false;

        HidD_GetHidGuid(ref hidGuid);           // Get the GUID

        deviceInfoSet = SetupDiGetClassDevs     // Get pointer to a device info set
            (ref hidGuid,
            IntPtr.Zero,
            IntPtr.Zero,
            DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

        do
        {
            MyDeviceInterfaceData.cbSize = Marshal.SizeOf(MyDeviceInterfaceData);   // Identify Device Interface
            success = SetupDiEnumDeviceInterfaces
                (deviceInfoSet,
                IntPtr.Zero,
                ref hidGuid,
                memberIndex,
                ref MyDeviceInterfaceData);

            success = SetupDiGetDeviceInterfaceDetail           // Request Structure …
Run Code Online (Sandbox Code Playgroud)

c# usb hid

2
推荐指数
1
解决办法
4012
查看次数

类似Gameboy的键和D-Pad for Android

我想为Android 2.3手机制作RPG,并认为优秀的老Gameboy拥有这类游戏的完美格式.所以我想建立一个带有D-Pad和几个键的"Case",并通过USB将它们与Android设备连接起来.我不想要蓝牙,因为它需要很多能量.我想过为Case提供自己的Battery Cell,并且可能会加载Android设备.所以我的问题是:

如何从Android设备访问此案例的密钥?

usb android arduino gameboy

2
推荐指数
1
解决办法
494
查看次数

如何在linux中获取usb的urb信息

我试着获取usb stick的urb信息.我写的如下:

#include <sys/ioctl.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <usb.h>
/* #include <stropts.h> */
/* #include <inttypes.h> */
#include <linux/usbdevice_fs.h>
/* #include <asm/byteorder.h> */
/* #include <linux/usb/ch9.h> */
#define USBDEVFS_REAPURB           _IOW('U', 12, void *)
int main(int argc, char *argv[])
{ 
  int fd;
  int result;
  int i;
  struct usbdevfs_urb * receive;
  receive = malloc(sizeof (struct usbdevfs_urb));

  bzero(receive, sizeof (struct usbdevfs_urb));

  char file[30];
  strncpy (file, argv[1], 30);

  if ((fd = open(file, O_RDWR)) < 0) …
Run Code Online (Sandbox Code Playgroud)

c linux usb libusb

2
推荐指数
1
解决办法
4883
查看次数

Android 4.0.3上的USB触摸屏 - >无法选择(仅移动指针)

早上好家伙.

我买了一个集成了电阻式触摸屏的LCD嵌入式显示器.TS可通过USB连接.

我已将其连接到运行Android 4.0.3的设备,并且触摸被正确识别为外部HID.问题:敲击(按下)不被认为是选择/确认......出现这种情况,当我点击屏幕,是在协调我finger..like的我感动corrispondance移动指针(箭头)的唯一的事情没有左键单击的鼠标HID

我不可能滚动或选择一些东西 - >对我来说很乱:(

请记住,我有另一台带有集成USB TS的LCD,可以正常工作.我可以选择的情况下,我对他们的挖掘图标,我可以滚动窗口等 - > exactely像左键鼠标点击总是 - >确定对我!

也许这是司机的问题,但我没有具体的想法.

Ps我没有该设备的特定驱动程序.

有什么建议吗?请帮我 :)

先感谢您!!!!!

usb lcd touchscreen hid

2
推荐指数
1
解决办法
2万
查看次数

在应用程序级别从USB设备以Xcode获取序列号

我刚开始进行硬件编程,一直在尝试从USB设备获取序列号。我正在应用程序级别而不是内核级别实现所有功能。

我已经有一个字典可以匹配USB设备,因此我知道我有正确的设备。我不确定的是要返回的数据,如何解释它以及我是否正确处理了该问题。

因此,这里有一些我一直在尝试使用的代码,用于从设备获取序列号。

IOReturn retSerialIndex;
UInt8 snsi;
retSerialIndex = (*usbDevice)->USBGetSerialNumberStringIndex(usbDevice, &snsi);
if (retSerialIndex != kIOReturnSuccess)
{
    printf("Could not get serial number string index (error: %x)\n", retSerialIndex);
}
printf("Serial string index is %x\n", retSerialIndex);
IOReturn retSerial;
IOUSBConfigurationDescriptorPtr *desc;
if (retSerialIndex)
{
    retSerial = (*usbDevice)->GetConfigurationDescriptorPtr(usbDevice,
                                                            retSerialIndex,
                                                            desc);
    if (retSerial != kIOReturnSuccess)
    {
        printf("Could not get serial number using string index (error: %x)\n", retSerial);
    }
}
printf("Serial number is %x\n", retSerial);
char serialString;
serialString = getUSBStringDescriptor(usbDevice, retSerial);
printf("Serial string is %c\n", serialString);
Run Code Online (Sandbox Code Playgroud)

这是我的getUSBStringDescriptor实现: …

macos usb xcode

2
推荐指数
1
解决办法
748
查看次数

Raspberry Pyusb让资源忙碌

我正在尝试通过USB将我的Raspberry PI连接到Pic4550.(使用Windows c#程序,Pic功能正常!).所以我安装了rpi 2,pyusb,并尝试在[ https://github.com/walac/pyusb/blob/master/docs/tutorial.rst][1]的帮助下进行通信

我连接到USB设备,lsusb显示:

总线001器件006:ID 04d8:0080 Microchip Technology,Inc.

python prog找到了设备!获取正确的配置但无法写入消息:

usb.core.USBError:[Errno 16]资源忙

我尝试以sudo身份运行,我添加了规则:

SUBSYSTEM =="usb",ATTR {idVendor} =="04d8",ATTR {idProduct} =="0080",MODE ="666"

无论如何,我得到相同的资源忙

任何胶水帮助链接?

python usb hid pyusb raspberry-pi2

2
推荐指数
2
解决办法
9299
查看次数

在Linux中使用ACS ACR1252U USB NFC读卡器

我正在使用通过USB连接的ACS ACR1252U读卡器(http://www.acs.com.hk/en/products/342/acr1252u-usb-nfc-reader-iii-nfc-forum-certified-reader/)说实话,我不知道如何让它工作.我用谷歌搜索了很多东西,但没有运气.我正在使用Debian的变种.以下是我所做的或多或少:

我使用dmesg得到以下内容:

[ 7173.059710] usb 1-1.3: new full-speed USB device number 6 using dwc_otg
[ 7173.160500] usb 1-1.3: not running at top speed; connect to a high speed hub
[ 7173.163114] usb 1-1.3: New USB device found, idVendor=072f, idProduct=223b
[ 7173.163147] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7173.163168] usb 1-1.3: Product: ACR1252 Dual Reader
[ 7173.163186] usb 1-1.3: Manufacturer: ACS
Run Code Online (Sandbox Code Playgroud)

我使用以下Python代码来获取有关设备的更多详细信息:

#!/usr/bin/python

import sys
import usb.core

# find USB devices
dev = usb.core.find(find_all=True) …
Run Code Online (Sandbox Code Playgroud)

python linux usb smartcard nfc

2
推荐指数
1
解决办法
4533
查看次数

如何读取sysfs设备路径?

我的USB触摸屏连接到我的硬件设置.当我使用时,cat /proc/bus/input/devices我得到有关我的设备的以下详细信息:

I: Bus=0003 Vendor=2965 Product=5023 Version=0110
N: Name="Kortek Kortek Touch"
P: Phys=usb-0000:00:14.0-3.4/input2
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.2/0003:2965:5023.0006/input/input7
U: Uniq=S20131028
H: Handlers=mouse1 event7 js0
B: PROP=0
B: EV=1b
B: KEY=30000 0 0 0 0 0 0 0 0
B: ABS=3
B: MSC=10
Run Code Online (Sandbox Code Playgroud)

我想知道这条线S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.2/0003:2965:5023.0006/input/input7意味着什么.怎么看?路径中的数字是多少?

linux usb sysfs

2
推荐指数
1
解决办法
4611
查看次数

标签 统计

usb ×10

hid ×3

linux ×3

android ×2

python ×2

arduino ×1

c ×1

c# ×1

cdc ×1

client-server ×1

embedded ×1

gameboy ×1

lcd ×1

libusb ×1

macos ×1

nfc ×1

protocols ×1

pyusb ×1

raspberry-pi2 ×1

smartcard ×1

sysfs ×1

touchscreen ×1

xcode ×1