LinuxQuestions.org
Help answer threads with 0 replies.
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-2010, 07:12 AM   #1
wybourn
LQ Newbie
 
Registered: Jul 2010
Posts: 14

Rep: Reputation: 0
Driver programming problem


I'm running Ubuntu 10.04 and I'm creating an usb device driver for a specialist device known as a motion controller.

Using a usb hardware packet sniffer I can see that the device can successfully write and read commands from the device, two main problems though.

In my read function, wait_for_completion just hangs, it never finishes. I managed to get round this using wait_for_completion_timeout which returns the correct result. What I don't understand is, if the driver is receiving a response why does program hang continually without a time-out.

Secondly, The driver only works once, ie I run my program which contains the commands and the write and read functions work fine and get a response. However if I run the program again I get no response from the device, I can write to it but not read. To get it working again I need to restart the device.

Does anyone have an idea what the problem could be?

(By the way its defiantly not a problem with the device, it already has a fully working windows driver and has undergone extensive testing).
 
Old 07-16-2010, 09:59 AM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,375

Rep: Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557
Quote:
Originally Posted by wybourn View Post
In my read function, wait_for_completion just hangs, it never finishes. I managed to get round this using wait_for_completion_timeout which returns the correct result. What I don't understand is, if the driver is receiving a response why does program hang continually without a time-out.
Not fully a programming head, but that's easy. Mark Twain once said:
"What gets us into trouble is not what we don't know;
It's what we know for sure, but just ain't so":-)
Whatever you are sure should be causing it to exit is not. Guessing wildly, it could be waiting for an EOF that isn't ever going to come.

Quote:
Originally Posted by wybourn View Post
Secondly, The driver only works once, ie I run my program which contains the commands and the write and read functions work fine and get a response. However if I run the program again I get no response from the device, I can write to it but not read. To get it working again I need to restart the device.
ReRead Mark Twain above. Guessing again, read/write modes or timing errors.
 
Old 07-19-2010, 01:26 AM   #3
wybourn
LQ Newbie
 
Registered: Jul 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you for your response. Unfortunately I haven't yet been able to figure out the problem, using the usb packet sniffer I can see that module in Linux and the driver in windows are sending out identical packets. Therefore the only thing I can thing of is a timing issue or read/write mode as you mentioned above. However this doesn't explain why the first time the program is run it works perfectly and then stops working after that.

I did however manage to pinpoint the error message location, its in urb.c line 226 if (!urb || urb->hcpriv || !urb->complete) return -EINVAL; in the function usb_sumbit_urb.

Also if anyone knows any forums more specific to low level Linux programming (i.e modules/drivers) I would be very grateful.
 
Old 07-20-2010, 03:39 AM   #4
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,375

Rep: Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557Reputation: 557
What's the cpu in the device? There are simulators out there. The once I went at that, I was using assembler with a pic, and there was a simulator just waiting to be used. I even caught a bug in it, and had it sorted by the time I was finished.

But you are into more forensic techniques in probing why poor software is that. I've been there, but without more knowledge of your circuitry, it is difficult to offer pointed advice.
 
  


Reply

Tags
usb


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
Driver programming , any help GSalah Programming 3 08-12-2006 11:14 PM
need some usb driver programming help glo Programming 3 10-27-2003 09:41 AM
Graphics Driver Programming XoSkely10 Programming 1 07-31-2002 02:26 PM
Linux Driver Programming prowzen General 6 06-05-2001 02:44 AM


All times are GMT -5. The time now is 07:08 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration