Discussion Forum

hang while USB receive

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Tushaar Jain
Posted
8-Jul-2009 12:10 GMT
Toolset
ARM
New! hang while USB receive

Hi to all the members. I have been very impressed by the members answers which encourages me to post my query first time. Good job.

I am trying to communicate between the USB and the device STM32. I have configured the packet size to 64 both receive and sent.

I am transmitting the packet from the PC to board (packet length > 64). In this I got success by receieving the 64 packet each time with termination condition ";" at the end.

Now I also want to transmit a packet gretaer than 64 to PC. but everytime the communication hangs.

the code is pasted below. hope it helps

Board code:
printf("%s\n\r",OutReport);
if((OutReport[0]=='!') || (OutReport[0]=='K'))
{ while(count_buffer > 0)
{ if(OutReport[0]=='K')
{ for(i=0;i<64;i++)
{ tempINbuffer[i] = OutputBuffer[init];
init++;
} sprintf(InReport,"%s",tempINbuffer);
printf("\n\rInreport: %s",InReport);
init = init + 1;
count_buffer = count_buffer - 64;
OutReport[0]='S';
} }
} OutputBuffer contains a data greater than 64 characters.

Visual Basic 6 code:
Usb_Tx = "K;"
Call WriteReport
Usb_Rx_temp = ""
receive_flag = 1
While receive_flag <> 1
Call ReadReport
Usb_Rx_temp = Usb_Rx_temp & Usb_Rx
receive_buff = VBA.StrConv(Usb_Rx, vbFromUnicode)
For i = 0 To 63
If receive_buff(i) = 59 Then
receive_flag = 1 MsgBox receive_buff(i)
End If
Next Usb_Tx = "K;"
Call WriteReport
Wend
Text1.Text = Usb_Rx_temp

I apologise for the formatting as this message box doesnt support formatting.

Thanks for your time.

Read-Only
Author
Per Westermark
Posted
8-Jul-2009 12:23 GMT
Toolset
ARM
New! RE: hang while USB receive

The message box do support formatting as in:

#include <stdio.h>
int main(void) {
    printf("Hello world!\n");
    return 0;
}

Seems that you posted quite little code. Hardly any code at all, and no links to any code you based your project on.

Read-Only
Author
Andy Neil
Posted
8-Jul-2009 12:59 GMT
Toolset
None
New! RE: this message box doesnt support formatting

yes it does - and it also gives clear instructions on how to do it:

http://www.danlhenry.com/caps/keil_code.png

And see the link, Tips for posting messages...

Read-Only
Author
Tushaar Jain
Posted
8-Jul-2009 13:02 GMT
Toolset
None
New! RE: this message box doesnt support formatting

thanks for your suggestions. I will take care of this thing in future.

I have made myself the code working. Its working now.

Next Thread | Thread List | Previous Thread Start a Thread | Settings