完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
伙计们,
如何从RX端口获得字节长度? 谢谢 以上来自于百度翻译 以下为原文 Guys, How can I get byte_length from Rx port ? Thanks |
|
相关推荐
20个回答
|
|
可以在TX中写入字符串(多字节),但与RX不一样。
RX有一个只能容纳1字节信息的缓冲器,每次只能读取一个字节。 如果要获得字节计数,则必须继续读取缓冲区中的数据,每次读取一个字节。 你可以尝试一下: 而(UARTHARSTRACXSTATUS()和UARTHARXRXRGIGULL)//只要RX缓冲区中存在数据,就保持循环。 { 如果(UARTHI CRADARCHARE())RXCOUNT+++;//O-CREADCHAR从缓冲区读取一个字符,如果有错误或没有数据,则返回0 } 以上来自于百度翻译 以下为原文 It is possible to write a string of characters (multiple bytes) into a TX. But not the same with RX. The RX has a buffer that can hold only 1 byte of information, and can read only one byte at a time. If you want to get the byte count, you have to keep reading the data from the buffer, one byte at at time. You can give this a try: while (UART_bReadRxStatus() & UART_RX_REG_FULL)) // keeps looping as long as there is data in the RX buffer { if (UART_cReadChar()) RXcount++; //_cReadChar reads one character from buffer, returns 0 if there's an error or no data } |
|
|
|
我尝试这个,并返回一些字节,但不确定它是否正确。
(1){DU{UARTHAR1LCMDRESET();//RESET命令缓冲区为(i=0;i & lt;15;i++){UARTARY1LPTCCHAR(0x01);/ /发送字符到UART TX端口} Delay50uTimes(1);C=UARTARY1CGCHARCHER();}(C==0x01)//CHECK可使用的卡{LCDY-ClryLyn(0);LCDA ClryLyn(1);LCD1 1x位置(0,0);LCDY11PRCSTROM(“卡in”);UARTARY11CMDRESET();/复位命令缓冲器(i=0;I & lt;3;i++){UARTARY1LPTCCHAR(SELLARCARD[I]);/ /发送字符到UART TX端口}(!)UTARTHY1BCMDCHECK()){ByTeTyLange= UARTHAR11BCMDLIN();}为(i,lt;ByTeTyStand;I++){RxDATABUFF=UARTHAR1LCGCHARCHER();/ /从UART RX数据寄存器}获得LCD1 1x位置(1,0);LCDY11PrClSn(“Sn:”);(i=2;I & lt;6;I++){LCDY11PrHouthByter(RxDATABUFF);//检测到的卡的序列号} / /结束,如果0x01}//结束,同时}/ /结束主 以上来自于百度翻译 以下为原文 I try this one and returning some bytes, but not sure if it's right or not while(1) { do { UART_1_CmdReset(); // Reset Command Buffer for (i=0;i<15;i++) { UART_1_PutChar(0x01); // Send a character to UART TX port } Delay50uTimes(1); c = UART_1_cGetChar(); }while (c == 0); if (c == 0x01)//check the card available { LCD_clr_line(0); LCD_clr_line(1); LCD_1_Position(0,0); LCD_1_PrCString("Card in "); UART_1_CmdReset(); // Reset Command Buffer for (i=0;i<3;i++) { UART_1_PutChar(sel_card); // Send a character to UART TX port } if(!UART_1_bCmdCheck() ) { byte_length = UART_1_bCmdLength(); } for (i=0;i RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register } LCD_1_Position(1,0); LCD_1_PrCString("SN: "); for (i=2;i<6;i++) { LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected } }//end if 0x01 }//end while }//end main |
|
|
|
如何构思具有内容的RX缓冲区:
AB 04 01 01 04 ?? 以上来自于百度翻译 以下为原文 How can I detect Rx buffer with content : AB 04 01 04 00 ?? |
|
|
|
我要给命令终止符什么?我看不出RX的结局是什么??
这个参数选择一个命令结束的字符。当接收到一个标志时,设置一个标志,表示已经接收到一个完整的命令。在设置此标志之后,在调用CMDREST()函数之前,不接受其他字符。 以上来自于百度翻译 以下为原文 what shoud I put for command terminator ? I can't see what's the end of the Rx...??
|
|
|
|
我能做什么:
(i=0;i & lt;字节数;i++){rxDATABUFF=UARTHAR1LCGCHARCHER();/ /从UART RX数据寄存器}获得LCD1 1x位置(0,0)的字符;LCDY11PrClSn(“Sn:”);LCD1 1x位置(1,0);F或(i=0;i & lt;10;i++){LCDY11PrHouthByter(RxDATABUFF);//打印的卡序列号检测到} 以上来自于百度翻译 以下为原文 can I do : byte_length=UART_1_cGetChar(); for (i=0;i RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register } LCD_1_Position(0,0); LCD_1_PrCString("SN: "); LCD_1_Position(1,0); for (i=0;i<10;i++) { LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected } |
|
|
|
如果返回是:AB 04 01,04…00…命令终止符是什么?
00?? 以上来自于百度翻译 以下为原文 if the return is : AB 04 01 04 00 ......what's the command terminator ? 00 ?? |
|
|
|
而(UARTHARSTRACXSTATUS()和UARTHARXRXRGIGULL)//只要RX缓冲区中存在数据,就保持循环。
{ 如果(UARTHI CRADARCHARE())RXCOUNT+++;//O-CREADCHAR从缓冲区读取一个字符,如果有错误或没有数据,则返回0 } 这不是一个有效的工作代码…… 以上来自于百度翻译 以下为原文 while (UART_bReadRxStatus() & UART_RX_REG_FULL)) // keeps looping as long as there is data in the RX buffer { if (UART_cReadChar()) RXcount++; //_cReadChar reads one character from buffer, returns 0 if there's an error or no data } It's not a valid working code...... |
|
|
|
请看视频:
HTTP://S129 PosikButk.COM/USER/PICTHORES7/MIDA/RIDIDZPS0AEF3A5D.MP4.HTML 我用过: 字节长度= uARTHAR11CREADARCHARE(); 代码: (1){DU{UARTHAR1LCMDRESET();//RESET命令缓冲区为(i=0;i & lt;15;i++){UARTARY1LPTCCHAR(0x01);/ /发送字符到UART TX端口} Delay50uTimes(1);C=UARTARY1CGCHARCHER();}(C==0x01)//CHECK可使用的卡{LCDY-ClryLyn(0);LCDA ClryLyn(1);LCD1 1x位置(0,0);LCDY11PRCSTROM(“卡in”);UARTARY11CMDRESET();/复位命令缓冲器(i=0;i;lt;3;i++){UARTARY1LPTCCHAR(SELLARCARD[I]);/ /发送字符到UART TX端口}/*IF(!)UTARGY1BCMDCHECK()){ByTeTyLe= UARTARGY1BCMDLIN();}(i=0;i & lt;字节数;i++){rxDATABUFF=UARTHAR1LCGCHARCHER();/从UART RX数据寄存器}获得LCD1 1x位置(1,0)的字符;LCD1环(“Sn:”);(i=0;i;lt;4;i++){LCDy11PrUpHuffEnter(RxDATABUF);//检测到的卡的序列号} / /结束如果0x01否则if(C==0xFe){LCDY-ClryLin(0);LCDA ClryLin(1);LCD1 1x位置(1,0);LCDY11PRCSTROM(“无卡!”);} //结束0xFE}/ /结束,同时}/ /结束主 以上来自于百度翻译 以下为原文 Please have a look on the video : http://s129.photobucket.com/user/picture_77/media/RFID_zps0aef3a5d.mp4.html I used : byte_length = UART_1_cReadChar(); The code : while(1) { do { UART_1_CmdReset(); // Reset Command Buffer for (i=0;i<15;i++) { UART_1_PutChar(0x01); // Send a character to UART TX port } Delay50uTimes(1); c = UART_1_cGetChar(); }while (c == 0); if (c == 0x01)//check the card available { LCD_clr_line(0); LCD_clr_line(1); LCD_1_Position(0,0); LCD_1_PrCString("Card in "); UART_1_CmdReset(); // Reset Command Buffer for (i=0;i<3;i++) { UART_1_PutChar(sel_card); // Send a character to UART TX port } /* if(!UART_1_bCmdCheck() ) { byte_length = UART_1_bCmdLength(); } */ byte_length = UART_1_cReadChar(); for (i=0;i RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register } LCD_1_Position(1,0); LCD_1_PrCString("SN: "); for (i=0;i<4;i++) { LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected } }//end if 0x01 else if (c == 0xFE) { LCD_clr_line(0); LCD_clr_line(1); LCD_1_Position(1,0); LCD_1_PrCString("No Card! "); }//end 0xFE }//end while }//end main |
|
|
|
您需要启用命令缓冲区并定义命令终止符。
然后使用下面的代码,它应该工作 如果(!)UARTHARBCMDCHECK()){ BytEthLange= uARTHARBCMDLIMTHOST();} 以上来自于百度翻译 以下为原文 You need to enable the command buffer and define the command terminator. Then using the code below it should work if(!UART_bCmdCheck() ){ byte_length = UART_bCmdLength(); } Regards |
|
|
|
|
|
|
|
所以会是这样:
如果(!)UTARTH-BCMDCHECK()){BytEthLange= UARTHARBCMDLTENTHER();}为(i,lt;BytEthLead;i++){RxDATABUFF=UARTHAR1LCGCHARCHER();/ /从UART RX数据寄存器}获得LCD1 1x位置(0,0);LCD1 1PrClSnk(“Sn:”);LCD1 1x位置(1,0);(i=0;I & lt;10;I++){LCDY11PrHouthByter(RXDATABUFF);//检测到的卡的打印序列号} 以上来自于百度翻译 以下为原文 So it'll be like this : if(!UART_bCmdCheck() ){ byte_length = UART_bCmdLength(); } for (i=0;i RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register } LCD_1_Position(0,0); LCD_1_PrCString("SN: "); LCD_1_Position(1,0); for (i=0;i<10;i++) { LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected } |
|
|
|
在使用的协议中没有命令终止符,因此不能使用命令缓冲区。
以上来自于百度翻译 以下为原文 In the protocol you use there is no command terminator, so you can't use the command buffer. |
|
|
|
如何启用命令缓冲区并定义命令终止符?
你能给我举个例子吗?谢谢您 以上来自于百度翻译 以下为原文 How can I enable the command buffer and define the command terminator ? Can you give me example ? thank you |
|
|
|
用串口和RS232进行计算机测试
我发送AB 02 01,响应是AB 04 01 04 00。 但在柏树,我得到了不同的反应,不是AB 04,01,00……为什么会这样??????????????????????????????????? 以上来自于百度翻译 以下为原文 I tested with serial port and RS232 in computer I send AB 02 01 and the response is AB 04 01 04 00 but in cypress I get a different response it's not AB 04 01 04 00.....why is that ???????????????????????? |
|
|
|
我不能看到命令终止符,因为它是从设备……回复5到10字节。
我怎样才能创建它呢? 请找到我的手册,上面有“基本命令说明”。 谢谢 以上来自于百度翻译 以下为原文 I can't see command terminator since it's a reply from device......for 5 to 10 bytes. How can I create it ? Please find my manual attached, and it's on "Basic Command Description" Thanks a lot |
|
|
|
逻辑:
我给了设备命令,它在RX端口上用AB 04 01 04 04回答,我如何解析它,以便我能把它们显示到LCD中?谢谢您 以上来自于百度翻译 以下为原文 The logic : I gave command to device and it replied with AB 04 01 04 00 on Rx port, how can I parse it so I can display them into LCD ? thank you |
|
|
|
要启用命令缓冲区,您需要定义一个参数来启用。
你能重新附上手册吗? 答复必须以某种方式格式化,比如地址和数据字节加校验和或其他任何东西。如果应答序列总是以不同的值结束,那么在经过了预先定义的时间之后,从命令缓冲区检索数据。 当做 以上来自于百度翻译 以下为原文 To enable the command buffer, there is a parameter that you define to enable. Could you re-attached the manual? The reply must formatted in some way, like an address and a data byte plus a checksum or anything else. If the reply sequence always end with a different value then after a pre-difined time has elapsed retrieve the data from the command buffer. Regards |
|
|
|
您可以在UART用户模块参数窗口中定义命令终止符,并启用RX命令缓冲区选项。必须启用RX中断。
从数据表- 此参数允许接收命令缓冲区和用于命令处理的固件。必须为命令缓冲器启用UART RX中断操作。 RxBuffelStand此参数确定为接收缓冲区保留的RAM位置的数目。可以接收的最大命令是小于选定的缓冲区大小的命令,因为字符串必须为空终止。此参数仅在启用RxCmdBuffer和启用UART RX中断时有效。 这个参数选择一个命令结束的字符。当接收到一个标志时,设置一个标志,表示已经接收到一个完整的命令。在设置此标志之后,在调用CMDREST()函数之前,不接受其他字符。 确保输入流总是包含CMD终止符以获得计数。如果未接收到命令终止符,则在该代码中将不设置ByTeTyLoad。 如果(!)UARTHYBCMDCAMP() {BytEthLange= uARTHARBCMDLIMTHONE();} 另一个问题是RX CMD缓冲区有一个很大的限制(32或64字节,PLS检查)。 如果你想做的是在LCD上显示RX字符串,最好的解决办法是使用中断(每次收到一个字节就可以得到中断),并在LCD缓冲器上显示当前的LCD缓冲区。此外,使用RX状态标志来确定是否所有数据都已显示。 以上来自于百度翻译 以下为原文 You can define the command terminator in the UART user module parameters window, and enable the RX command buffer option. RX interrupts must be enabled. From the datasheet- RxCmdBuffer This parameter enables the receive command buffer and firmware used for command processing. The UART RX interrupt must be enabled for the command buffer to operate. RxBufferSize This parameter determines the number of RAM locations that are reserved for the receive buffer. The largest command that can be received is one less than the buffer size selected, because the string must be null terminated. This parameter is only valid when the RxCmdBuffer is enabled and the UART RX interrupt is enabled. CommandTerminator This parameter selects the character that signals the end of a command. When received, a flag is set signaling that a complete command has been received. After this flag is set, additional characters are not accepted until the cmdReset() function is called. Make sure the input stream always contains the cmd terminator to get the count. If the command terminator is not received, in this code, byte_length will not be set- if(!UART_bCmdCheck() ) { byte_length = UART_bCmdLength(); } The other issue is that the RX cmd buffer has a size limitation (32 or 64 bytes, pls check) If all you want to do is display the RX string on an LCD, the best solution is to use interrupts (you can get an interrupt every time one byte is received) and display the current byte in the RX buffer on LCD. Additionally use the RX status flags to determine if all data has been displayed. |
|
|
|
要启用命令缓冲区,您需要定义一个参数来启用。
你能重新附上手册吗? 答复必须以某种方式格式化,比如地址和数据字节加校验和或其他任何东西。如果应答序列总是以不同的值结束,那么在经过了预先定义的时间之后,从命令缓冲区检索数据。 当做 事业的发展 是的,我将再次附上手册。 如果你说的是校验和,从我在手册上读到它以后,对我来说更有意义,但是我还不知道如何使用它。 我需要检查回复(RX)的结尾,但是从我可以看到它总是在变化… 我可以打印出RX,但仍然是随机的。我想要的是IGIVE命令AB 02 01, 设备将回答AB 04 01 04 04,请参阅手册上的第5页。 1356MHZFRIDIDARMONALL1.ZIP 980 K 以上来自于百度翻译 以下为原文 To enable the command buffer, there is a parameter that you define to enable. Could you re-attached the manual? The reply must formatted in some way, like an address and a data byte plus a checksum or anything else. If the reply sequence always end with a different value then after a pre-difined time has elapsed retrieve the data from the command buffer. Regards ============== Yes sure, I'll attach the manual again. if you're talking about checksum, make more sense for me since I read about it on the manual but don't know how to use it yet. I need to check the end of the reply (Rx), but from I can see it's always changing..... I can print out Rx, but still random. What I want, is if I give command AB 02 01, device will reply AB 04 01 04 00, please see page 5 on the manual.
|
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2111 浏览 1 评论
1858 浏览 1 评论
3673 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1792 浏览 6 评论
1540 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
579浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
432浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
441浏览 2评论
391浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
972浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 06:45 , Processed in 2.020994 second(s), Total 113, Slave 97 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号