Linux:在内核模块中发送原始USB数据包

问题描述

我知道USB数据包具有非常特定的格式,但是我想自己写这些数据包,我知道@Slf4j public class NameAuthRestApi { final NameAuthService nameAuthService; @Post("/auth") @ProducesJson public Mono<RealNameAuthResp> auth(RealNameAuthReq req) { return nameAuthService.auth(NameAuthConverter.CONVERTER.toDto(req)) .handle((result,sink) -> { if (result.isSuccess()) { // I post an event here,but the event process couldn't access the ServiceRequestContext // that's would be the problem. eventBus.post(new SomeCustomizedClass(result)); final RealNameAuthResp realNameAuthResp = new RealNameAuthResp(); realNameAuthResp.setTradeNo(result.getTradeNo()); realNameAuthResp.setSuccess(true); sink.next(realNameAuthResp); sink.complete(); } else { sink.error(new SystemException(ErrorCode.API_ERROR,result.errors())); } }); } } 是一种控制数据包的接口,但是此功能已经负责发送setup_token,输入/输出令牌,并可能检查ACKS。我如何自己构造这些数据包然后发送?

解决方法

似乎您想要的是编写自己的USB主机驱动程序。我建议您尝试分析现有的USB主机驱动程序(ehci / xhci),然后尝试编写自己的驱动程序,但是请注意,这并非易事。还请注意,对于给定的USB主机控制器(ehci / xhci),不可能存在多个驱动程序。如果您确实想做这些事情,则需要同时了解两者:USB协议和ehci / xhci规范,这可能需要很多时间。还需要具有编写Linux驱动程序的丰富经验。正如我所说的,这不是一件容易的事。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...