CH573 USB CDC SET_LINE_CODING問題

使用CH573的USB CDC串口,串口可以通訊,數(shù)據(jù)上下行正常。但是每次打開串口都會(huì)下發(fā)兩次SET_LINE_CODING,數(shù)據(jù)還不一樣,我抓到的打印信息如下:

CH573>>[I/USB/CDC]?set?line?coding?dataRate?:?9600?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8
[I/USB/CDC]?set?line?coding?dataRate?:?9600?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8

第一次的波特率是9600 第二次這個(gè)8609是怎么回事? 前面的只有波特率是正常的,后面這次波特率不對 其他的都是正確的。



部分代碼如下:

????????????//?endpoint0?out
????????????case?UIS_TOKEN_OUT:
????????????{
????????????????LOG_D("endpoint0?out?->?len?=?%d",?R8_USB_RX_LEN);
????????????????len?=?R8_USB_RX_LEN;
????????????????/*?類請求?且是?設(shè)置linecodeing*/
????????????????if?(SetupReqCode?==?SET_LINE_CODING)
????????????????{
????????????????????if?(RB_U_TOG_OK)
????????????????????{
????????????????????????Line_Coding.dwDTERate?=?*(uint32_t?*)pEP0_DataBuf;
????????????????????????Line_Coding.bCharFormat?=?pEP0_DataBuf[4];
????????????????????????Line_Coding.bParityType?=?pEP0_DataBuf[5];
????????????????????????Line_Coding.bDataBits?=?pEP0_DataBuf[6];
????????????????????????LOG_I("set?line?coding?dataRate?:?%ld?,?charFormat?:?%d?parityType?:?%d?dataBits?:?%d",?Line_Coding.dwDTERate,?Line_Coding.bCharFormat,?Line_Coding.bParityType,?Line_Coding.bDataBits);
????????????????????????R8_UEP0_T_LEN?=?0;
????????????????????????R8_UEP0_CTRL?|=?UEP_R_RES_ACK?|?UEP_T_RES_ACK;?//?準(zhǔn)備上傳0包
????????????????????}
????????????????}
????????????????else
????????????????{
????????????????????R8_UEP0_T_LEN?=?0;
????????????????????R8_UEP0_CTRL?|=?UEP_R_RES_ACK?|?UEP_T_RES_NAK;?//狀態(tài)階段,對IN響應(yīng)NAK
????????????????}
????????????????R8_UEP0_CTRL?^=?RB_UEP_R_TOG;?????????????????????????????????????//同步標(biāo)志位翻轉(zhuǎn)
????????????}
????????????break;



通過串口助手設(shè)置不同波特率的時(shí)候下發(fā)的指令正確嗎?

http://www.findthetime.net/bbs/thread-71832-1.html

該鏈接下有CH579模擬CDC的demo,可以參考一下。


CH573>>[I/USB/CDC]?set?line?coding?dataRate?:?115200?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8
[I/USB/CDC]?set?line?coding?dataRate?:?115200?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8
[I/USB/CDC]?set?line?coding?dataRate?:?38400?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8
[I/USB/CDC]?set?line?coding?dataRate?:?38400?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?0?parityType?:?0?dataBits?:?8
[I/USB/CDC]?set?line?coding?dataRate?:?38400?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?1?parityType?:?4?dataBits?:?6
[I/USB/CDC]?set?line?coding?dataRate?:?38400?,?charFormat?:?0?parityType?:?0?dataBits?:?7
[I/USB/CDC]?set?line?coding?dataRate?:?8609?,?charFormat?:?1?parityType?:?4?dataBits?:?6

這幾條就是設(shè)置不同波特率 停止位 校驗(yàn)位的時(shí)候收到的數(shù)據(jù) 每次都會(huì)收到四條set line coding命令 兩兩重復(fù)。代碼參考了ch579的實(shí)現(xiàn),但是ch579沒有解析set line coding命令。


你好,你可以把你的工程貼一下,或者發(fā)我的郵箱,我們幫你看一下。


發(fā)你郵箱了 收到請幫忙看一下


好的 收到


如方便,請電話025-52635387


請給個(gè)回復(fù),這個(gè)問題我翻了USB 1.1的手冊 沒找到解決方法。著急 感謝


icon_rar.gifCH573_CDC_OK.rar

可以參考一下CH573_CDC壓縮包,你的調(diào)試環(huán)境和復(fù)現(xiàn)步驟可否詳細(xì)敘述。

