Using the HID class eases the job of writing USB device drivers

Hy-MT2(Python) 「Hy-MT2(Python)」是开源项目(Python)。源码完整,下载解压即可查看使用,适合学习参考、课程设计与二次开发。 立即下载

The difficulty of writing device drivers is one of the major barriers to the adoption of the USB. A typical embedded-device engineer who can comfortably design embedded systems all day long can get nervous at the thought of writing a PC-device driver. The design is no longer as simple as using the parallel port or serial port. Nonetheless, the USB offers many advantages, including multiplatform support, standard device classes, and support for vendor-defined devices. Motherboard vendors are also attempting to eliminate the legacy connections in favor of the USB, which forces embedded-system engineers to accept the evolution of technology. Move to the USB, or become obsolete.

Fortunately, by using the HID (Human Interface Device) class for the USB, you need not write a single Windows/Mac/Linux device driver. Even if your device doesn't fit into one of the predefined HID usages, you can use a completely vendor-defined usage.

The HID class is a standard device classification for the USB, but don't let the words "standard" or "classification" fool you. The HID class doesn't represent a set of fixed-function devices. Rather, it supports a variety of devices with widely varying characteristics. Some examples include a computer mouse, a keyboard, sports equipment, medical instruments, audio/video devices, and vendor-defined functions. HID also supports device primitives such as an LED and a button, and standard measurements, such as time, temperature, and distance. The general idea is that you can use the HID class to support a range of vendor-specific applications that a USB-device class doesn't currently support. Microsoft also supports the HID class with a well-rounded library that it includes as part of the Windows DDK.

ADVERTISEMENT
Click here!
To show how to use the HID class to communicate with an embedded device, a thermometer example that follows focuses on encapsulating the concepts of a Windows-based application. This example also shows how to use the Windows DDK library in a typical situation for a vendor-defined HID usage. The goal of the sample Windows application and USB device is to show the basic steps of data exchange across the USB using the HID driver. Click here for a complete design package for this example.

How does a device get on the USB?

The process of a device's getting on the USB begins with the act of a simple pull-up resistor. After you plug the device into an active USB host, the device turns on a pull-up resistor on one of the USB data signals. The device pulls up D– if the device is low-speed and pulls up D+ if it is full- or high-speed. The USB host detects this condition and begins device enumeration, a start-up process on the USB (Figure 1). (Note that high-speed hosts go through an additional process.) During enumeration, the host requests a number of data structures, or descriptors, from the device. These descriptors contain information about the number and type of communication channels, or endpoints, that the USB device desires to use, as well as information about any device class. Enumeration occurs on the default endpoint, which is endpoint 0, also known as the control endpoint. The host also assigns a unique 7-bit address to the device, directing communications to a particular device.

On PC or Mac platforms, the first part of the enumeration process occurs without custom or class-specific device drivers. During the first part of enumeration, the USB driver retrieves the general descriptors that all devices support and gives the device a unique address on the USB. If the descriptors indicate that the device belongs to a particular USB device class, the USB driver hands off the rest of the enumeration to the specified class driver. In the example for this article, the driver handoff is to the HID-class driver. If the descriptors don't specify a class, then the device's VID (vendor ID) and PID (product ID), gathered from the descriptors, identify an appropriate driver for the USB device.

In a properly designed USB HID device, you need not worry about the driver process. The device drivers on the USB host handle the enumeration process and the class-driver handoff for you. The USB host simply enumerates the device, which is then ready to use with your application. However, if you improperly format the descriptors or the device responds improperly, either the USB or the class driver disables the device, depending on when the failure occurred during enumeration.

HID requires no human interface

Don't let the "human interface" part of HID confuse you. A USB device that claims to belong to the Human Interface Device class need not necessarily have a human interface. The HID class supports a variety of devices that you would generally never associate with a human interface. Devices can be as obvious as a mouse or a keyboard but as unexpected as an IC programmer or a thermometer. The class also supports a variety of device primitives that you would associate with a general digital device, such as an LED, a button, a vector, or an LCD.

The HID class allows you to create a collection of HID usages to describe a device. The HID report descriptor, which the host gathers during enumeration, describes this collection along with the input and output data streams. For instance, a clock description could be an input stream of 3 bytes corresponding to hours, minutes, and seconds. The clock could also have an output report in the collection that describes how to write to a device's LCD. The HID class also has the capacity to allow vendor-defined usages. Even if none of the predefined usages in the HID usage tables (Reference 1) can describe your device, you can still reserve a generic vendor-defined slot in the HID report collection.

The downside to using the HID class is that the typical class drivers support only one type of endpoint communication—an interrupt—and the bandwidth is limited to well below the USB's maximum throughput. The bandwidth is limited to 800 bytes/sec/report (8 bytes/msec/I/O report) for low-speed devices, 64,000 bytes/sec/report (64 bytes/msec/I/O report) for full-speed devices, and approximately 23.4 Mbytes/sec/report (3072 bytes/microframe/I/O report) for high-speed devices. An HID may specify multiple reports if more than the "per-report" bandwidth is necessary.

Don't let these bandwidth limits immediately discourage you. Using an intelligent USB controller often helps presort data and lower the bandwidth that's required to support an application. The low-speed bandwidth limit was far greater than was necessary for the sample application that follows.

The steps to a working HID

You need to take many steps to make an HID enumerate and communicate using HID reports on the USB. This process isn't easy, but this application provides a framework that you can copy and edit as a starting point.

All USB devices handle "Chapter 9 requests," which Chapter 9 of the USB specification describes (Reference 2). The requests include tasks such retrieving a standard set of descriptors from the device and setting standard device parameters. The first specific task in making an HID is specifying the HID class in the USB interface descriptor's bInterfaceClass field. A value of 0x03 corresponds to the HID class. This value lets the general USB driver know which class driver the application needs to be passed on to after enumeration is complete.

During enumeration, the device also supplies an HID class descriptor as a subsection of the configuration descriptor in between the interface and the endpoint-descriptor subsections. This descriptor basically contains the HID-specification version information and the length of the HID-report descriptor. The second aspect of making an HID is the HID-report descriptor itself, which can be complex. The HID descriptor comprises HID usages, each of which describes a field in an input or an output report (Listing 1). The HID usage-table document shows a large number of useful examples of how to create an HID-report descriptor (Reference 1).

When the device correctly handles the Chapter 9 requests and HID-specific parameters, the remainder of the work lies in the application itself. This example uses a Microsoft Windows-based application. Examples are also available elsewhere for MacOS and Linux (references 3 and 4).

An application must first be able to open the device for communications—a fairly lengthy process. However, the sample application encapsulates the process into a reusable function, bOpenHidDevice() (Reference 5). The bOpenHidDevice function takes a device-handle reference, a target device VID, and a target device PID as function arguments. If the host finds a device that matches the desired VID and PID, then the function returns "true," and the Windows HID API assigns a valid value to the device handle. If the function returns false, it more than likely means that the either the device is not plugged in or the device failed enumeration.

The process of opening a device consists of seven steps (Figure 2).

  1. Obtain the Windows GUID (globally unique ID) for HID devices via a call to HidD_ GetHidGuid().
  2. Get an array of structures that contain information about all attached HIDs via a call to SetupDiGetClassDevs(). This step uses the previously obtained HID GUID to specify that the list should contain only HID devices.
  3. Use the Windows function SetupDiEnumDeviceInterfaces() to get information about a device in the list. You need to step through each index of device information until you find one with the correct VID and PID. If this function returns "false," then you have reached the end of the list without finding the desired device.
  4. A call to SetupDiGetDeviceInterfaceDetail() returns detailed data about the device indexed in the previous step. You want to use the device path to open the device in the next step.
  5. Call CreateFile() to open the device using the path obtained in the previous step. If the Windows API call to CreateFile() returns a valid handle, then you can examine the VID and PID to determine whether this is the device you want.
  6. Compare the open device's VID and PID to determine whether this is the device you want. If so, then you should return the device handle and a "true" condition.
  7. If the VID and PID are incorrect, then you need to close the device handle and return to Step 3 to check the next device the list indexes.

The HID application must then handle device-attachment and -detachment notification. The bHidDeviceNotify() function encapsulates this process. This function causes the Windows USB system to send a WM_DEVICECHANGE message to the application whenever a USB HID device is plugged into or unplugged from the system. The notification system is not intelligent enough to indicate an HID-device change for a VID and a PID, so the application must check whether the device is still attached on any notification message.

Setting up device notifications is a five-part process:

  1. Obtain the Windows GUID for HID devices by way of a call to HidD_GetHidGuid()
  2. Clear the contents of a DEV_BROADCAST_DEVICEINTERFACE structure 0.
  3. Assign the members of the structure such that you specify the HID GUID.
  4. Register the application for device notifications by calling the function RegisterDeviceNotification().
  5. If the previous step returns an invalid handle, then an error has occurred, and the function should return an error. Otherwise, the return is successful.

The Windows DDK provides a number of functions that allow you to find devices with certain capabilities and retrieve pieces of data from the USB device. The library functions are too numerous to mention here, but you can find them by searching for "HID Support Routines for Clients" on the MSDN Web site (Reference 6).

Input and output reports

The next function that the application needs is the ability to read input reports and write output reports. To perform these tasks, an application uses the ReadFile() and WriteFile() functions, respectively. Each of these functions use the device handle that the

CreateFile() function returns. This application uses overlapped transactions, which allow the application to enter a low-CPU-overhead state while waiting for a requested USB transaction to occur. You can queue as many as eight overlapped transactions at once by default, and you can queue more if more are specified. If an application doesn't use overlapped transactions, then it has to wait until the USB transaction finishes before it can perform any additional tasks. This state is undesirable when an application spends most of its time waiting for data returned from a USB device. The bOpenHidDevice() function opens the device with the FILE_FLAG_OVERLAPPED parameter, so all transactions are overlapped in this example.

A second aspect of data transfer is the use of multiple threads. Because the main application needs to remain responsive even while waiting for USB transactions, it is desirable to put the USB reads and writes in a separate thread. This feature allows the main application to continue processing messages while the USB transaction thread waits for overlapped transactions to complete.

A sample HID thermometer

The thermometer in this example communicates with a PC via the HID-class driver. This example shows an unconventional use of the versatile HID class. This thermometer has an LED, a button, and a temperature measurement. The button and thermometer are grouped into an input report, and the host application controls the LED via an output report. Again, for a complete design package, click here.

An LED is a predefined "usage page"—that is, a collection of LED-related functions—of the HID class (see the HID usage-tables specification). For the purposes of this application, the LED usage is defined as a ready LED. The intention of providing this control is to show how to use an HID output report. The report comprises one byte that turns on the LED (0x01) or off (0x00). The LED is on when the computer starts taking measurements and off when the measurements stop; that is, when the application closes. WriteFile() sends an overlapped HID output report to the USB device.

The button is also a predefined usage page of the HID class. You can define a general-purpose button without a usage in mind. Figure 3 shows the format of the button report. To request button information from the USB device, the windows application uses an overlapped transaction via a call to ReadFile().

The temperature measurement is a bit more complex. The "generic-desktop" usage page contains a nonoriented vector. The intended use of a nonoriented vector is for measuring time, distance, temperature, light intensity, and so on when direction is not important. The HID report descriptor also indicates the units for the measurement—that is, SI linear Kelvin—and the exponent (100) for the reported value. The temperature-measurement IC on the USB device reports in Celsius, so reporting in Kelvin is a matter of simply adding 273 to the IC's measured value. The application searches for a USB device; it does not look for units, exponents, or other information. However, the Windows HID DDK allows your application to search for devices with certain capabilities instead of a dedicated device (Reference 6).

The example provides both the button and temperature measurement as one report. Whenever the button changes or a temperature measurement is complete, the USB device reports these values back to the host in the format that Figure 3 shows. The format of the HID report descriptor for the thermometer shows the vendor-defined usage and a collection of three reports, two of which are in a single input report (Listing 2). The Windows HID driver follows the conventions set in the HID-class specification to parse the HID report descriptor. Even if the host-side application doesn't use some of the information in the HID report descriptor, it is still necessary for the HID driver to accept your device.

Detailed information about how to format HID report descriptors is beyond the scope of this article. The HID-class and HID usage-table specifications provide complete information on this subject. A HID descriptor tool is also available to help you with this task.

The host application for the HID-thermometer application was written using the VisualC++ Version 6.0 tools and the Win98 DDK (Figure 4). The Win98 DDK isn't the most up-to-date kit, but it ensures that you can build the application using all versions of the Windows DDK and that the application will run with all USB-enabled versions of Windows.

Cypress developed the USB device for the CY7C63743 USB microcontroller. The CY3644 application board that comes with the microcontroller's development kit has buttons, LEDs, and a temperature IC. The microcontroller's source code, assembler, and ROM image are part of the design package.


Author Information
Stuart Allman is a senior systems engineer and solution architect for the Personal Communications Division of Cypress Semiconductor (www.cypress.com). He holds a BS degree in electrical engineering from the University of Washington (Seattle). Before joining Cypress, Allman worked at small audio companies developing microcontroller- and DSP-based products. Allman joined Cypress in 1998 and has been involved with microprocessor development tools, IC architectures, and encryption technology.
SpringBoot+Vue+Mysql图书馆管理系统(源码+文档) SpringBoot+Vue+Mysql图书馆管理系统 WEB端软件项目(源码+文档)--11 项目包含:①完整源码(后端+管理后台+用户前台);②数据库脚本(db.sql 建库 + 演示数据.sql,导入即有多条真实感演示数据);③论文文档;④开题报告;⑤答辩PPT;⑥任务书与项目部署运行说明文档(含演示账号与导入步骤)。 项目架构: B/S 架构、MVC 分层设计 技术栈: Java、MySQL、SpringBoot、MyBatis-Plus、Token 权限校验、管理后台 Vue+ElementUI、用户前台 HTML+Vue+Layui、后台首页数据看板(SVG 图表)、Maven 构建。 一、角色设计 读者(用户): 注册登录、图书检索与浏览、在线借阅申请、归还信息查看、罚金查询与缴纳、图书评论、图书收藏、留言反馈、个人中心等。 管理员: 图书信息管理、图书分类管理、借阅申请审核、归还登记、罚金管理、读者管理、评论管理、馆内资讯管理、留言板管理、轮播图管理、后台数据统计看板等。 二、前台功能模块(读者端) 首页展示:全屏轮播图、图书信息一览、馆内资讯速递、图书搜索入口 图书浏览:图书分类导航(世界名著 / 人文社科 / 少儿读物等六大分类)、图书列表检索、图书详情页(封面、作者、出版社、可借数量、简介) 借阅模块:在线提交借阅申请、选择借阅天数、管理员审核、借阅记录查询(借阅中 / 已归还)、应还日期提醒 归还模块:归还信息查看、归还日期登记核对 罚金模块:逾期罚金查询、缴纳状态管理(已缴 / 未缴) 图书评论:图书详情页留言评论互动 收藏模块:图书收藏与取消收藏、我的收藏列表 馆内资讯:开馆调整、新书通报、活动公告等资讯列表与详情 留言板:读者建议与咨询留言、管理员回复 个人中心:个人资料修改、修改密码 三、后台管理模块 ..... 立即下载

