LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   USB: Connection timed out SYS: Connection timed out (https://www.linuxquestions.org/questions/programming-9/usb-connection-timed-out-sys-connection-timed-out-4175469823/)

PeterUK 07-16-2013 11:31 AM

USB: Connection timed out SYS: Connection timed out
 
Hi! I am trying to run an example where it send bulk data through the USB port as max device speed to test the link.

The chip is a Cypress FX2 (I dont think there is a problem firmware).
You can find the whole example here

He create this own version sdcc and used a function called Bench_bulk.

The Problem it looked like System is timing out, but I don't know how to really tell to wait until it has received all the data.

I run the command:
Code:

cycfx2prog prg:bench_in.ihx run bench_bulk:6,16777216
and I get:

Quote:

cycfx2prog prg:bench_in.ihx run bench_bulk:6,16777216
Using ID 04b4:8613 on 002.009.
Putting 8051 into reset.
Programming 8051 using "bench_in.ihx".
Putting 8051 out of reset.
Reading 65536 bytes from EP 0x86: USB: Connection timed out SYS: Connection timed out
The last line should be something like this:

Quote:

Read 16777216 bytes in 828 msec (chunk size 65536): 19.332 Mb/sec (256 calls, 65536 bytes/call)
Now the function without any modification from that website:

Quote:

else if(!strcmp(cmd,"bench_bulk"))
{
int ep=-1;
int len=1024*1024;
int cs=65536;

if(a[0] && *a[0]) { ep=strtol(a[0],NULL,0); }
if(a[1] && *a[1]) { len=strtol(a[1],NULL,0); }
if(a[2] && *a[2]) { cs=strtol(a[2],NULL,0); }
// If len<0, allow short reads.
if(ep<0 || ep>=127 || len<=0 || len>32*1024*1024 ||
cs<1 || cs>32*1024*1024)
{ fprintf(stderr,"Command bench_bulk: Illegal/missing "
"endpoint/length/number.\n"); ++errors; }
else
{
// IN endpoints have the bit 7 set.
ep|=0x80;

int rv=cycfx2.BenchBlockRead(ep,len,cs,'b');
errors += rv ? 1 : 0;
}
}
From other example it use stdin to non-blocking which I though may be the answer to:

Quote:

else if(!strcmp(cmd,"bench_bulk"))
{
int ep=-1;
int len=1024*1024;
int cs=65536;
/****************************
* Need to change stdin to non-blocking. */
int n, k;
n = fcntl(0,F_GETFL);
if(n<0) {
fprintf(stderr,"Trouble getting stdin flags\n");
n = 0;
}
n = fcntl(0,F_SETFL,n|O_NONBLOCK);
if(n<0) {
fprintf(stderr,"Trouble setting stdin flags\n");
n = 0;
}





if(a[0] && *a[0]) { ep=strtol(a[0],NULL,0); }
if(a[1] && *a[1]) { len=strtol(a[1],NULL,0); }
if(a[2] && *a[2]) { cs=strtol(a[2],NULL,0); }
// If len<0, allow short reads.
if(ep<0 || ep>=127 || len<=0 || len>32*1024*1024 ||
cs<1 || cs>32*1024*1024)
{ fprintf(stderr,"Command bench_bulk: Illegal/missing "
"endpoint/length/number.\n"); ++errors; }
else
{
// IN endpoints have the bit 7 set.
ep|=0x80;

int rv=cycfx2.BenchBlockRead(ep,len,cs,'b');
errors += rv ? 1 : 0;
}
}
But that does not work still timing it out, Thanks for you help.

PeterUK 07-16-2013 06:59 PM

UPDATE 2:

I am sorry if people read this and try to answer as I have some hardware issues here, now its doing bulk transfer:

Quote:

Read 16777216 bytes in 495 msec (chunk size 65536): 32.352 Mb/sec ( 256 calls, 65536 bytes/call)
As you see from before it only display 65536 read so those were bytes/call good indication something is wrong.

The clue came when I found the function to send data to the RAM through the USB and after increasing it was going nothing.

Here is the bit:

Quote:

usb_control_msg(usbhandle,0x40,0xa0,/*addr=*/dl_addr,0, /*buf=*/(char*)d,/*size=*/bs,/*timeout=*/1000/*msec*/);
I tried to port this library to C but it was going lot of error regarding variable types.

Now it give me a good question why go to create a library in C++ when nearly all is done in C?

And can you always translate C++ library into C one? Thanks

PeterUK 07-17-2013 06:15 PM

UPDATE 3:

I had time to spend a bit more with the code, but I have noticed that is C++ code stile but the files are .cc and its compiling with gcc, its possible use C++ using gcc compiler?

PeterUK 07-18-2013 02:59 AM

UPDATE 4:

I have got the answer from here and here

"
It depends on what exactly you changed in the makefile. gcc / g++ is really just a front-end driver program which invokes the actual compiler and / or linker based on the options you give it.

If you invoke the compiler as gcc:

it will compile as C or C++ based on the file extension (.c, or .cc / .cpp);
it will link as C, i.e. it will not pull in C++ libraries unless you specifically add additional arguments to do so.

If you invoke the compiler as g++:

it will compile as C++ regardless of whether or not the file extension is .c or .cc / .cpp;
it will link as C++, i.e. automatically pull in the standard C++ libraries."


All times are GMT -5. The time now is 04:45 AM.