LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2013, 12:31 PM   #1
PeterUK
Member
 
Registered: May 2009
Posts: 281

Rep: Reputation: 16
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.
 
Old 07-16-2013, 07:59 PM   #2
PeterUK
Member
 
Registered: May 2009
Posts: 281

Original Poster
Rep: Reputation: 16
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

Last edited by PeterUK; 07-17-2013 at 08:44 PM.
 
Old 07-17-2013, 07:15 PM   #3
PeterUK
Member
 
Registered: May 2009
Posts: 281

Original Poster
Rep: Reputation: 16
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?
 
Old 07-18-2013, 03:59 AM   #4
PeterUK
Member
 
Registered: May 2009
Posts: 281

Original Poster
Rep: Reputation: 16
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."
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh: connection to host port: 22: Connection timed out lost connection cucolin@ Linux - Server 4 11-22-2011 07:15 AM
connection timed out cheers Red Hat 3 04-18-2011 07:33 AM
sendmail - Connection timed out [dsn=4.0.0 stat=Deferred: Connection timed out] ananthak Linux - Software 0 04-24-2007 08:28 AM
connection timed out. moby Linux - Networking 0 10-13-2004 08:45 AM
Connection timed out Valluvan Programming 6 12-22-2002 03:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration