Mercurial > hg > ucis.core
annotate USBLib/Communication/UsbInterface.cs @ 69:82290dc1403c
Fix crash in FBGUI renderer shutdown
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 16 Oct 2013 17:00:19 +0200 |
parents | 2d16447eff12 |
children |
rev | line source |
---|---|
21 | 1 ???using System; |
2 using System.Text; | |
3 using UCIS.USBLib.Descriptor; | |
4 | |
5 namespace UCIS.USBLib.Communication { | |
6 public abstract class UsbInterface : IUsbInterface { | |
7 public virtual byte Configuration { | |
8 get { | |
9 byte[] buf = new byte[1]; | |
67
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
10 int tl = ControlTransfer( |
21 | 11 UsbControlRequestType.EndpointIn | UsbControlRequestType.TypeStandard | UsbControlRequestType.RecipDevice, |
12 (byte)UsbStandardRequest.GetConfiguration, 0, 0, | |
13 buf, 0, buf.Length); | |
14 if (tl != buf.Length) throw new Exception("Read failed"); | |
15 return buf[0]; | |
16 } | |
17 set { | |
18 throw new NotImplementedException(); | |
19 } | |
20 } | |
21 public virtual int GetDescriptor(byte descriptorType, byte index, short langId, byte[] buffer, int offset, int length) { | |
67
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
22 return ControlTransfer( |
21 | 23 UsbControlRequestType.EndpointIn | UsbControlRequestType.RecipDevice | UsbControlRequestType.TypeStandard, |
24 (Byte)UsbStandardRequest.GetDescriptor, | |
25 (short)((descriptorType << 8) | index), langId, buffer, offset, length); | |
26 } | |
67
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
27 public virtual int ControlTransfer(UsbControlRequestType requestType, byte request, short value, short index) { |
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
28 return ControlTransfer(requestType, request, value, index, null, 0, 0); |
21 | 29 } |
30 | |
31 public abstract void Close(); | |
32 | |
67
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
33 public abstract int PipeTransfer(Byte endpoint, Byte[] buffer, int offset, int length); |
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
34 public virtual void PipeReset(Byte endpoint) { throw new NotImplementedException(); } |
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
35 public virtual void PipeAbort(Byte endpoint) { throw new NotImplementedException(); } |
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
36 public abstract int ControlTransfer(UsbControlRequestType requestType, byte request, short value, short index, byte[] buffer, int offset, int length); |
21 | 37 |
67
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
38 public virtual UsbPipeStream GetPipeStream(Byte endpoint) { |
2d16447eff12
Simplified USB communication code, added functions to abort pipe transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
65
diff
changeset
|
39 return new UsbPipeStream(this, endpoint); |
21 | 40 } |
41 | |
42 public void Dispose() { | |
43 Close(); | |
44 GC.SuppressFinalize(this); | |
45 } | |
46 ~UsbInterface() { | |
47 Close(); | |
48 } | |
49 } | |
50 } |