它是FT2232D芯片,LED连接到BDBUS6.
这个库的文档记录比我想象的要少(比FTDI自己的库更好,它甚至不能在现代内核上工作),我能找到的唯一示例代码,它使用了一个不推荐使用的函数(我试过,它没有似乎工作),我绝对难倒.
我越努力尝试这件事,看起来就越难.我不是在寻找别人为我做功课,因为我只需要朝着正确的方向努力.任何帮助赞赏(甚至推测).
更新:我一直在尝试这个,虽然不推荐使用ftdi_enable_bitbang().下面的代码编译,它运行没有barfing,但没有blinkenlighten.有关器件的原理图可在http://www.semtech.com/images/datasheet/sx1211ska_v1_std.pdf (第23页)中找到.BDBUS6和BDBUS7连接到LED.
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <ftdi.h>
#define FTDI_VID 0x0403
#define FTDI_PID 0x6010
static struct ftdi_context ftdic_context;
int main(void) {
int ret;
unsigned int i;
unsigned char c = 0;
// Initialize bitbang.
// ret = ft2232_bb_init();
ftdi_usb_open(&ftdic_context, FTDI_VID, FTDI_PID);
ftdi_set_interface(&ftdic_context, INTERFACE_B);
ftdi_enable_bitbang(&ftdic_context, 0xb0);
// Trying to blink some lights.
printf("\nNow let's try to blinkenlights...\n");
for (i = 0; i < 20; i++) {
c ^= 0x80;
ftdi_write_data(&ftdic_context, &c, …Run Code Online (Sandbox Code Playgroud) 所以我一步一步地关注BlueGiga的BGDemo应用笔记,但在使用dfutool.exe更新USB加密狗的固件时遇到了问题.我采取的步骤如下:
但是命令提示符给我一个错误"device:2458:fffe not found",这真的令人难以置信,因为它在设备管理器中显示为具有完全相同硬件ID的libusb设备.有没有人知道我可能做错了什么?
我正在尝试使用libusb1.0.9实现用户空间usb驱动程序.我有lpc2148蓝板(ARM7)和我一起使用.这个主板是由Bertrik Sikken先生装载的开源USB堆栈/固件.现在我的用户空间驱动程序尝试用板写读.我正在获取垃圾数据.我想了解批量转运的流程.对于任何传输/事务是否涉及内核设备驱动程序?我们还需要usb小工具设备驱动吗?我无法理解数据被复制的位置.重要的是,当我读/写中断生成时,我可以在LCD上看到正确的数据.我需要读/写USBRxData/USBTxData吗?请做必要的.
我尝试了以下代码进行批量传输读写.
int usb_read(struct libusb_device *dev,struct libusb_device_handle *hDevice)
{
char *data,*data1;
struct libusb_endpoint_descriptor *ep;
struct libusb_interface_descriptor *id;
int len=64,r,ret_alt,ret_clm,ret_rst,i;
struct libusb_device **list;
data = (char *)malloc(512); //allocation of buffers
data1 = (char *)malloc(512);
memset(data,'\0',512);
memset(data1,'\0',512);
if(hDevice==NULL)
{
printf("\nNO device found\n");
return 0;
}
int ret_open = libusb_open(dev,&hDevice);
if(ret_open!=0)
{
printf("Error in libusb_open\n");
libusb_free_device_list(list,1);
return -1;
}
char str_tx[512]="G"; //data to send to device
char str_rx[512]; //receive string
data = str_tx;
printf("data::%s\t,str::%s\n",data,str_tx);
//printf("%c\n",data);
ep = active_config(dev,hDevice);
printf("after ep\n");
//printf("alt_interface = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种跨平台的方式来获取C#中的usb到达和删除事件,我找到了"LibUsbDotNet C#USB Library"(http://sourceforge.net/projects/libusbdotnet/?source=navbar).
它应该工作,但在Linux中似乎我无法获得设备挂载点(路径).在Linux中它使用"libusb"库,它没有获取设备路径的方法.
这是一个检测设备事件的简单代码示例:
internal class DeviceNotification
{
public static IDeviceNotifier UsbDeviceNotifier = DeviceNotifier.OpenDeviceNotifier();
private static void Main(string[] args)
{
// Hook the device notifier event
UsbDeviceNotifier.OnDeviceNotify += OnDeviceNotifyEvent;
// Exit on and key pressed.
Console.Clear();
Console.WriteLine();
Console.WriteLine("Waiting for system level device events..");
Console.Write("[Press any key to exit]");
while (!Console.KeyAvailable)
Application.DoEvents();
UsbDeviceNotifier.Enabled = false; // Disable the device notifier
// Unhook the device notifier event
UsbDeviceNotifier.OnDeviceNotify -= OnDeviceNotifyEvent;
}
private static void OnDeviceNotifyEvent(object sender, DeviceNotifyEventArgs e)
{ …Run Code Online (Sandbox Code Playgroud) 我使用以下命令安装了libusb.我不确定它是否正确而命令是
sudo apt-get install libusb-dev
Run Code Online (Sandbox Code Playgroud)
一旦我安装了(我不确定它是否已经安装,因为我是Ubuntu的新手用户),我想知道我将如何使用该库,因为我编写了一些使用<libusb.h>的示例代码,但是当我使用编译C++文件时
g++ test_libusb.cpp
Run Code Online (Sandbox Code Playgroud)
抛出以下错误,
test_libusb.cpp:2:20:致命错误:libusb.h:没有终止此类文件或目录编译.
我无能为力.我无法在互联网上找到任何来源到底...
我想知道两件事:
我正在尝试在我的PC和PIC18F4550之间进行通信,但是程序没有检测到它,而计算机正在设备管理器中显示它.
import usb.core
dev = usb.core.find(idVendor = 0x04D8, idProduct = 0xFEAA)
Run Code Online (Sandbox Code Playgroud)
检查USB设备的功能:
def find(find_all = False, backend = None, custom_match = None, **args):
def device_iter(k, v):
for dev in backend.enumerate_devices():
d = Device(dev, backend)
if _interop._reduce(lambda a, b: a and b,map(operator.eq,v,map(lambda i:getattr(d,i),k)),True)and (custom_match is None or custom_match(d)):
yield d
if backend is None:
import usb.backend.libusb1 as libusb1
import usb.backend.libusb0 as libusb0
import usb.backend.openusb as openusb
for m in (libusb1, openusb, libusb0):
backend = m.get_backend()
if backend is not …Run Code Online (Sandbox Code Playgroud) 我有用于Linux的Logitech G613键盘。除了默认情况下G(1-6)键映射到F(1-6),并且没有重新映射F键就无法重新映射它们的方法,该方法工作正常。
因此,我浏览了Internet上的大量资源,并找到了g15daemon和libg15。不幸的是,libg15不支持G613,但是我通过添加以下行找到了一种方法来使库检测键盘
DEVICE("Logitech G613",0x46d,0xc53d,G15_KEYS),
现在唯一的问题是,libg15使用来将kernerl驱动程序与设备分离usb_detach_kernel_driver_np(),这是成功的。但是之后,对的调用usb_set_configuration()失败了
USB error: could not set config 1: Device or resource busy
hwinfo分离内核驱动程序之前的输出
38: USB 00.0: 10800 Keyboard
[Created at usb.122]
Unique ID: ADDn.IsFhTXWBs20
Parent ID: k4bc.2DFUsyrieMD
SysFS ID: /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
SysFS BusID: 1-1:1.0
Hardware Class: keyboard
Model: "Logitech USB Receiver"
Hotplug: USB
Vendor: usb 0x046d "Logitech, Inc."
Device: usb 0xc53d "USB Receiver"
Revision: "43.00"
Driver: "usbhid"
Driver Modules: "usbhid"
Speed: 12 Mbps …Run Code Online (Sandbox Code Playgroud) 在WPF应用程序中使用USB设备,我可以成功连接并向设备发送命令.设备只接收命令,没有回复,所以我需要的是一个与之通信的EndpointWriter.
MyUsbFinder = new UsbDeviceFinder(vid, pid);
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
wholeUsbDevice = MyUsbDevice as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
wholeUsbDevice.SetConfiguration(1);
wholeUsbDevice.ClaimInterface(0);
}
writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);
Run Code Online (Sandbox Code Playgroud)
然后写入设备的过程:
byte[] update = { some bytes };
int bytesWritten;
if (MyUsbDevice != null)
{
ec = writer.Write(update, 2000, out bytesWritten);
}
Run Code Online (Sandbox Code Playgroud)
一切正常,包括关闭应用程序,除非在工作过程中USB设备断开然后重新连接.应用程序成功处理此方案并重新连接到设备,继续成功向其发送命令:
public bool reconnect()
{
//clear the info so far
if (MyUsbDevice != null)
{
writer.Dispose();
wholeUsbDevice.ReleaseInterface(0);
wholeUsbDevice.Close();
MyUsbDevice.Close();
UsbDevice.Exit();
}
//now start over
MyUsbFinder = new UsbDeviceFinder(vid, pid);
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
Run Code Online (Sandbox Code Playgroud)
......等等.
在发生此类断开/重新连接后关闭应用程序时会发生此问题.虽然该程序成功运行并与设备通信了很长一段时间,但在退出时我得到以下异常: …
我正在创建一个程序,使用 libusb 从 MIDI 控制器读取输入。如何正确调用libusb_bulk_transfer?目前我每次都会收到错误“LIBUSB_ERROR_NOT_FOUND”,并且我收到的数据是“P”。
我已将函数“libusb_bulk_transfer”替换为“libusb_interrupt_transfer”,但仍然收到相同的错误:LIBUSB_ERROR_NOT_FOUND
以下是我目前包含的库
#include <stdlib.h>
#include <stdio.h>
#include <libusb-1.0/libusb.h>
Run Code Online (Sandbox Code Playgroud)
下面是查找所有 USB 设备并调用导致我出现问题的函数的主函数: printDeviceUsbInput(devices[i]); 据我所知,主要功能运行良好。我删除了错误检查以使代码更短
int main(int argc, char *argv[])
{
libusb_device **devices;
libusb_context *context = NULL;
size_t list;
size_t i;
int returnValue;
returnValue = libusb_init(&context);
list = libusb_get_device_list(context, &devices);
printf("There are %zu devices found \n\n", list);
for (i = 0; i < list; i++)
{
printDeviceUsbInput(devices[i]);
//printDevices(devices[i]);
}
libusb_free_device_list(devices, 1);
libusb_exit(context);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
下面是查找 MIDI 键盘设备并尝试打印出 MIDI 输入的函数。又名导致我出现问题的功能。我受到这段代码的启发:http://libusb.sourceforge.net/api-1.0/libusb_io.html
我还删除了错误检查以使函数更短。
void printDeviceUsbInput(libusb_device *device)
{
struct …Run Code Online (Sandbox Code Playgroud) 由于此处的说明,正在尝试安装rtl-sdr(通过) ,但不能比第一个说明序列中的步骤更进一步:git clone git://git.osmocom.org/rtl-sdr.gitmake
cd rtl-sdr/\nmkdir build\ncd build\ncmake ../\nmake\nRun Code Online (Sandbox Code Playgroud)\n在我第一次尝试时,我收到以下错误:
\n/rtl-sdr/src/librtlsdr.c:30:10: fatal error: libusb.h: No such file or directory\nRun Code Online (Sandbox Code Playgroud)\n找到该文件后:
\n/usr/include$ sudo locate libusb.h\n/usr/include/libusb-1.0/libusb.h\nRun Code Online (Sandbox Code Playgroud)\n我尝试将原始内容替换#include <libusb.h>为#include <libusb-1.0/libusb.h>(如此处和此处建议的那样),这导致了不同的失败:
/rtl-sdr/build$ make\n[ 6%] Built target convenience_static\nScanning dependencies of target rtlsdr\n[ 9%] Building C object src/CMakeFiles/rtlsdr.dir/librtlsdr.c.o\n[ 12%] Linking C shared library librtlsdr.so\n[ 28%] Built target rtlsdr\n[ 31%] Linking C executable rtl_test\nlibrtlsdr.so.0.6git: undefined reference to …Run Code Online (Sandbox Code Playgroud)