Ports
May 19, 2013, 02:06:05 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: [1]
  Print  
Author Topic: Exception thrown in C# Generic HID at fileStreamDeviceData.write  (Read 1155 times)
mihooper
Member
***
Posts: 19


« on: April 28, 2012, 11:57:04 am »

I am attempting to use Generic HID to talk to my TI MSP board. I can find the device, but an exception is thrown here:
Code:
private void ExchangeInputAndOutputReports()
....
fileStreamDeviceData.Write(outputReportBuffer, 0, outputReportBuffer.Length);
The exception says:
Quote
System.IO.IOException was caught
  Message=IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations.
  Source=mscorlib
  StackTrace:
       at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
       at GenericHid.FrmMain.ExchangeInputAndOutputReports() in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\FrmMain.cs:line 1256
  InnerException:

I am fairly new to all of this. Can anyone offer a suggestion on what could be happening?

Thx,

MikeH

« Last Edit: April 28, 2012, 11:58:55 am by mihooper » Logged

Thx,
MikeH
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #1 on: April 28, 2012, 12:20:07 pm »

Does your device have a a HID OUT report that matches the length of the data you're trying to send?

Jan
Logged
mihooper
Member
***
Posts: 19


« Reply #2 on: April 28, 2012, 01:11:28 pm »

Jan,

Yes, it does.
Quote
MyHid.Capabilities.InputReportByteLength = 0x0040
MyHid.Capabilities.OutputReportByteLength = 0x0040
Very confusing. I consistently get this exception. I have stepped through each line of code and all looks OK. Weird.
« Last Edit: April 28, 2012, 01:19:26 pm by mihooper » Logged

Thx,
MikeH
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #3 on: April 29, 2012, 09:33:31 am »

I don't know the reason why you're seeing this or why the error message refers to WriteCore instead of Write:

System.IO.FileStream.WriteCore

You could try my version that uses Writefile:

http://www.lvr.com/hidpage.htm#MyExampleCode

or search on the error message for clues.

Jan
Logged
mihooper
Member
***
Posts: 19


« Reply #4 on: April 30, 2012, 05:47:39 am »

Jan,

Your example code seems to work (generic_hid_cs_46). Thanks for responding.
Logged

Thx,
MikeH
mihooper
Member
***
Posts: 19


« Reply #5 on: April 30, 2012, 08:31:15 am »

Mystery solved....(sort of).

My HID device requires a ReportID = 63. The your generic_HID code inserts ReportID = 0. This apparently caused the exception to be thrown. After changing the ReportID to 63, all is working properly!

Thanks again!
Logged

Thx,
MikeH
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #6 on: April 30, 2012, 01:33:00 pm »

Glad you got it working.

If the HID has no more than 1 report of each type (Input, Output, Feature), it should use report ID zero.

Jan
 
Logged
mihooper
Member
***
Posts: 19


« Reply #7 on: April 30, 2012, 02:13:53 pm »

Jan,

I am using the TI MSP430 "datapipe" HID. It is a special HID that does not require a custom driver on the PC, but allows you to pass 64 bytes of data. I'm still learning about how it all works, but I noticed in the TI demo app that ReportID must be set fo 63 for the USB transactions to work.

FYI, TI's documentation on USB and HID is very good. It is well written and comprehensive. If folks are looking for a good USB solution, I recommend taking a look at the MSP430 product family. I am using the MSP430529 eval board http://www.ti.com/tool/msp-exp430f5529.

Logged

Thx,
MikeH
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!