包含javausb通信的词条

博主:adminadmin 2022-11-21 20:06:08 78

今天给各位分享javausb通信的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

Java 如何通过 USB 读取对应的内容?

Java有个Common包,可以与串口活着并口通信,做毕业设计的时候用过,似乎那时候还没有USB的通用包,不过如果了解USB的协议的话,就可以处理usb数据帧了

windows下JAVA语言怎么操作USB设备进行数据收发。求指教~~~~~

Windows下开发视频采集方面的东西,你去找网上找一下DirectShow发面的资料,很多了,先要熟悉一下ActiveX编程不是很难。

Java应该是不能写驱动,因为java跨平台,而各个平台之间底层驱动完全不同,而且java的.class要靠虚拟机解释,由于虚拟机工作在ring3级,驱动程序却必须是工作在内核的ring0级,因此.class无法运行在ring0级。只知道VC能写VXD或者WDM驱动。

但是在windows环境下application模式的Java可以调用本地的DLL中的函数,你可以用VC写驱动,把相应的功能用VC、Delphi做成DLL供java调用,不过要记住必须是本地的DLL。

JAVA编程问题,利用 libusb-win32 将一个文件(比如abc.txt)写入 U盘.

LibUSB-Win32是一个用于Windows操作系统(Win98SE、WinME、Win2k和WinXP)上的通用USB设备驱动程序。该驱动程序允许使用者在不写任何一行核心驱动程序代码的情况下,可以访问Windows系统上的任意一个USB设备。该驱动程序具特点:

能够与任意一个已安装的USB设备进行通信

可被用作自己开发的USB设备的驱动程序

支持批量和中断传输

支持USB规范中定义的所有标准设备请求

支持USB设备制造商的自定义请求

通过使用七个函数,就可以与USB设备进行简单通信了,通信的主要流程可分为以下四步:

1) 调用usb_init函数,进行初始化。

2) 打开要进行通信的USB设备的句柄。首先依次调用usb_find_busses、usb_find_devices和usb_get_busses这三个函数,获得已找到的USB总线序列;然后通过链表遍历所有的USB设备,根据已知的要打开USB设备的ID(VID/PID),找到相应的USB设备;最后调用usb_open函数打开该USB设备(在这里假设总线上没有相同VID和PID的USB设备。如果总线上存在着相同VID和PID的设备,还需要进行其他条件判断,比如设备名称,以保证是打开的是期望的USB设备)。

3) 与USB设备进行通信。使用usb_control_msg函数,向USB设备读取数据或写入数据。

4) 关闭USB设备。完成所有操作后,调用usb_close函数关闭已经打开的USB设备。

具体流程去编程论坛,有清楚流程!

good luck!

java中有没有通过USB传输数据的库或者API之类的,要求一个终端发送一定格式的usb数据另一个终端能收到

High-level (javax-usb) API

import javax.usb.*;

import java.util.List;

public class TraverseUSB

{

 public static void main(String argv[])

 {

try

{

 // Access the system USB services, and access to the root 

 // hub. Then traverse through the root hub.

 UsbServices services = UsbHostManager.getUsbServices();

 UsbHub rootHub = services.getRootUsbHub();

 traverse(rootHub);

} catch (Exception e) {}

 }

 public static void traverse(UsbDevice device)

 {

if (device.isUsbHub())

 // This is a USB Hub, traverse through the hub.

 List attachedDevices = ((UsbHub) device).getAttachedUsbDevices();

 for (int i=0; i

 {

traverse((UsbDevice) attachedDevices.get(i));

 }

}

else

{

 // This is a USB function, not a hub.

 // Do something.

}

 }

 public static void testIO(UsbDevice device)

{

 try

 {

// Access to the active configuration of the USB device, obtain 

// all the interfaces available in that configuration.

UsbConfiguration config = device.getActiveUsbConfiguration();

List totalInterfaces = config.getUsbInterfaces();

// Traverse through all the interfaces, and access the endpoints 

// available to that interface for I/O.

for (int i=0; i

{

 UsbInterface interf = (UsbInterface) totalInterfaces.get(i);

 interf.claim();

 List totalEndpoints = interf.getUsbEndpoints();

 for (int j=0; j

 {

// Access the particular endpoint, determine the direction

// of its data flow, and type of data transfer, and open the 

// data pipe for I/O.

UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(i);

int direction = ep.getDirection();

int type = ep.getType();

UsbPipe pipe = ep.getUsbPipe();

pipe.open();

// Perform I/O through the USB pipe here.

pipe.close();

 }

 interf.release();

}

 } catch (Exception e) {} 

}

}

Java怎么通过USB传输数据

数据通过USB实时传输到PC

== 这段肯定用到mfc

java 端获取数据,要么c++那边开发了一个可用的dll,要么需要自己写一个与cpp对应的java类来实时调用mfc

javausb通信的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、javausb通信的信息别忘了在本站进行查找喔。

The End

发布于:2022-11-21,除非注明,否则均为首码项目网原创文章,转载请注明出处。