相关推荐

AirymaxOS 极境智能体操作系统 基于Linux 6.6 进行微内化改造的kerne 本仓库是 AirymaxOS 的管理仓库,也是 airymaxhub 下的五个管理仓库之一

极境智能体操作系统,自有Kernel:ALK(Liunx 微内核化改造)支撑每秒数万 Agent 并发任务。整个AirymaxOS工程实现采用微内核思想,和AirymaxRT属于不同态,AirymaxRT能基于AirymaxOS运行,效率更高,速度更快,运行更稳定。

Field 'id' doesn't have a default value 错误的解决办法

1.Field 'id' doesn't have a default value如果你在写web项目的时候,然后在写添加的方法的时候,出现 Field 'id' doesn't have a default value 这个错误,那就什么都不用看 直接找到你的数据库,然后打开设计表,看下面自增递增是否勾选上了,如果没有勾上再去执行 就可以了。(这个问题困扰了我半天时间)...

qq_39086076的博客 17万+

五子棋小游戏,可联机,单机

五子棋小游戏,可联机,单机

Field ‘id‘ doesn‘t have a default value问题解决方法

(1)打开数据库,选中表并选择设计表 (2)选中id行 (3)选择自动递增二、当id为char或varchar类型 这种情况一般不会出现这种问题,如果出现需要检查自己设计的实体类中,id所使用的主键策略。 (1)检查是否IdType是否选择了AUTO (2)如果是,则修改为ID_WORKER_STR........................

m0_47475793的博客 2万+

基于蜣螂优化算法的多无人机安全航迹规划方法研究(Matlab代码实现)

内容概要:本文研究了基于多策略改进蜣螂优化算法(MSDBO)的多无人机协同三维安全航迹规划方法,旨在解决城市空中交通等复杂环境中多无人机集群飞行的路径规划与动态避障问题。通过引入多种优化策略对蜣螂算法进行改进,增强了算法的全局搜索能力与收敛精度,构建了以路径长度、飞行高度、威胁规避和转弯角度等为约束的综合成本最小化目标函数,实现了多无人机在三维空间中的高效协同避障与安全路径生成。该方法有效提升了飞行任务的安全性与执行效率,并通过Matlab仿真验证了其相较于传统算法在路径质量、避障能力和收敛性能方面的优越性。; 适合人群:具备一定智能优化算法基础和Matlab编程能力,从事无人机路径规划、群体智能算法、空中交通管理或相关工程应用研究的科研人员、高校研究生及自动化、航空航天领域的技术人员。; 使用场景及目标:①应用于城市巡检、应急救援、物流配送等多无人机协同任务中的三维路径规划;②为解决复杂动态环境下多机冲突消解、威胁规避与航迹优化问题提供高效算法支持;③推动蜣螂优化算法在多智能体系统与复杂工程优化中的实际落地与拓展应用。; 阅读建议:建议结合文中提供的Matlab代码进行仿真实践,深入理解MSDBO算法的设计机制与航迹规划模型的构建逻辑,可尝试调整环境参数、威胁分布或优化目标权重,观察算法在不同场景下的适应性与鲁棒性,进一步掌握智能优化算法在无人机系统中的应用方法与调参技巧。

有限长度直导线的三维磁场计算:应用毕奥-萨法尔定律(Matlab代码实现)