或直接聯(lián)系025-52635387


????????switch?(?SetupReqCode?)
????????{
??????????case?0x01?:??????????????????//GetReport
????????????break;
??????????case?0x02?:??????????????????//GetIdle
????????????break;
??????????case?0x03?:??????????????????//GetProtocol
????????????break;
??????????case?0x09?:??????????????????//SetReport
????????????break;
??????????case?0x0A?:??????????????????//SetIdle
????????????break;
??????????case?0x0B?:??????????????????//SetProtocol
????????????break;
??????????case?GET_LINE_CODING?:????//0x21??currently?configured
????????????pDescr?=?LineCoding;
????????????len?=?sizeof(?LineCoding?);
????????????len?=?SetupReqLen?>=?DEFAULT_ENDP0_SIZE??
????????????????DEFAULT_ENDP0_SIZE?:?SetupReqLen;
????????????memcpy(?pEP0_DataBuf,?pDescr,?len?);
????????????SetupReqLen?-=?len;
????????????pDescr?+=?len;
????????????break;
??????????case?SET_CONTROL_LINE_STATE?:????//0x22??generates?RS-232/V.24?style?control?signals
????????????break;
??????????case?SET_LINE_CODING?:??????//0x20??Configure
???????????//?PRINT("set?line?coding?len?=?%d...\n",?R8_USB_RX_LEN);
????????????for(int?i?=?0;?i?<?R8_USB_RX_LEN;?i?++)
????????????{
??????????????PRINT("%02x?",?pEP0_DataBuf[i]);
????????????}
????????????PRINT("\n");
????????????break;
??????????default?:
????????????errflag?=?0xFF;
????????????break;
????????}

就你附件的代碼 你在

SET_LINE_CODING

里面打印一下,看一下上位機(jī)的串口軟件在打開的時(shí)候串口信息是什么? 感覺串口配置信息和上位機(jī)軟件的配置不一樣啊。


以下是我抓到的信息。

21?20?00?00?00?00?07?00?35?00?34?00?5f?00?43?00?44?00?43?00?00?10?01?05?24?01?00?00?04?24?02?02?05?24?06?00?01?07?05?81?03?08?00?ff?09?04?01?00?02?0a?00?00?00?07?05?02?02?40?00?00?07?05?82?02?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?

21?20?00?00?00?00?07?00?35?00?34?00?5f?00?43?00?44?00?43?00?00?10?01?05?24?01?00?00?04?24?02?02?05?24?06?00?01?07?05?81?03?08?00?ff?09?04?01?00?02?0a?00?00?00?07?05?02?02?40?00?00?07?05?82?02?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00?00




你好,CH573模擬USB轉(zhuǎn)串口,具體問題點(diǎn)是什么?

不能正常使用嗎?如不能使用,請描述一下復(fù)現(xiàn)步驟和細(xì)節(jié)。

串口配置信息和上位機(jī)軟件的配置信息不一致?本工程不向上配置信息,只通過USB讀取上位機(jī)傳下來的串口配置信息。

可以如下修改 UINT8 LineCoding[7] = { 0x00};?



你好,遇到的問題是 上位機(jī)串口軟件的配置信息讀取不正確。項(xiàng)目需要知道當(dāng)前串口上位機(jī)軟件點(diǎn)配置信息,然后再配置CH573的串口信息(波特率 校驗(yàn)位 數(shù)據(jù)位 停止位)等等。但是通過SET_LINE_CODING這條指令讀取的上位機(jī)串口配置信息不對,請幫忙分析一下


獲取上位機(jī)PC串口調(diào)試助手的波特率等配置信息在標(biāo)簽獲取,case UIS_TOKEN_OUT :

PC SSCOM上設(shè)置115200,8位。會(huì)打印信息如下:

1619180033193573.png

代碼打印處如下:

1619180033146686.png



會(huì)打印兩次

? ? ? ? case UIS_TOKEN_OUT :

? ? ? ? ? len = R8_USB_RX_LEN;

? ? ? ? ? for(int i = 0; i < len; i++)

? ? ? ? ? {

? ? ? ? ? ? printf("%02x ", pEP0_DataBuf[i]);

? ? ? ? ? }

? ? ? ? ? printf("\r\n");


00 c2 01 00 00 00 00?


00 00 00 00 01 01 07?




00 c2 01 00 00 00 00?


00 00 00 00 01 01 07?


通過處理手段 解決好了


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频