完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我看到,在USB堆栈中,有一个函数PufSubStudio()将数据数组写入到USB中,但是没有GETUBSUART(),而是有一个从USB到缓冲区的字节串。因此,当PUT函数有3个版本的字符串2和字节数组的1时。get函数只有一个字符串版本。
以上来自于百度翻译 以下为原文 I see that in the USB stack there is a function putUSBUSART() that writes an array of data to the USB however there is no getUSBSUSART() instead there is getsUSBUSART() this copies a string of bytes from USB to the buffer. So while the put function has 3 versions 2 for strings and 1 for array of bytes the get functions has just a string version. Any idea why? |
|
相关推荐
6个回答
|
|
|
也许命名GETUsBuffAtter()更好,而不是GETSubStudio()。我认为通常只是几个字节,而不是您接收的“字符串”。IIRC,到目前为止,我从未使用putString……在我的任何CDC项目中都有函数。Ram和RomString的不同put版本是C18编译器的遗留。
以上来自于百度翻译 以下为原文 Maybe it would have been better to name it getUSBUSART() instead of getsUSBUSART(). I think usually it just a number of bytes and not a "string" that you receive. IIRC, up to now I never used the putString... functions in any of my CDC projects. The different put versions for Ram and RomString are a relict from C18 compiler I think. |
|
|
|
|
|
文档说明GETSubStudio()复制一个字节串…所以只是想知道…如何处理NULL?
以上来自于百度翻译 以下为原文 the documentation says getsUSBUSART() copies a string of bytes ... so just wondering .. how NULL is handled? |
|
|
|
|
|
为什么想知道呢?只需查看源代码…
以上来自于百度翻译 以下为原文 Why wondering? Just view the sourcecode.... /********************************************************************************** Function: uint8_t getsUSBUSART(char *buffer, uint8_t len) Summary: getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT endpoint to a user's specified location. It is a non-blocking function. It does not wait for data if there is no data available. Instead it returns '0' to notify the caller that there is no data available. Description: getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT endpoint to a user's specified location. It is a non-blocking function. It does not wait for data if there is no data available. Instead it returns '0' to notify the caller that there is no data available. Typical Usage: Conditions: Value of input argument 'len' should be smaller than the maximum endpoint size responsible for receiving bulk data from USB host for CDC class. Input argument 'buffer' should point to a buffer area that is bigger or equal to the size specified by 'len'. Input: buffer - Pointer to where received BYTEs are to be stored len - The number of BYTEs expected. **********************************************************************************/ uint8_t getsUSBUSART(uint8_t *buffer, uint8_t len) { cdc_rx_len = 0; if(!USBHandleBusy(CDCDataOutHandle)) { /* * Adjust the expected number of BYTEs to equal * the actual number of BYTEs received. */ if(len > USBHandleGetLength(CDCDataOutHandle)) len = USBHandleGetLength(CDCDataOutHandle); /* * Copy data from dual-ram buffer to user's buffer */ for(cdc_rx_len = 0; cdc_rx_len < len; cdc_rx_len++) buffer[cdc_rx_len] = cdc_data_rx[cdc_rx_len]; /* * Prepare dual-ram buffer for next OUT transaction */ CDCDataOutHandle = USBRxOnePacket(CDC_DATA_EP,(uint8_t*)&cdc_data_rx,sizeof(cdc_data_rx)); }//end if return cdc_rx_len; }//end getsUSBUSART |
|
|
|
|
|
这个函数似乎除了移动数据之外什么都不做。所以,对于他应该重命名为GeUsBuffAt()的那部分,你是对的。
以上来自于百度翻译 以下为原文 The function doesn't seem to be doing anything other than moving data around .. so you are right about the part that he function should be renamed to getUSBUSART() |
|
|
|
|
|
你好,KurtCalk,如果我没记错的话,必须调用GuUSB总线()函数才能正确地操作USB。你必须用一个与端点大小相同的或大于端点大小的缓冲器来调用它(64?)你只有一次机会获得数据包。您不能使用DATAN部分。该功能为下一个传入事务重新武装USB。任何数据都丢失了。希望这有助于Yorky。
以上来自于百度翻译 以下为原文 Hello kurtclark, If I recall correctly, the getUSBUSART() function has to be called for the USB to operate correctly. You have to call it with a buffer that is the same size or larger than the Endpoint size (64?). You only 'get one chance' at the packet of data. You can not consume the data in parts. The function re-arms the USB for the next incoming transaction. Any data is lost. Hope this assists. T Yorky |
|
|
|
|
|
它复制一个字节串而不是一个“字符串”。只有一个版本被提供,因为所有的源和目标存储类型总是相同的(例如,不能复制到ROM)。在这个级别上没有“字符串”(或任何其他)数据类型的概念,它只是来自通信信道的字节。TES可以是任何值,包括零。在这个级别上没有null的概念。字节的意思是由一些更高的层决定的。
以上来自于百度翻译 以下为原文 It copies a string of bytes not a "string". Only one version is supplied as that is all that is needed as the source and destination storage types are always the same (you can't copy to ROM for example). There can be no concept of a "string" (or any other) data type at this level, it's all just bytes coming from a communication channel. The bytes can be any value, including zero. There is no concept of NULL at this level. What the bytes mean is determined by some higher layer. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1122浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
872浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 21:28 , Processed in 0.828110 second(s), Total 82, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
16573