内容概要:本文系统阐述了基于毕奥-萨伐尔定律计算有限长度直导线在三维空间中产生磁场的理论方法与实现过程。通过建立直导线磁场的积分数学模型,结合数值离散化处理手段,利用Matlab编程实现磁场矢量的精确计算与三维可视化,详细展示了空间任意点处磁场强度的大小与方向分布特性。文中深入探讨了该方法相较于安培环路定律在处理非闭合、有限长导体时的适用优势,并提供了完整的Matlab代码实现方案,便于读者复现结果、理解物理规律并拓展至更复杂的电磁场建模问题。; 适合人群:具备电磁学基础理论知识和Matlab编程能力的高等院校电气、物理及相关专业的本科生、研究生、科研人员以及从事电磁兼容、电力工程、传感器设计等领域的工程技术开发者。; 使用场景及目标:①作为电磁场与电磁波课程的教学辅助材料,帮助学生直观理解毕奥-萨伐尔定律的物理内涵与实际应用;②为工程实践中直导线电流产生的磁场建模、电磁干扰(EMI)分析、磁传感器布局优化等提供可靠的仿真依据;③作为学习复杂电磁系统数值计算方法的入门级实践案例,为进一步研究奠定基础。; 阅读建议:建议读者结合经典电磁学教材,仔细推导文中的积分公式,透彻理解其物理意义,并亲自运行所提供的Matlab代码,通过调整导线长度、电流强度及观察点位置等参数,观察磁场分布的变化规律,从而深化对三维静磁场特性的直观认知与工程应用理解。

Field ‘id’ doesn’t have a default value的解决方法

问题描述: 今天在写作业的过程中,发现了这样一个问题: org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.sql.SQLException: Field 'id' doesn't have a default value ### The error may involve com.ssm.mapper.GoodsMapper.addGoods-Inline ### The

Shen_ye_jiu的博客 2万+

塔式熔盐光热朗肯循环电站建模!并且搭建了Simulink模型!!

内容概要:本文详细介绍了塔式熔盐光热朗肯循环电站的建模过程,并基于MATLAB/Simulink平台构建了完整的系统仿真模型。该模型深度融合了光热发电的核心组件与朗肯循环的能量转换机制,涵盖太阳能集热、熔盐传热储热、蒸汽发生及汽轮发电等关键环节,能够有效模拟系统的动态响应特性与能量转换效率。研究特别关注系统在变工况下的运行性能,通过仿真手段分析其电能输出稳定性、热力循环效率以及对电网调频的潜在支撑能力,凸显了Simulink在复杂能源系统多物理场耦合仿真中的强大功能与工程应用价值。; 适合人群:具备一定电力系统、热力学基础知识和Simulink软件操作技能的研究生、科研人员及能源领域的工程师。; 使用场景及目标:① 深入学习和掌握塔式熔盐光热电站的工作原理、系统组成及建模方法;② 利用Simulink进行多能耦合的综合能源系统仿真研究,探究系统优化运行策略与动态性能;③ 为从事新能源发电、储能技术及智能电网调度的专业人士提供先进的技术参考和创新灵感。; 阅读建议:读者在学习本文时,应结合具体的系统原理图与Simulink模型进行对照分析,深入理解各模块的数学建模与参数设置。强烈建议动手复现仿真模型并调整关键参数,通过改变光照强度、熔盐流量等输入条件来观察系统输出的变化,以加深对光热电站动态特性的理解,培养解决实际工程问题的实践与创新能力。

如何解决Field 'id' doesn't have a default value 问题

其主要原因是因为mysql的中没有将主键设置为自增,所以在增加元素时获取生成主键时出现异常 那么问题就转变成了如何将id属性设置为主键自增 首先打开Mysql workbench,找到对应所要设置的表: 点击表的扳手符号 出现该表的设置信息页面: 选中所要设立自增属性的AI,点击应用即可完成设置。 重新运行,即可实现增加数据的操作 另外分享一个Mysql workbench的汉化教程...

汤姆lazy的优快云博客 14万+

双Buck电路并联VDCM下垂控制(Simulink仿真实现)

内容概要:本文介绍了基于Simulink的双Buck电路并联VDCM下垂控制的仿真实现,属于电力电子与新能源系统控制领域的研究内容。通过构建双Buck电路的并联拓扑结构,结合VDCM(电压下降控制法)下垂控制策略,实现多个变换器模块间的均流与稳定输出电压控制。文中详细阐述了控制原理、系统建模方法、关键参数设计及Simulink仿真模型的搭建过程,展示了在负载变化或输入波动条件下系统的动态响应与稳定性表现,验证了所提控制策略在提高系统可靠性与模块化扩展性方面的有效性。; 适合人群:具备电力电子技术、自动控制理论基础,从事新能源变换器、直流微电网、模块化电源系统等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 掌握双Buck电路的工作原理与并联运行特性;② 学习VDCM下垂控制机制及其在均流控制中的应用;③ 构建并调试多模块并联DC-DC变换器的Simulink仿真模型,用于科研验证或教学演示。; 阅读建议:建议结合Simulink仿真环境动手实践,重点关注控制器参数整定、均流效果评估及系统抗干扰能力分析,同时可延伸至其他并联均流控制策略(如主从控制、平均电流法)的对比研究。

用于增加无线传感器网络(WSN)寿命的改进型LEACH协议(Matlab代码实现)

内容概要:本文围绕用于增加无线传感器网络(WSN)寿命的改进型LEACH协议展开研究,通过Matlab代码实现对经典LEACH协议进行优化,旨在延长网络生命周期、降低能耗并提升数据传输的可靠性。文章首先剖析了LEACH协议在簇头选举机制、能量消耗分布及数据冗余传输方面的固有缺陷,随后提出一种改进方案,重点优化簇头选择算法以实现节点间能量消耗的均衡化,减少远距离通信带来的高能耗问题,并增强网络拓扑的稳定性。研究构建了完整的WSN仿真模型,设定合理的网络规模、节点分布与能量参数,在Matlab平台上对比分析原始LEACH与改进协议在网络存活轮数、剩余能量衰减趋势、有效数据包传输量等关键性能指标上的表现,充分验证了所提方法在提升能量效率和延长网络寿命方面的有效性与优越性。; 适合人群:具备一定无线传感器网络基础知识和Matlab编程能力的高校研究生、科研人员及从事物联网、低功耗通信系统开发的工程技术人员。; 使用场景及目标:①深入理解LEACH协议的工作机制及其局限性;②掌握基于Matlab的无线传感器网络仿真建模方法;③学习如何通过算法优化提升WSN的能量效率与网络寿命;④为相关领域科研项目或实际系统设计提供技术参考与实现范例。; 阅读建议:建议读者结合文中提供的Matlab代码逐模块阅读,重点关注簇头选举逻辑、能量模型构建与仿真结果分析部分,动手运行并调试代码以加深理解,同时可尝试在此基础上进一步改进算法或扩展仿真场景。

Field 'id' doesn't have a default value之解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。https://blog.youkuaiyun.com/qq_42680327 java.sql.SQLException: Field 'id' doesn't have a default value:今天在学习struts2的时候,测试数据的时候老是报"Field 'id' doesn't have a default value"异常,找了半天...

qq_42680327的博客 1万+

大学生职业生涯规划.pptx

大学生职业生涯规划.pptx

Field ‘userID‘ doesn‘t have a default value

Caused by: java.sql.SQLException: Field 'userID' doesn't have a default value 字段需要设置一个默认值

niaonao 8万+

论文《基于物理信息神经网络的传热过程物理场代理模型的构建》Python torch复现

内容概要:本文是对论文《基于物理信息神经网络的传热过程物理场代理模型的构建》的Python Torch复现研究,旨在通过PyTorch框架实现物理信息神经网络(PINN)在传热过程中的应用。该复现工作将热传导等物理定律嵌入神经网络训练过程,利用控制方程和边界条件构造损失函数,使模型能够在少量甚至无实测数据的情况下,对温度场等物理量进行高精度预测。研究涵盖了模型架构设计、物理约束的数学表达、损失项构建、训练流程优化及结果可视化等关键环节,充分展示了PINN在科学计算与工程仿真中替代传统数值方法的潜力与优势。; 适合人群:具备深度学习与传热学基础知识,熟悉Python编程及PyTorch框架,从事科研或工程仿真的研究生、科研人员及工程技术开发者。; 使用场景及目标:① 掌握物理信息神经网络(PINN)的基本原理与代码实现方法;② 构建高效的传热过程代理模型,以替代高成本的传统数值模拟,提升仿真效率;③ 应用于热管理系统设计、材料热性能分析、能源系统优化等需要快速物理场预测的实际工程场景。; 阅读建议:建议读者结合原论文与本复现代码,深入理解物理控制方程如何转化为可微分的损失项,并通过调试网络结构与超参数,探究不同损失权重对模型收敛性与预测精度的影响,进一步将该方法迁移至其他偏微分方程驱动的物理系统建模任务中。

用GraphPad Prism直出单细胞亚群堆叠柱状图

用GraphPad Prism直出单细胞亚群堆叠柱状图

fivehuge的博客 4198

Field 'Id' doesn't have a default value解决方法

      今天写代码遇到的一个小问题:使用工具将SQL文件导入数据库时出现的问题,一开始没注意到,后来检查了下数据表,发现在Mysql中没有将主键设置为自增,所以在使用Mybatis时获取生成主键时出现异常,异常如下:七月 14, 2018 12:27:33 上午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.s...

刘信坚的博客 4万+

解锁RK1126与SC132GS摄像头适配密码:技术与代码全解析

本文详细介绍了瑞芯微RK1126芯片与SC132GS摄像头的适配方法。首先分析了RK1126的四核Cortex-A7处理器、Mali-T860 GPU等硬件特性,以及SC132GS的130万像素、全局快门等技术参数。重点阐述了基于MIPI CSI接口的硬件连接原理和基于V4L2框架的软件驱动设计,并提供了完整的初始化、数据采集和图像处理代码实现。针对常见连接和图像质量问题给出了解决方案,展现了该组合在智能安防、工业检测等领域的应用潜力,为开发者提供了实用的技术参考。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1507

又是一个新问题,Field 'id' doesn't have a default value 最终完美解决

问题多多,纯粹为记录,今天晚上纯粹就是找BUG了,已经解决3个问题了! 这个问题第一次遇到,在此记录下,下次有可能还要用到! 在网上找了下,第一种方法就解决了!再记录下,别的方法! 解决方法一: 打开my.ini,查找 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 修改为 sql-mod...

风吹花儿香 1万+

YOLO11改进-注意力-引入Deformable Large Kernel Attention (DLKA) 解决多尺度、小目标、遮挡等问题

Deformable Large Kernel Attention (DLKA) 是一种用于视觉任务的注意力机制,旨在提升模型在处理不同尺寸和形状对象时的灵活性和性能。DLKA 的设计灵感源自传统的注意力机制,但通过引入可变形核(deformable kernel)来增强对局部特征的适应能力。

qq_64693987的博客 4042

Autosar Configuration(十四)SomeIP之配置SoAd

本文主要介绍SomeIp协议栈中的SoAd在Configurator中的详细配置

king110108的专栏 2603

Field 'id' doesn't have a default value错误解决方法

初学Hibernate写了一个实体类Person,然后打算在main()函数中用session对象的save()方法保存对象到数据库javee中。运行后控制台报 Field 'id' doesn't have a default value 错误提示。检查了配置文件和各个类的代码感觉没有问题,再运行仍报错。写的Person.hbm.xml映射文件如下图: 主键类型获取

zr_1877的博客 2万+

《网络安全自学教程》- 802.1x协议

802.1x协议架构,工作原理/认证流程,认证方式,MAB认证,触发认证的三种方式,EAP报文格式,EAPOL报文格式

wangyuxiang946的博客 2万+
上一篇: Cisco 3640策略路由配置
下一篇: 一种提取shellcode的方法
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值