├── .gitmodules
├── MSVC
├── .gitattributes
├── .gitignore
├── MSVC.sln
├── MSVC.vcxproj.filters
├── benchmark.vcxproj
├── listdev.vcxproj
└── transmit.vcxproj
├── PL25A1 Build and Install Modified Kernel Driver for Ubuntu.pdf
├── PL25A1 SDK Integration Guide.pdf
├── Source
├── Makefile
├── Readme.txt
├── benchmark.cpp
├── libusb.h
├── listdev.cpp
├── pl25a1.h
├── plusb.c
├── signing_key.pem
├── signing_key.x509
└── transmit.cpp
└── Xcode
├── .gitignore
├── PL25A1
└── PL25A1.xcodeproj
│ └── project.pbxproj
└── Xcode.xcworkspace
├── contents.xcworkspacedata
└── xcshareddata
└── Xcode.xcscmblueprint
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "libusb"]
2 | path = libusb
3 | url = https://github.com/libusb/libusb.git
4 |
--------------------------------------------------------------------------------
/MSVC/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/MSVC/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/MSVC/MSVC.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "..\Libusb\msvc\libusb_static_2015.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdev", "listdev.vcxproj", "{E5187AD3-E001-491B-B4EC-C513176085BF}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "transmit", "transmit.vcxproj", "{11B3816C-4A36-4901-8524-0B86E1C89A5A}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{FA934DDC-84C2-413E-A6C6-5409B7506E30}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|x64 = Debug|x64
17 | Debug|x86 = Debug|x86
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
23 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
24 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x86.ActiveCfg = Debug|Win32
25 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x86.Build.0 = Debug|Win32
26 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
27 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
28 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x86.ActiveCfg = Release|Win32
29 | {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x86.Build.0 = Release|Win32
30 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Debug|x64.ActiveCfg = Debug|x64
31 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Debug|x64.Build.0 = Debug|x64
32 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Debug|x86.ActiveCfg = Debug|Win32
33 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Debug|x86.Build.0 = Debug|Win32
34 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Release|x64.ActiveCfg = Release|x64
35 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Release|x64.Build.0 = Release|x64
36 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Release|x86.ActiveCfg = Release|Win32
37 | {E5187AD3-E001-491B-B4EC-C513176085BF}.Release|x86.Build.0 = Release|Win32
38 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Debug|x64.ActiveCfg = Debug|x64
39 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Debug|x64.Build.0 = Debug|x64
40 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Debug|x86.ActiveCfg = Debug|Win32
41 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Debug|x86.Build.0 = Debug|Win32
42 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Release|x64.ActiveCfg = Release|x64
43 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Release|x64.Build.0 = Release|x64
44 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Release|x86.ActiveCfg = Release|Win32
45 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}.Release|x86.Build.0 = Release|Win32
46 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Debug|x64.ActiveCfg = Debug|x64
47 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Debug|x64.Build.0 = Debug|x64
48 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Debug|x86.ActiveCfg = Debug|Win32
49 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Debug|x86.Build.0 = Debug|Win32
50 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Release|x64.ActiveCfg = Release|x64
51 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Release|x64.Build.0 = Release|x64
52 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Release|x86.ActiveCfg = Release|Win32
53 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}.Release|x86.Build.0 = Release|Win32
54 | EndGlobalSection
55 | GlobalSection(SolutionProperties) = preSolution
56 | HideSolutionNode = FALSE
57 | EndGlobalSection
58 | EndGlobal
59 |
--------------------------------------------------------------------------------
/MSVC/MSVC.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MSVC/benchmark.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {FA934DDC-84C2-413E-A6C6-5409B7506E30}
23 | MSVC
24 | 8.1
25 | benchmark
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | MultiByte
40 |
41 |
42 | Application
43 | true
44 | v140
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | $(Configuration)\$(ProjectName)\T
75 |
76 |
77 | $(Configuration)\$(ProjectName)\
78 | $(SolutionDir)$(Configuration)\
79 |
80 |
81 |
82 | Level3
83 | Disabled
84 |
85 |
86 | $(SolutionDir)..\Libusb\libusb\;%(AdditionalIncludeDirectories)
87 | ProgramDatabase
88 |
89 |
90 | true
91 | Console
92 | true
93 |
94 |
95 |
96 |
97 | Level3
98 | Disabled
99 | true
100 |
101 |
102 |
103 |
104 | Level3
105 | MaxSpeed
106 | true
107 | true
108 | true
109 |
110 |
111 | true
112 | true
113 |
114 |
115 |
116 |
117 | Level3
118 | MaxSpeed
119 | true
120 | true
121 | true
122 |
123 |
124 | true
125 | true
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | {349ee8f9-7d25-4909-aaf5-ff3fade72187}
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/MSVC/listdev.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {E5187AD3-E001-491B-B4EC-C513176085BF}
23 | MSVC
24 | 8.1
25 | listdev
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | MultiByte
40 |
41 |
42 | Application
43 | true
44 | v140
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | $(Configuration)\$(ProjectName)\
75 |
76 |
77 | $(SolutionDir)$(Configuration)\
78 | $(Configuration)\$(ProjectName)\
79 |
80 |
81 |
82 | Level3
83 | Disabled
84 |
85 |
86 | $(SolutionDir)..\Libusb\libusb\;%(AdditionalIncludeDirectories)
87 | ProgramDatabase
88 |
89 |
90 | true
91 | Console
92 | true
93 |
94 |
95 |
96 |
97 | Level3
98 | Disabled
99 | true
100 |
101 |
102 |
103 |
104 | Level3
105 | MaxSpeed
106 | true
107 | true
108 | true
109 |
110 |
111 | true
112 | true
113 |
114 |
115 |
116 |
117 | Level3
118 | MaxSpeed
119 | true
120 | true
121 | true
122 |
123 |
124 | true
125 | true
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 | {349ee8f9-7d25-4909-aaf5-ff3fade72187}
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/MSVC/transmit.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {11B3816C-4A36-4901-8524-0B86E1C89A5A}
23 | MSVC
24 | 8.1
25 | transmit
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | MultiByte
40 |
41 |
42 | Application
43 | true
44 | v140
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | $(Configuration)\$(ProjectName)\
75 |
76 |
77 | $(SolutionDir)$(Configuration)\
78 | $(Configuration)\$(ProjectName)\
79 |
80 |
81 |
82 | Level3
83 | Disabled
84 |
85 |
86 | $(SolutionDir)..\Libusb\libusb\;%(AdditionalIncludeDirectories)
87 | ProgramDatabase
88 |
89 |
90 | true
91 | Console
92 | true
93 |
94 |
95 |
96 |
97 | Level3
98 | Disabled
99 | true
100 |
101 |
102 |
103 |
104 | Level3
105 | MaxSpeed
106 | true
107 | true
108 | true
109 |
110 |
111 | true
112 | true
113 |
114 |
115 |
116 |
117 | Level3
118 | MaxSpeed
119 | true
120 | true
121 | true
122 |
123 |
124 | true
125 | true
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | {349ee8f9-7d25-4909-aaf5-ff3fade72187}
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/PL25A1 Build and Install Modified Kernel Driver for Ubuntu.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProlificCom/PL25A1_Libusb_SDK/fd621892a4c608501ab690f9f7d473bd1771d512/PL25A1 Build and Install Modified Kernel Driver for Ubuntu.pdf
--------------------------------------------------------------------------------
/PL25A1 SDK Integration Guide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProlificCom/PL25A1_Libusb_SDK/fd621892a4c608501ab690f9f7d473bd1771d512/PL25A1 SDK Integration Guide.pdf
--------------------------------------------------------------------------------
/Source/Makefile:
--------------------------------------------------------------------------------
1 | CC=g++
2 |
3 | All: transmit benchmark listdev
4 |
5 | transmit: transmit.cpp
6 | $(CC) transmit.cpp -lusb-1.0 -lpthread -o $@
7 |
8 | benchmark: benchmark.cpp
9 | $(CC) benchmark.cpp -lusb-1.0 -lpthread -o $@
10 |
11 | listdev: listdev.cpp
12 | $(CC) listdev.cpp -lusb-1.0 -o $@
13 |
14 | clean:
15 | rm -f transmit
16 | rm -f benchmark
17 | rm -f listdev
18 | rm -f *.o
19 |
--------------------------------------------------------------------------------
/Source/Readme.txt:
--------------------------------------------------------------------------------
1 | Introduction
2 | This software package includes the following components:
3 | 1. listdev
4 | A sample program to list PL25A1 device and show its information
5 | 2. transmit
6 | A simplified program to transmit data from sender to receiver
7 | 3. data_transfer_example
8 | A sample program to transfer data through two PL25A1 USB devices
9 |
10 | Test/Build Environment
11 | Ubuntu 14.04 x64 and Ubuntu 16.04 x64
12 |
13 | Installation/Build
14 | Follow the below steps to install the latest libusb and build all sample programs:
15 | 1. Install all necessary packages – libudev-dev
16 | a. Download the latest package lists from the repositories by typing “sudo apt-get update” in the command line
17 | b. Install “libudev-dev” by typing “sudo apt-get install libudev-dev” in the command line
18 | 2. Build and install the libusb
19 | packed in the SDK
20 | a. Extract libusb-1.0.20.tar.bz2 to the directory “libusb”
21 | b. Change directory to “libusb”
22 | c. Run “./configure”
23 | to configure the build environment
24 | d. Run “make” to build the library
25 | e. Run “sudo make install” to install it
26 | on the system
27 | 3. Build the sample programs
28 | a. Change directory to “PL25A1 for Linux”
29 | b. Run “make” to build all programs, and then “listdev”, “transmit”, and “data_transfer_example” will be created
30 |
31 | Execution
32 | listdev
33 | Perform the below steps to run the sample program “listdev”:
34 | 1. Connect both sides of PL25A1 USB cable to two PCs running Ubuntu OS.
35 | 2. On any Ubuntu system, execute the following command
36 | sudo ./listdev
37 | After that, the program lists found PL25A1 device and show its information.
38 | transmit
39 | Perform the below steps to run the sample program “transmit”:
40 | 1. Connect both sides of PL25A1 USB cable to two PCs running Ubuntu OS. One is called Ubuntu A, and another is called Ubuntu B.
41 | 2. On Ubuntu A, execute the following command
42 | sudo ./transmit recv
43 | 3. On Ubuntu B, execute the following command
44 | sudo ./transmit send
45 | After that, the sender program transmit data to the receiver program.
46 | data_transfer_example
47 | Perform the below steps to run the sample program “data_transfer_example”:
48 | 1. Connect both sides of PL25A1 USB cable to two PCs running Ubuntu OS. One is called Ubuntu A, and another is called Ubuntu B.
49 | 2. On Ubuntu A, execute the following command
50 | sudo ./data_transfer_example recv
51 | 3. On Ubuntu B, execute the following command
52 | sudo ./data_transfer_example send
53 | After that, the sender program transmit data to the receiver program.
54 |
--------------------------------------------------------------------------------
/Source/benchmark.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // benchmark.cpp
3 | // Performance benchmark program
4 | //
5 | // Created by software team in Prolific on 3/13/2017.
6 | // Copyright (c) 2017 Prolific Corp.. All rights reserved.
7 | //
8 | #include
9 | #include
10 | #include
11 | #include "libusb.h"
12 | #include "pl25a1.h"
13 | #if !defined(_WIN32)
14 | #include
15 | #include
16 | #include
17 | #if defined(__linux__)
18 | #include
19 | #elif defined(__APPLE__)
20 | #include
21 | #endif
22 | #endif
23 |
24 | static int gProgRole = PROGRAM_ROLE_UNKNOWN; /* The role which this program play */
25 | static bool gkilled = false; /* Be true to kill the thread and then exit this program */
26 | static int g_bulk_interface_no = 0; /* The interface No. you wish to claim */
27 | #define DATA_TRANSFER_SIZE (512 * 2 * 1024) /* 1 MB bytes for each transfer round */
28 | #define TRANSFER_ROUND_NO 50 /* The number of rounds sender will transmit */
29 |
30 | /*
31 | The called function when the process gets the specified signal(s)
32 | */
33 | static void signal_handler(int signum)
34 | {
35 | gkilled = true;
36 | }
37 |
38 | /*
39 | The receiver thread for receiving data
40 | */
41 | void* receiver_task(void *param)
42 | {
43 | int return_code; // Return value of each Prolific API
44 | unsigned char *recvBuf = (unsigned char *)malloc(sizeof(char) * DATA_TRANSFER_SIZE); // Buffer for receiving data
45 | int transferred_size = 0; // Received data in bytes
46 | unsigned int transferred_total_size = 0; // Total received data in bytes
47 | struct libusb_device_handle **dev_handle = (struct libusb_device_handle **)param; /* Structure of
48 | the opened PL25A1 device handle */
49 |
50 | printf("Flush Endpoint IN FIFO first\n");
51 | return_code = libusb_bulk_transfer(
52 | *dev_handle,
53 | BULK_USB2_EP1_IN_ADDR,
54 | recvBuf,
55 | BULK_USB2_EP1_FIFO_SIZE,
56 | &transferred_size,
57 | BULK_USB2_TIMEOUT
58 | );
59 |
60 | printf("Start to receive the data\n");
61 | // This tread continuously receive data from the sender
62 | while (!gkilled) {
63 | transferred_size = 0;
64 |
65 | // Perform a USB bulk transfer
66 | return_code = libusb_bulk_transfer(
67 | *dev_handle,
68 | BULK_USB2_EP1_IN_ADDR,
69 | recvBuf,
70 | DATA_TRANSFER_SIZE,
71 | &transferred_size,
72 | BULK_USB2_TIMEOUT
73 | );
74 |
75 | transferred_total_size += transferred_size;
76 |
77 | if (return_code == LIBUSB_ERROR_TIMEOUT) {
78 | // libusb keep return LIBUSB_ERROR_TIMEOUT if no data were be received, and this thread
79 | // keep trying to receive any one
80 | continue;
81 | } else if (return_code != LIBUSB_SUCCESS) {
82 | // Error occurs except LIBUSB_ERROR_TIMEOUT
83 | printf("Fail receiving data from bulk, return_code = %d\n", return_code);
84 | break;
85 | }
86 | printf("Total received size = %u\n", transferred_total_size);
87 | }
88 |
89 | free(recvBuf);
90 | return NULL;
91 | }
92 |
93 | /*
94 | The sender thread for sending data
95 | */
96 | void* sender_task(void *param)
97 | {
98 | int i; // Index for a loop
99 | int return_code; // Return value of each Prolific API
100 | unsigned char *sendBuf = (unsigned char *)malloc(sizeof(char) * DATA_TRANSFER_SIZE); // Buffer for sending data
101 | int transferred_size = 0; // Sent data in bytes
102 | unsigned int transferred_total_size = 0; // Total sent data in bytes
103 | struct libusb_device_handle **dev_handle = (struct libusb_device_handle **)param; /* Structure of
104 | the opened PL25A1 device handle */
105 | #if defined(_WIN32)
106 | DWORD64 start_time;
107 | DWORD64 end_time;
108 | #elif defined(__linux__)
109 | struct timespec start_time, end_time, diff_time;
110 | double elapsed_time;
111 | #elif defined(__APPLE__)
112 | uint64_t start_time;
113 | uint64_t end_time;
114 | uint64_t diff_time;
115 | mach_timebase_info_data_t info;
116 | #endif
117 | // Create the data pattern "sendBuf" to be sent to the receiver
118 | for (i = 0; i < DATA_TRANSFER_SIZE; i++) {
119 | sendBuf[i] = i % 0x100;
120 | }
121 |
122 | printf("Start to send the data\n");
123 | #if defined(_WIN32)
124 | start_time = GetTickCount();
125 | #elif defined(__linux__)
126 | clock_gettime(CLOCK_REALTIME, &start_time);
127 | #elif defined(__APPLE__)
128 | mach_timebase_info(&info);
129 | start_time = mach_absolute_time();
130 | #endif
131 |
132 | // This thread send test pattern TRANSFER_ROUND_NO times
133 | for (i = 0; i < TRANSFER_ROUND_NO && !gkilled; i++) {
134 | transferred_size = 0;
135 |
136 | // Send the data to the sender
137 | return_code = libusb_bulk_transfer (
138 | *dev_handle,
139 | BULK_USB2_EP1_OUT_ADDR,
140 | sendBuf,
141 | DATA_TRANSFER_SIZE,
142 | &transferred_size,
143 | BULK_USB2_TIMEOUT
144 | );
145 | transferred_total_size += transferred_size;
146 |
147 | if (return_code != LIBUSB_SUCCESS) {
148 | printf("Failed writing data to bulk, return_code = %d\n", return_code);
149 | break;
150 | }
151 | }
152 |
153 | // Show benchmark results
154 | #if defined(_WIN32)
155 | end_time = GetTickCount();
156 |
157 | DOUBLE performance = ((DOUBLE)DATA_TRANSFER_SIZE * TRANSFER_ROUND_NO * 1000) / (end_time - start_time) / 1024;
158 | printf("Transferred total size = %u bytes\n", transferred_total_size);
159 | printf("TickCount = %lld ms\n", end_time - start_time);
160 | printf("Performance = %.2lf KB/s\n", performance);
161 | #elif defined(__linux__)
162 | clock_gettime(CLOCK_REALTIME, &end_time);
163 |
164 | if (end_time.tv_nsec - start_time.tv_nsec < 0)
165 | {
166 | diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec - 1;
167 | diff_time.tv_nsec = 1000000000L + end_time.tv_nsec - start_time.tv_nsec;
168 | }
169 | else
170 | {
171 | diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec;
172 | diff_time.tv_nsec = end_time.tv_nsec - start_time.tv_nsec;
173 | }
174 | elapsed_time = (double)diff_time.tv_sec + (double)(diff_time.tv_nsec) / 1000000000L;
175 | // printf("DiffTime = %ld %ld\n", diffTime.tv_sec, diffTime.tv_nsec);
176 | printf("Transferred %u bytes\n", transferred_total_size);
177 | printf("Elapsed Time = %.2lf sec\n", elapsed_time);
178 | printf("Performance = %.2lf KB/s\n", (double)transferred_total_size / elapsed_time / 1024);
179 | #elif defined(__APPLE__)
180 | end_time = mach_absolute_time();
181 | diff_time = end_time - start_time;
182 | diff_time *= info.numer;
183 | diff_time /= info.denom;
184 | printf("Transferred %u bytes\n", transferred_total_size);
185 | printf("Elapsed Time = %.2lf sec\n", (double)diff_time / 1000000000);
186 | printf("Performance = %.2lf KB/s\n", (double)transferred_total_size / ((double)diff_time / 1000000000) / 1024);
187 | #endif
188 |
189 | free(sendBuf);
190 | return NULL;
191 | }
192 |
193 | /*
194 | Main routine
195 | */
196 | int main(int argc, char* argv[])
197 | {
198 | bool found_PL25A1_device = false; // TRUE means PL25A1 was found
199 | int i = 0; // Indexes for the loops
200 | libusb_device **devices; // Structures representing all USB device detected on the system
201 | libusb_device *device; // Structure representing one USB device detected on the system
202 | int return_code = 0; // Return value from each libusb API
203 | ssize_t no_of_devices; // The number of devices in the device list
204 | #if !defined(_WIN32)
205 | pthread_t thread; // For thread creation
206 | #endif
207 | struct libusb_device_descriptor device_descriptor; // structure represents the standard USB device descriptor
208 | struct libusb_config_descriptor *config_desc = NULL; // Structure represents the standard USB configuration descriptor
209 | struct libusb_device_handle *dev_handle = NULL; /* Structure represents the handles on a USB device */
210 |
211 | // Check command parameters and Initialize the transmission
212 | if (argc != 2) {
213 | printf("Usage:\n\t%s [send/recv]\n", argv[0]);
214 | // gProgRole = PROGRAM_ROLE_SENDER; // For debug only
215 | return PL_ERROR_WRONG_PARA;
216 | } else if (strcmp(argv[1], "send") == 0) {
217 | gProgRole = PROGRAM_ROLE_SENDER;
218 | } else if (strcmp(argv[1], "recv") == 0) {
219 | gProgRole = PROGRAM_ROLE_RECEIVER;
220 | } else {
221 | printf("Usage:\n\t%s [send/recv]\n", argv[0]);
222 | return PL_ERROR_WRONG_PARA;
223 | }
224 |
225 | // Register the signals to exit the program
226 | signal(SIGINT, signal_handler);
227 | #if !defined(_WIN32)
228 | signal(SIGKILL, signal_handler);
229 | signal(SIGQUIT, signal_handler);
230 | signal(SIGSTOP, signal_handler);
231 | #endif
232 | signal(SIGILL, signal_handler);
233 |
234 | // Initialize libusb
235 | return_code = libusb_init(NULL);
236 | if (return_code < LIBUSB_SUCCESS)
237 | return return_code;
238 |
239 | // Returns a list of USB devices currently attached to the system
240 | no_of_devices = libusb_get_device_list(NULL, &devices);
241 | if (no_of_devices < 1)
242 | return PL_ERROR_WRONG_DEVICE_NO;
243 |
244 | // printf("Found the folowing devices\n");
245 | while((device = devices[i++]) != NULL) {
246 | return_code = libusb_get_device_descriptor(device, &device_descriptor);
247 | if(return_code < 0) {
248 | fprintf(stderr, "Failed to get device descriptor");
249 | return return_code;
250 | }
251 |
252 | // Find PL25A1 USB device
253 | if((PROLIFIC_VID == device_descriptor.idVendor) && (PL25A1_PID == device_descriptor.idProduct)) {
254 | found_PL25A1_device = true;
255 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
256 | printf("Found PL25A1 USB device!\n");
257 |
258 | // Open a device and obtain a device handle
259 | return_code = libusb_open(device, &dev_handle);
260 | if(return_code < 0) {
261 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
262 | libusb_close(dev_handle);
263 |
264 | return return_code;
265 | }
266 |
267 | #if defined(__APPLE__)
268 | // Get a USB configuration descriptor based on its index
269 | return_code = libusb_get_config_descriptor(device, 0, &config_desc);
270 | #else
271 | // Get the USB configuration descriptor for the currently active configuration
272 | return_code = libusb_get_active_config_descriptor(device, &config_desc);
273 | #endif
274 | if(return_code != 0) {
275 | // Close a device handle
276 | libusb_close(dev_handle);
277 | continue;
278 | }
279 | DEBUG("(%s, %s(), L%d) config_desc->bNumInterfaces = %d\n",
280 | __FILE__, __FUNCTION__, __LINE__, config_desc->bNumInterfaces);
281 | }
282 | }
283 |
284 | // Check whether any PL25A1 USB device was found
285 | if(!found_PL25A1_device)
286 | {
287 | printf("No PL25A1 USB device was found!\n");
288 | return PL_ERROR_NO_DEVICE;
289 | }
290 |
291 | #if !defined(_WIN32)
292 | // Check whether a kernel driver is attached to interface #0. If so, it need to be detached
293 | if(libusb_kernel_driver_active(dev_handle, g_bulk_interface_no))
294 | {
295 | return_code = libusb_detach_kernel_driver(dev_handle, g_bulk_interface_no);
296 | DEBUG("(%s, %s(), L%d) return_code = %d\n", __FILE__, __FUNCTION__, __LINE__, return_code);
297 | }
298 | #endif
299 |
300 | // Claim an interface on a given device handle
301 | return_code = libusb_claim_interface(dev_handle, g_bulk_interface_no);
302 | DEBUG("(%s, %s(), L%d) return_code = %d\n", __FILE__, __FUNCTION__, __LINE__, return_code);
303 |
304 | // Check local and remote device statuses
305 | DEV_STATUS dev_status;
306 | memset((void *)&dev_status, 0xFF, sizeof(DEV_STATUS));
307 | while (1)
308 | {
309 | // Get device statuses from vendor command
310 | return_code = VENDOR_SPECIFIC_REQ_GET_STATUS(dev_handle, (unsigned char *)&dev_status);
311 | if (return_code < DEVICE_STATUS_LEN)
312 | {
313 | printf("Fail to get PL25A1 USB device status!\n");
314 | return PL_ERROR_WRONG_STATUS;
315 | }
316 | printf("Local device status: %s, %s\n", dev_status.localSuspend ? "Suspend" : "Active",
317 | dev_status.localUnplug ? "Unplug" : "Attached");
318 | printf("Remote device status: %s, %s\n", dev_status.RemoteSuspend ? "Suspend" : "Active",
319 | dev_status.RemoteUnplug ? "Unplug" : "Attached");
320 | // Break the loop when the remote device was attached
321 | if (!dev_status.RemoteUnplug)
322 | break;
323 | #if !defined(_WIN32)
324 | usleep(SLEEP_TIME);
325 | #else
326 | Sleep(SLEEP_TIME);
327 | #endif
328 | }
329 |
330 | #if defined(_WIN32)
331 | // Run sender or receiver for data transfer
332 | if (gProgRole == PROGRAM_ROLE_RECEIVER) {
333 | // Run receiver's function
334 | receiver_task((void*)&dev_handle);
335 | }
336 | else if (gProgRole == PROGRAM_ROLE_SENDER) {
337 | // Run sender's function
338 | sender_task((void*)&dev_handle);
339 | }
340 | #else
341 | // Create one sender and one receiver for data transfer
342 | if (gProgRole == PROGRAM_ROLE_RECEIVER) {
343 | // Create a thread to run sender's task.
344 | return_code = pthread_create(&thread, NULL, receiver_task, (void*) &dev_handle);
345 | if (return_code != 0) {
346 | printf("Unable to create sender thread.\n");
347 | return -1;
348 | }
349 |
350 | pthread_join(thread, NULL);
351 |
352 | } else if (gProgRole == PROGRAM_ROLE_SENDER) {
353 | // Create a thread to run receiver's task.
354 | return_code = pthread_create(&thread, NULL, sender_task, (void*) &dev_handle);
355 | if (return_code != 0) {
356 | printf("Unable to create receiver thread.\n");
357 | return -1;
358 | }
359 |
360 | pthread_join(thread, NULL);
361 | }
362 | #endif
363 | // Frees a list of devices previously discovered using libusb_get_device_list()
364 | libusb_free_device_list(devices, 1);
365 |
366 | // Exit libusb
367 | libusb_exit(NULL);
368 | return PL_ERROR_SUCCESS;
369 | }
370 |
--------------------------------------------------------------------------------
/Source/libusb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Public libusb header file
3 | * Copyright © 2001 Johannes Erdfelt
4 | * Copyright © 2007-2008 Daniel Drake
5 | * Copyright © 2012 Pete Batard
6 | * Copyright © 2012 Nathan Hjelm
7 | * For more information, please visit: http://libusb.info
8 | *
9 | * This library is free software; you can redistribute it and/or
10 | * modify it under the terms of the GNU Lesser General Public
11 | * License as published by the Free Software Foundation; either
12 | * version 2.1 of the License, or (at your option) any later version.
13 | *
14 | * This library is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | * Lesser General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU Lesser General Public
20 | * License along with this library; if not, write to the Free Software
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 | */
23 |
24 | #ifndef LIBUSB_H
25 | #define LIBUSB_H
26 |
27 | #ifdef _MSC_VER
28 | /* on MS environments, the inline keyword is available in C++ only */
29 | #if !defined(__cplusplus)
30 | #define inline __inline
31 | #endif
32 | /* ssize_t is also not available (copy/paste from MinGW) */
33 | #ifndef _SSIZE_T_DEFINED
34 | #define _SSIZE_T_DEFINED
35 | #undef ssize_t
36 | #ifdef _WIN64
37 | typedef __int64 ssize_t;
38 | #else
39 | typedef int ssize_t;
40 | #endif /* _WIN64 */
41 | #endif /* _SSIZE_T_DEFINED */
42 | #endif /* _MSC_VER */
43 |
44 | /* stdint.h is not available on older MSVC */
45 | #if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
46 | typedef unsigned __int8 uint8_t;
47 | typedef unsigned __int16 uint16_t;
48 | typedef unsigned __int32 uint32_t;
49 | #else
50 | #include
51 | #endif
52 |
53 | #if !defined(_WIN32_WCE)
54 | #include
55 | #endif
56 |
57 | #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
58 | #include
59 | #endif
60 |
61 | #include
62 | #include
63 |
64 | /* 'interface' might be defined as a macro on Windows, so we need to
65 | * undefine it so as not to break the current libusb API, because
66 | * libusb_config_descriptor has an 'interface' member
67 | * As this can be problematic if you include windows.h after libusb.h
68 | * in your sources, we force windows.h to be included first. */
69 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
70 | #include
71 | #if defined(interface)
72 | #undef interface
73 | #endif
74 | #if !defined(__CYGWIN__)
75 | #include
76 | #endif
77 | #endif
78 |
79 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
80 | #define LIBUSB_DEPRECATED_FOR(f) \
81 | __attribute__((deprecated("Use " #f " instead")))
82 | #else
83 | #define LIBUSB_DEPRECATED_FOR(f)
84 | #endif /* __GNUC__ */
85 |
86 | /** \def LIBUSB_CALL
87 | * \ingroup libusb_misc
88 | * libusb's Windows calling convention.
89 | *
90 | * Under Windows, the selection of available compilers and configurations
91 | * means that, unlike other platforms, there is not one true calling
92 | * convention (calling convention: the manner in which parameters are
93 | * passed to functions in the generated assembly code).
94 | *
95 | * Matching the Windows API itself, libusb uses the WINAPI convention (which
96 | * translates to the stdcall convention) and guarantees that the
97 | * library is compiled in this way. The public header file also includes
98 | * appropriate annotations so that your own software will use the right
99 | * convention, even if another convention is being used by default within
100 | * your codebase.
101 | *
102 | * The one consideration that you must apply in your software is to mark
103 | * all functions which you use as libusb callbacks with this LIBUSB_CALL
104 | * annotation, so that they too get compiled for the correct calling
105 | * convention.
106 | *
107 | * On non-Windows operating systems, this macro is defined as nothing. This
108 | * means that you can apply it to your code without worrying about
109 | * cross-platform compatibility.
110 | */
111 | /* LIBUSB_CALL must be defined on both definition and declaration of libusb
112 | * functions. You'd think that declaration would be enough, but cygwin will
113 | * complain about conflicting types unless both are marked this way.
114 | * The placement of this macro is important too; it must appear after the
115 | * return type, before the function name. See internal documentation for
116 | * API_EXPORTED.
117 | */
118 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
119 | #define LIBUSB_CALL WINAPI
120 | #else
121 | #define LIBUSB_CALL
122 | #endif
123 |
124 | /** \def LIBUSB_API_VERSION
125 | * \ingroup libusb_misc
126 | * libusb's API version.
127 | *
128 | * Since version 1.0.13, to help with feature detection, libusb defines
129 | * a LIBUSB_API_VERSION macro that gets increased every time there is a
130 | * significant change to the API, such as the introduction of a new call,
131 | * the definition of a new macro/enum member, or any other element that
132 | * libusb applications may want to detect at compilation time.
133 | *
134 | * The macro is typically used in an application as follows:
135 | * \code
136 | * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
137 | * // Use one of the newer features from the libusb API
138 | * #endif
139 | * \endcode
140 | *
141 | * Internally, LIBUSB_API_VERSION is defined as follows:
142 | * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
143 | */
144 | #define LIBUSB_API_VERSION 0x01000105
145 |
146 | /* The following is kept for compatibility, but will be deprecated in the future */
147 | #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
148 |
149 | #ifdef __cplusplus
150 | extern "C" {
151 | #endif
152 |
153 | /**
154 | * \ingroup libusb_misc
155 | * Convert a 16-bit value from host-endian to little-endian format. On
156 | * little endian systems, this function does nothing. On big endian systems,
157 | * the bytes are swapped.
158 | * \param x the host-endian value to convert
159 | * \returns the value in little-endian byte order
160 | */
161 | static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
162 | {
163 | union {
164 | uint8_t b8[2];
165 | uint16_t b16;
166 | } _tmp;
167 | _tmp.b8[1] = (uint8_t) (x >> 8);
168 | _tmp.b8[0] = (uint8_t) (x & 0xff);
169 | return _tmp.b16;
170 | }
171 |
172 | /** \def libusb_le16_to_cpu
173 | * \ingroup libusb_misc
174 | * Convert a 16-bit value from little-endian to host-endian format. On
175 | * little endian systems, this function does nothing. On big endian systems,
176 | * the bytes are swapped.
177 | * \param x the little-endian value to convert
178 | * \returns the value in host-endian byte order
179 | */
180 | #define libusb_le16_to_cpu libusb_cpu_to_le16
181 |
182 | /* standard USB stuff */
183 |
184 | /** \ingroup libusb_desc
185 | * Device and/or Interface Class codes */
186 | enum libusb_class_code {
187 | /** In the context of a \ref libusb_device_descriptor "device descriptor",
188 | * this bDeviceClass value indicates that each interface specifies its
189 | * own class information and all interfaces operate independently.
190 | */
191 | LIBUSB_CLASS_PER_INTERFACE = 0,
192 |
193 | /** Audio class */
194 | LIBUSB_CLASS_AUDIO = 1,
195 |
196 | /** Communications class */
197 | LIBUSB_CLASS_COMM = 2,
198 |
199 | /** Human Interface Device class */
200 | LIBUSB_CLASS_HID = 3,
201 |
202 | /** Physical */
203 | LIBUSB_CLASS_PHYSICAL = 5,
204 |
205 | /** Printer class */
206 | LIBUSB_CLASS_PRINTER = 7,
207 |
208 | /** Image class */
209 | LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
210 | LIBUSB_CLASS_IMAGE = 6,
211 |
212 | /** Mass storage class */
213 | LIBUSB_CLASS_MASS_STORAGE = 8,
214 |
215 | /** Hub class */
216 | LIBUSB_CLASS_HUB = 9,
217 |
218 | /** Data class */
219 | LIBUSB_CLASS_DATA = 10,
220 |
221 | /** Smart Card */
222 | LIBUSB_CLASS_SMART_CARD = 0x0b,
223 |
224 | /** Content Security */
225 | LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
226 |
227 | /** Video */
228 | LIBUSB_CLASS_VIDEO = 0x0e,
229 |
230 | /** Personal Healthcare */
231 | LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
232 |
233 | /** Diagnostic Device */
234 | LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
235 |
236 | /** Wireless class */
237 | LIBUSB_CLASS_WIRELESS = 0xe0,
238 |
239 | /** Application class */
240 | LIBUSB_CLASS_APPLICATION = 0xfe,
241 |
242 | /** Class is vendor-specific */
243 | LIBUSB_CLASS_VENDOR_SPEC = 0xff
244 | };
245 |
246 | /** \ingroup libusb_desc
247 | * Descriptor types as defined by the USB specification. */
248 | enum libusb_descriptor_type {
249 | /** Device descriptor. See libusb_device_descriptor. */
250 | LIBUSB_DT_DEVICE = 0x01,
251 |
252 | /** Configuration descriptor. See libusb_config_descriptor. */
253 | LIBUSB_DT_CONFIG = 0x02,
254 |
255 | /** String descriptor */
256 | LIBUSB_DT_STRING = 0x03,
257 |
258 | /** Interface descriptor. See libusb_interface_descriptor. */
259 | LIBUSB_DT_INTERFACE = 0x04,
260 |
261 | /** Endpoint descriptor. See libusb_endpoint_descriptor. */
262 | LIBUSB_DT_ENDPOINT = 0x05,
263 |
264 | /** BOS descriptor */
265 | LIBUSB_DT_BOS = 0x0f,
266 |
267 | /** Device Capability descriptor */
268 | LIBUSB_DT_DEVICE_CAPABILITY = 0x10,
269 |
270 | /** HID descriptor */
271 | LIBUSB_DT_HID = 0x21,
272 |
273 | /** HID report descriptor */
274 | LIBUSB_DT_REPORT = 0x22,
275 |
276 | /** Physical descriptor */
277 | LIBUSB_DT_PHYSICAL = 0x23,
278 |
279 | /** Hub descriptor */
280 | LIBUSB_DT_HUB = 0x29,
281 |
282 | /** SuperSpeed Hub descriptor */
283 | LIBUSB_DT_SUPERSPEED_HUB = 0x2a,
284 |
285 | /** SuperSpeed Endpoint Companion descriptor */
286 | LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30
287 | };
288 |
289 | /* Descriptor sizes per descriptor type */
290 | #define LIBUSB_DT_DEVICE_SIZE 18
291 | #define LIBUSB_DT_CONFIG_SIZE 9
292 | #define LIBUSB_DT_INTERFACE_SIZE 9
293 | #define LIBUSB_DT_ENDPOINT_SIZE 7
294 | #define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
295 | #define LIBUSB_DT_HUB_NONVAR_SIZE 7
296 | #define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6
297 | #define LIBUSB_DT_BOS_SIZE 5
298 | #define LIBUSB_DT_DEVICE_CAPABILITY_SIZE 3
299 |
300 | /* BOS descriptor sizes */
301 | #define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7
302 | #define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10
303 | #define LIBUSB_BT_CONTAINER_ID_SIZE 20
304 |
305 | /* We unwrap the BOS => define its max size */
306 | #define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\
307 | (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +\
308 | (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\
309 | (LIBUSB_BT_CONTAINER_ID_SIZE))
310 |
311 | #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
312 | #define LIBUSB_ENDPOINT_DIR_MASK 0x80
313 |
314 | /** \ingroup libusb_desc
315 | * Endpoint direction. Values for bit 7 of the
316 | * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
317 | */
318 | enum libusb_endpoint_direction {
319 | /** In: device-to-host */
320 | LIBUSB_ENDPOINT_IN = 0x80,
321 |
322 | /** Out: host-to-device */
323 | LIBUSB_ENDPOINT_OUT = 0x00
324 | };
325 |
326 | #define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
327 |
328 | /** \ingroup libusb_desc
329 | * Endpoint transfer type. Values for bits 0:1 of the
330 | * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
331 | */
332 | enum libusb_transfer_type {
333 | /** Control endpoint */
334 | LIBUSB_TRANSFER_TYPE_CONTROL = 0,
335 |
336 | /** Isochronous endpoint */
337 | LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
338 |
339 | /** Bulk endpoint */
340 | LIBUSB_TRANSFER_TYPE_BULK = 2,
341 |
342 | /** Interrupt endpoint */
343 | LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
344 |
345 | /** Stream endpoint */
346 | LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
347 | };
348 |
349 | /** \ingroup libusb_misc
350 | * Standard requests, as defined in table 9-5 of the USB 3.0 specifications */
351 | enum libusb_standard_request {
352 | /** Request status of the specific recipient */
353 | LIBUSB_REQUEST_GET_STATUS = 0x00,
354 |
355 | /** Clear or disable a specific feature */
356 | LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
357 |
358 | /* 0x02 is reserved */
359 |
360 | /** Set or enable a specific feature */
361 | LIBUSB_REQUEST_SET_FEATURE = 0x03,
362 |
363 | /* 0x04 is reserved */
364 |
365 | /** Set device address for all future accesses */
366 | LIBUSB_REQUEST_SET_ADDRESS = 0x05,
367 |
368 | /** Get the specified descriptor */
369 | LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06,
370 |
371 | /** Used to update existing descriptors or add new descriptors */
372 | LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07,
373 |
374 | /** Get the current device configuration value */
375 | LIBUSB_REQUEST_GET_CONFIGURATION = 0x08,
376 |
377 | /** Set device configuration */
378 | LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
379 |
380 | /** Return the selected alternate setting for the specified interface */
381 | LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
382 |
383 | /** Select an alternate interface for the specified interface */
384 | LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
385 |
386 | /** Set then report an endpoint's synchronization frame */
387 | LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
388 |
389 | /** Sets both the U1 and U2 Exit Latency */
390 | LIBUSB_REQUEST_SET_SEL = 0x30,
391 |
392 | /** Delay from the time a host transmits a packet to the time it is
393 | * received by the device. */
394 | LIBUSB_SET_ISOCH_DELAY = 0x31,
395 | };
396 |
397 | /** \ingroup libusb_misc
398 | * Request type bits of the
399 | * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
400 | * transfers. */
401 | enum libusb_request_type {
402 | /** Standard */
403 | LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
404 |
405 | /** Class */
406 | LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5),
407 |
408 | /** Vendor */
409 | LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5),
410 |
411 | /** Reserved */
412 | LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
413 | };
414 |
415 | /** \ingroup libusb_misc
416 | * Recipient bits of the
417 | * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
418 | * transfers. Values 4 through 31 are reserved. */
419 | enum libusb_request_recipient {
420 | /** Device */
421 | LIBUSB_RECIPIENT_DEVICE = 0x00,
422 |
423 | /** Interface */
424 | LIBUSB_RECIPIENT_INTERFACE = 0x01,
425 |
426 | /** Endpoint */
427 | LIBUSB_RECIPIENT_ENDPOINT = 0x02,
428 |
429 | /** Other */
430 | LIBUSB_RECIPIENT_OTHER = 0x03,
431 | };
432 |
433 | #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
434 |
435 | /** \ingroup libusb_desc
436 | * Synchronization type for isochronous endpoints. Values for bits 2:3 of the
437 | * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
438 | * libusb_endpoint_descriptor.
439 | */
440 | enum libusb_iso_sync_type {
441 | /** No synchronization */
442 | LIBUSB_ISO_SYNC_TYPE_NONE = 0,
443 |
444 | /** Asynchronous */
445 | LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
446 |
447 | /** Adaptive */
448 | LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
449 |
450 | /** Synchronous */
451 | LIBUSB_ISO_SYNC_TYPE_SYNC = 3
452 | };
453 |
454 | #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
455 |
456 | /** \ingroup libusb_desc
457 | * Usage type for isochronous endpoints. Values for bits 4:5 of the
458 | * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
459 | * libusb_endpoint_descriptor.
460 | */
461 | enum libusb_iso_usage_type {
462 | /** Data endpoint */
463 | LIBUSB_ISO_USAGE_TYPE_DATA = 0,
464 |
465 | /** Feedback endpoint */
466 | LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
467 |
468 | /** Implicit feedback Data endpoint */
469 | LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
470 | };
471 |
472 | /** \ingroup libusb_desc
473 | * A structure representing the standard USB device descriptor. This
474 | * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
475 | * All multiple-byte fields are represented in host-endian format.
476 | */
477 | struct libusb_device_descriptor {
478 | /** Size of this descriptor (in bytes) */
479 | uint8_t bLength;
480 |
481 | /** Descriptor type. Will have value
482 | * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this
483 | * context. */
484 | uint8_t bDescriptorType;
485 |
486 | /** USB specification release number in binary-coded decimal. A value of
487 | * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */
488 | uint16_t bcdUSB;
489 |
490 | /** USB-IF class code for the device. See \ref libusb_class_code. */
491 | uint8_t bDeviceClass;
492 |
493 | /** USB-IF subclass code for the device, qualified by the bDeviceClass
494 | * value */
495 | uint8_t bDeviceSubClass;
496 |
497 | /** USB-IF protocol code for the device, qualified by the bDeviceClass and
498 | * bDeviceSubClass values */
499 | uint8_t bDeviceProtocol;
500 |
501 | /** Maximum packet size for endpoint 0 */
502 | uint8_t bMaxPacketSize0;
503 |
504 | /** USB-IF vendor ID */
505 | uint16_t idVendor;
506 |
507 | /** USB-IF product ID */
508 | uint16_t idProduct;
509 |
510 | /** Device release number in binary-coded decimal */
511 | uint16_t bcdDevice;
512 |
513 | /** Index of string descriptor describing manufacturer */
514 | uint8_t iManufacturer;
515 |
516 | /** Index of string descriptor describing product */
517 | uint8_t iProduct;
518 |
519 | /** Index of string descriptor containing device serial number */
520 | uint8_t iSerialNumber;
521 |
522 | /** Number of possible configurations */
523 | uint8_t bNumConfigurations;
524 | };
525 |
526 | /** \ingroup libusb_desc
527 | * A structure representing the standard USB endpoint descriptor. This
528 | * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
529 | * All multiple-byte fields are represented in host-endian format.
530 | */
531 | struct libusb_endpoint_descriptor {
532 | /** Size of this descriptor (in bytes) */
533 | uint8_t bLength;
534 |
535 | /** Descriptor type. Will have value
536 | * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOINT in
537 | * this context. */
538 | uint8_t bDescriptorType;
539 |
540 | /** The address of the endpoint described by this descriptor. Bits 0:3 are
541 | * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
542 | * see \ref libusb_endpoint_direction.
543 | */
544 | uint8_t bEndpointAddress;
545 |
546 | /** Attributes which apply to the endpoint when it is configured using
547 | * the bConfigurationValue. Bits 0:1 determine the transfer type and
548 | * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
549 | * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
550 | * Bits 4:5 are also only used for isochronous endpoints and correspond to
551 | * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
552 | */
553 | uint8_t bmAttributes;
554 |
555 | /** Maximum packet size this endpoint is capable of sending/receiving. */
556 | uint16_t wMaxPacketSize;
557 |
558 | /** Interval for polling endpoint for data transfers. */
559 | uint8_t bInterval;
560 |
561 | /** For audio devices only: the rate at which synchronization feedback
562 | * is provided. */
563 | uint8_t bRefresh;
564 |
565 | /** For audio devices only: the address if the synch endpoint */
566 | uint8_t bSynchAddress;
567 |
568 | /** Extra descriptors. If libusb encounters unknown endpoint descriptors,
569 | * it will store them here, should you wish to parse them. */
570 | const unsigned char *extra;
571 |
572 | /** Length of the extra descriptors, in bytes. */
573 | int extra_length;
574 | };
575 |
576 | /** \ingroup libusb_desc
577 | * A structure representing the standard USB interface descriptor. This
578 | * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
579 | * All multiple-byte fields are represented in host-endian format.
580 | */
581 | struct libusb_interface_descriptor {
582 | /** Size of this descriptor (in bytes) */
583 | uint8_t bLength;
584 |
585 | /** Descriptor type. Will have value
586 | * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE
587 | * in this context. */
588 | uint8_t bDescriptorType;
589 |
590 | /** Number of this interface */
591 | uint8_t bInterfaceNumber;
592 |
593 | /** Value used to select this alternate setting for this interface */
594 | uint8_t bAlternateSetting;
595 |
596 | /** Number of endpoints used by this interface (excluding the control
597 | * endpoint). */
598 | uint8_t bNumEndpoints;
599 |
600 | /** USB-IF class code for this interface. See \ref libusb_class_code. */
601 | uint8_t bInterfaceClass;
602 |
603 | /** USB-IF subclass code for this interface, qualified by the
604 | * bInterfaceClass value */
605 | uint8_t bInterfaceSubClass;
606 |
607 | /** USB-IF protocol code for this interface, qualified by the
608 | * bInterfaceClass and bInterfaceSubClass values */
609 | uint8_t bInterfaceProtocol;
610 |
611 | /** Index of string descriptor describing this interface */
612 | uint8_t iInterface;
613 |
614 | /** Array of endpoint descriptors. This length of this array is determined
615 | * by the bNumEndpoints field. */
616 | const struct libusb_endpoint_descriptor *endpoint;
617 |
618 | /** Extra descriptors. If libusb encounters unknown interface descriptors,
619 | * it will store them here, should you wish to parse them. */
620 | const unsigned char *extra;
621 |
622 | /** Length of the extra descriptors, in bytes. */
623 | int extra_length;
624 | };
625 |
626 | /** \ingroup libusb_desc
627 | * A collection of alternate settings for a particular USB interface.
628 | */
629 | struct libusb_interface {
630 | /** Array of interface descriptors. The length of this array is determined
631 | * by the num_altsetting field. */
632 | const struct libusb_interface_descriptor *altsetting;
633 |
634 | /** The number of alternate settings that belong to this interface */
635 | int num_altsetting;
636 | };
637 |
638 | /** \ingroup libusb_desc
639 | * A structure representing the standard USB configuration descriptor. This
640 | * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
641 | * All multiple-byte fields are represented in host-endian format.
642 | */
643 | struct libusb_config_descriptor {
644 | /** Size of this descriptor (in bytes) */
645 | uint8_t bLength;
646 |
647 | /** Descriptor type. Will have value
648 | * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
649 | * in this context. */
650 | uint8_t bDescriptorType;
651 |
652 | /** Total length of data returned for this configuration */
653 | uint16_t wTotalLength;
654 |
655 | /** Number of interfaces supported by this configuration */
656 | uint8_t bNumInterfaces;
657 |
658 | /** Identifier value for this configuration */
659 | uint8_t bConfigurationValue;
660 |
661 | /** Index of string descriptor describing this configuration */
662 | uint8_t iConfiguration;
663 |
664 | /** Configuration characteristics */
665 | uint8_t bmAttributes;
666 |
667 | /** Maximum power consumption of the USB device from this bus in this
668 | * configuration when the device is fully operation. Expressed in units
669 | * of 2 mA when the device is operating in high-speed mode and in units
670 | * of 8 mA when the device is operating in super-speed mode. */
671 | uint8_t MaxPower;
672 |
673 | /** Array of interfaces supported by this configuration. The length of
674 | * this array is determined by the bNumInterfaces field. */
675 | const struct libusb_interface *interface;
676 |
677 | /** Extra descriptors. If libusb encounters unknown configuration
678 | * descriptors, it will store them here, should you wish to parse them. */
679 | const unsigned char *extra;
680 |
681 | /** Length of the extra descriptors, in bytes. */
682 | int extra_length;
683 | };
684 |
685 | /** \ingroup libusb_desc
686 | * A structure representing the superspeed endpoint companion
687 | * descriptor. This descriptor is documented in section 9.6.7 of
688 | * the USB 3.0 specification. All multiple-byte fields are represented in
689 | * host-endian format.
690 | */
691 | struct libusb_ss_endpoint_companion_descriptor {
692 |
693 | /** Size of this descriptor (in bytes) */
694 | uint8_t bLength;
695 |
696 | /** Descriptor type. Will have value
697 | * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in
698 | * this context. */
699 | uint8_t bDescriptorType;
700 |
701 |
702 | /** The maximum number of packets the endpoint can send or
703 | * receive as part of a burst. */
704 | uint8_t bMaxBurst;
705 |
706 | /** In bulk EP: bits 4:0 represents the maximum number of
707 | * streams the EP supports. In isochronous EP: bits 1:0
708 | * represents the Mult - a zero based value that determines
709 | * the maximum number of packets within a service interval */
710 | uint8_t bmAttributes;
711 |
712 | /** The total number of bytes this EP will transfer every
713 | * service interval. valid only for periodic EPs. */
714 | uint16_t wBytesPerInterval;
715 | };
716 |
717 | /** \ingroup libusb_desc
718 | * A generic representation of a BOS Device Capability descriptor. It is
719 | * advised to check bDevCapabilityType and call the matching
720 | * libusb_get_*_descriptor function to get a structure fully matching the type.
721 | */
722 | struct libusb_bos_dev_capability_descriptor {
723 | /** Size of this descriptor (in bytes) */
724 | uint8_t bLength;
725 | /** Descriptor type. Will have value
726 | * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
727 | * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
728 | uint8_t bDescriptorType;
729 | /** Device Capability type */
730 | uint8_t bDevCapabilityType;
731 | /** Device Capability data (bLength - 3 bytes) */
732 | uint8_t dev_capability_data
733 | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
734 | [] /* valid C99 code */
735 | #else
736 | [0] /* non-standard, but usually working code */
737 | #endif
738 | ;
739 | };
740 |
741 | /** \ingroup libusb_desc
742 | * A structure representing the Binary Device Object Store (BOS) descriptor.
743 | * This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
744 | * All multiple-byte fields are represented in host-endian format.
745 | */
746 | struct libusb_bos_descriptor {
747 | /** Size of this descriptor (in bytes) */
748 | uint8_t bLength;
749 |
750 | /** Descriptor type. Will have value
751 | * \ref libusb_descriptor_type::LIBUSB_DT_BOS LIBUSB_DT_BOS
752 | * in this context. */
753 | uint8_t bDescriptorType;
754 |
755 | /** Length of this descriptor and all of its sub descriptors */
756 | uint16_t wTotalLength;
757 |
758 | /** The number of separate device capability descriptors in
759 | * the BOS */
760 | uint8_t bNumDeviceCaps;
761 |
762 | /** bNumDeviceCap Device Capability Descriptors */
763 | struct libusb_bos_dev_capability_descriptor *dev_capability
764 | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
765 | [] /* valid C99 code */
766 | #else
767 | [0] /* non-standard, but usually working code */
768 | #endif
769 | ;
770 | };
771 |
772 | /** \ingroup libusb_desc
773 | * A structure representing the USB 2.0 Extension descriptor
774 | * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
775 | * All multiple-byte fields are represented in host-endian format.
776 | */
777 | struct libusb_usb_2_0_extension_descriptor {
778 | /** Size of this descriptor (in bytes) */
779 | uint8_t bLength;
780 |
781 | /** Descriptor type. Will have value
782 | * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
783 | * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
784 | uint8_t bDescriptorType;
785 |
786 | /** Capability type. Will have value
787 | * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
788 | * LIBUSB_BT_USB_2_0_EXTENSION in this context. */
789 | uint8_t bDevCapabilityType;
790 |
791 | /** Bitmap encoding of supported device level features.
792 | * A value of one in a bit location indicates a feature is
793 | * supported; a value of zero indicates it is not supported.
794 | * See \ref libusb_usb_2_0_extension_attributes. */
795 | uint32_t bmAttributes;
796 | };
797 |
798 | /** \ingroup libusb_desc
799 | * A structure representing the SuperSpeed USB Device Capability descriptor
800 | * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
801 | * All multiple-byte fields are represented in host-endian format.
802 | */
803 | struct libusb_ss_usb_device_capability_descriptor {
804 | /** Size of this descriptor (in bytes) */
805 | uint8_t bLength;
806 |
807 | /** Descriptor type. Will have value
808 | * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
809 | * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
810 | uint8_t bDescriptorType;
811 |
812 | /** Capability type. Will have value
813 | * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
814 | * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context. */
815 | uint8_t bDevCapabilityType;
816 |
817 | /** Bitmap encoding of supported device level features.
818 | * A value of one in a bit location indicates a feature is
819 | * supported; a value of zero indicates it is not supported.
820 | * See \ref libusb_ss_usb_device_capability_attributes. */
821 | uint8_t bmAttributes;
822 |
823 | /** Bitmap encoding of the speed supported by this device when
824 | * operating in SuperSpeed mode. See \ref libusb_supported_speed. */
825 | uint16_t wSpeedSupported;
826 |
827 | /** The lowest speed at which all the functionality supported
828 | * by the device is available to the user. For example if the
829 | * device supports all its functionality when connected at
830 | * full speed and above then it sets this value to 1. */
831 | uint8_t bFunctionalitySupport;
832 |
833 | /** U1 Device Exit Latency. */
834 | uint8_t bU1DevExitLat;
835 |
836 | /** U2 Device Exit Latency. */
837 | uint16_t bU2DevExitLat;
838 | };
839 |
840 | /** \ingroup libusb_desc
841 | * A structure representing the Container ID descriptor.
842 | * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
843 | * All multiple-byte fields, except UUIDs, are represented in host-endian format.
844 | */
845 | struct libusb_container_id_descriptor {
846 | /** Size of this descriptor (in bytes) */
847 | uint8_t bLength;
848 |
849 | /** Descriptor type. Will have value
850 | * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
851 | * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
852 | uint8_t bDescriptorType;
853 |
854 | /** Capability type. Will have value
855 | * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID
856 | * LIBUSB_BT_CONTAINER_ID in this context. */
857 | uint8_t bDevCapabilityType;
858 |
859 | /** Reserved field */
860 | uint8_t bReserved;
861 |
862 | /** 128 bit UUID */
863 | uint8_t ContainerID[16];
864 | };
865 |
866 | /** \ingroup libusb_asyncio
867 | * Setup packet for control transfers. */
868 | struct libusb_control_setup {
869 | /** Request type. Bits 0:4 determine recipient, see
870 | * \ref libusb_request_recipient. Bits 5:6 determine type, see
871 | * \ref libusb_request_type. Bit 7 determines data transfer direction, see
872 | * \ref libusb_endpoint_direction.
873 | */
874 | uint8_t bmRequestType;
875 |
876 | /** Request. If the type bits of bmRequestType are equal to
877 | * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD
878 | * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to
879 | * \ref libusb_standard_request. For other cases, use of this field is
880 | * application-specific. */
881 | uint8_t bRequest;
882 |
883 | /** Value. Varies according to request */
884 | uint16_t wValue;
885 |
886 | /** Index. Varies according to request, typically used to pass an index
887 | * or offset */
888 | uint16_t wIndex;
889 |
890 | /** Number of bytes to transfer */
891 | uint16_t wLength;
892 | };
893 |
894 | #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
895 |
896 | /* libusb */
897 |
898 | struct libusb_context;
899 | struct libusb_device;
900 | struct libusb_device_handle;
901 |
902 | /** \ingroup libusb_lib
903 | * Structure providing the version of the libusb runtime
904 | */
905 | struct libusb_version {
906 | /** Library major version. */
907 | const uint16_t major;
908 |
909 | /** Library minor version. */
910 | const uint16_t minor;
911 |
912 | /** Library micro version. */
913 | const uint16_t micro;
914 |
915 | /** Library nano version. */
916 | const uint16_t nano;
917 |
918 | /** Library release candidate suffix string, e.g. "-rc4". */
919 | const char *rc;
920 |
921 | /** For ABI compatibility only. */
922 | const char* describe;
923 | };
924 |
925 | /** \ingroup libusb_lib
926 | * Structure representing a libusb session. The concept of individual libusb
927 | * sessions allows for your program to use two libraries (or dynamically
928 | * load two modules) which both independently use libusb. This will prevent
929 | * interference between the individual libusb users - for example
930 | * libusb_set_debug() will not affect the other user of the library, and
931 | * libusb_exit() will not destroy resources that the other user is still
932 | * using.
933 | *
934 | * Sessions are created by libusb_init() and destroyed through libusb_exit().
935 | * If your application is guaranteed to only ever include a single libusb
936 | * user (i.e. you), you do not have to worry about contexts: pass NULL in
937 | * every function call where a context is required. The default context
938 | * will be used.
939 | *
940 | * For more information, see \ref libusb_contexts.
941 | */
942 | typedef struct libusb_context libusb_context;
943 |
944 | /** \ingroup libusb_dev
945 | * Structure representing a USB device detected on the system. This is an
946 | * opaque type for which you are only ever provided with a pointer, usually
947 | * originating from libusb_get_device_list().
948 | *
949 | * Certain operations can be performed on a device, but in order to do any
950 | * I/O you will have to first obtain a device handle using libusb_open().
951 | *
952 | * Devices are reference counted with libusb_ref_device() and
953 | * libusb_unref_device(), and are freed when the reference count reaches 0.
954 | * New devices presented by libusb_get_device_list() have a reference count of
955 | * 1, and libusb_free_device_list() can optionally decrease the reference count
956 | * on all devices in the list. libusb_open() adds another reference which is
957 | * later destroyed by libusb_close().
958 | */
959 | typedef struct libusb_device libusb_device;
960 |
961 |
962 | /** \ingroup libusb_dev
963 | * Structure representing a handle on a USB device. This is an opaque type for
964 | * which you are only ever provided with a pointer, usually originating from
965 | * libusb_open().
966 | *
967 | * A device handle is used to perform I/O and other operations. When finished
968 | * with a device handle, you should call libusb_close().
969 | */
970 | typedef struct libusb_device_handle libusb_device_handle;
971 |
972 | /** \ingroup libusb_dev
973 | * Speed codes. Indicates the speed at which the device is operating.
974 | */
975 | enum libusb_speed {
976 | /** The OS doesn't report or know the device speed. */
977 | LIBUSB_SPEED_UNKNOWN = 0,
978 |
979 | /** The device is operating at low speed (1.5MBit/s). */
980 | LIBUSB_SPEED_LOW = 1,
981 |
982 | /** The device is operating at full speed (12MBit/s). */
983 | LIBUSB_SPEED_FULL = 2,
984 |
985 | /** The device is operating at high speed (480MBit/s). */
986 | LIBUSB_SPEED_HIGH = 3,
987 |
988 | /** The device is operating at super speed (5000MBit/s). */
989 | LIBUSB_SPEED_SUPER = 4,
990 | };
991 |
992 | /** \ingroup libusb_dev
993 | * Supported speeds (wSpeedSupported) bitfield. Indicates what
994 | * speeds the device supports.
995 | */
996 | enum libusb_supported_speed {
997 | /** Low speed operation supported (1.5MBit/s). */
998 | LIBUSB_LOW_SPEED_OPERATION = 1,
999 |
1000 | /** Full speed operation supported (12MBit/s). */
1001 | LIBUSB_FULL_SPEED_OPERATION = 2,
1002 |
1003 | /** High speed operation supported (480MBit/s). */
1004 | LIBUSB_HIGH_SPEED_OPERATION = 4,
1005 |
1006 | /** Superspeed operation supported (5000MBit/s). */
1007 | LIBUSB_SUPER_SPEED_OPERATION = 8,
1008 | };
1009 |
1010 | /** \ingroup libusb_dev
1011 | * Masks for the bits of the
1012 | * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
1013 | * of the USB 2.0 Extension descriptor.
1014 | */
1015 | enum libusb_usb_2_0_extension_attributes {
1016 | /** Supports Link Power Management (LPM) */
1017 | LIBUSB_BM_LPM_SUPPORT = 2,
1018 | };
1019 |
1020 | /** \ingroup libusb_dev
1021 | * Masks for the bits of the
1022 | * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
1023 | * field of the SuperSpeed USB Device Capability descriptor.
1024 | */
1025 | enum libusb_ss_usb_device_capability_attributes {
1026 | /** Supports Latency Tolerance Messages (LTM) */
1027 | LIBUSB_BM_LTM_SUPPORT = 2,
1028 | };
1029 |
1030 | /** \ingroup libusb_dev
1031 | * USB capability types
1032 | */
1033 | enum libusb_bos_type {
1034 | /** Wireless USB device capability */
1035 | LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
1036 |
1037 | /** USB 2.0 extensions */
1038 | LIBUSB_BT_USB_2_0_EXTENSION = 2,
1039 |
1040 | /** SuperSpeed USB device capability */
1041 | LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
1042 |
1043 | /** Container ID type */
1044 | LIBUSB_BT_CONTAINER_ID = 4,
1045 | };
1046 |
1047 | /** \ingroup libusb_misc
1048 | * Error codes. Most libusb functions return 0 on success or one of these
1049 | * codes on failure.
1050 | * You can call libusb_error_name() to retrieve a string representation of an
1051 | * error code or libusb_strerror() to get an end-user suitable description of
1052 | * an error code.
1053 | */
1054 | enum libusb_error {
1055 | /** Success (no error) */
1056 | LIBUSB_SUCCESS = 0,
1057 |
1058 | /** Input/output error */
1059 | LIBUSB_ERROR_IO = -1,
1060 |
1061 | /** Invalid parameter */
1062 | LIBUSB_ERROR_INVALID_PARAM = -2,
1063 |
1064 | /** Access denied (insufficient permissions) */
1065 | LIBUSB_ERROR_ACCESS = -3,
1066 |
1067 | /** No such device (it may have been disconnected) */
1068 | LIBUSB_ERROR_NO_DEVICE = -4,
1069 |
1070 | /** Entity not found */
1071 | LIBUSB_ERROR_NOT_FOUND = -5,
1072 |
1073 | /** Resource busy */
1074 | LIBUSB_ERROR_BUSY = -6,
1075 |
1076 | /** Operation timed out */
1077 | LIBUSB_ERROR_TIMEOUT = -7,
1078 |
1079 | /** Overflow */
1080 | LIBUSB_ERROR_OVERFLOW = -8,
1081 |
1082 | /** Pipe error */
1083 | LIBUSB_ERROR_PIPE = -9,
1084 |
1085 | /** System call interrupted (perhaps due to signal) */
1086 | LIBUSB_ERROR_INTERRUPTED = -10,
1087 |
1088 | /** Insufficient memory */
1089 | LIBUSB_ERROR_NO_MEM = -11,
1090 |
1091 | /** Operation not supported or unimplemented on this platform */
1092 | LIBUSB_ERROR_NOT_SUPPORTED = -12,
1093 |
1094 | /* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
1095 | message strings in strerror.c when adding new error codes here. */
1096 |
1097 | /** Other error */
1098 | LIBUSB_ERROR_OTHER = -99,
1099 | };
1100 |
1101 | /* Total number of error codes in enum libusb_error */
1102 | #define LIBUSB_ERROR_COUNT 14
1103 |
1104 | /** \ingroup libusb_asyncio
1105 | * Transfer status codes */
1106 | enum libusb_transfer_status {
1107 | /** Transfer completed without error. Note that this does not indicate
1108 | * that the entire amount of requested data was transferred. */
1109 | LIBUSB_TRANSFER_COMPLETED,
1110 |
1111 | /** Transfer failed */
1112 | LIBUSB_TRANSFER_ERROR,
1113 |
1114 | /** Transfer timed out */
1115 | LIBUSB_TRANSFER_TIMED_OUT,
1116 |
1117 | /** Transfer was cancelled */
1118 | LIBUSB_TRANSFER_CANCELLED,
1119 |
1120 | /** For bulk/interrupt endpoints: halt condition detected (endpoint
1121 | * stalled). For control endpoints: control request not supported. */
1122 | LIBUSB_TRANSFER_STALL,
1123 |
1124 | /** Device was disconnected */
1125 | LIBUSB_TRANSFER_NO_DEVICE,
1126 |
1127 | /** Device sent more data than requested */
1128 | LIBUSB_TRANSFER_OVERFLOW,
1129 |
1130 | /* NB! Remember to update libusb_error_name()
1131 | when adding new status codes here. */
1132 | };
1133 |
1134 | /** \ingroup libusb_asyncio
1135 | * libusb_transfer.flags values */
1136 | enum libusb_transfer_flags {
1137 | /** Report short frames as errors */
1138 | LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,
1139 |
1140 | /** Automatically free() transfer buffer during libusb_free_transfer().
1141 | * Note that buffers allocated with libusb_dev_mem_alloc() should not
1142 | * be attempted freed in this way, since free() is not an appropriate
1143 | * way to release such memory. */
1144 | LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,
1145 |
1146 | /** Automatically call libusb_free_transfer() after callback returns.
1147 | * If this flag is set, it is illegal to call libusb_free_transfer()
1148 | * from your transfer callback, as this will result in a double-free
1149 | * when this flag is acted upon. */
1150 | LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,
1151 |
1152 | /** Terminate transfers that are a multiple of the endpoint's
1153 | * wMaxPacketSize with an extra zero length packet. This is useful
1154 | * when a device protocol mandates that each logical request is
1155 | * terminated by an incomplete packet (i.e. the logical requests are
1156 | * not separated by other means).
1157 | *
1158 | * This flag only affects host-to-device transfers to bulk and interrupt
1159 | * endpoints. In other situations, it is ignored.
1160 | *
1161 | * This flag only affects transfers with a length that is a multiple of
1162 | * the endpoint's wMaxPacketSize. On transfers of other lengths, this
1163 | * flag has no effect. Therefore, if you are working with a device that
1164 | * needs a ZLP whenever the end of the logical request falls on a packet
1165 | * boundary, then it is sensible to set this flag on every
1166 | * transfer (you do not have to worry about only setting it on transfers
1167 | * that end on the boundary).
1168 | *
1169 | * This flag is currently only supported on Linux.
1170 | * On other systems, libusb_submit_transfer() will return
1171 | * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
1172 | *
1173 | * Available since libusb-1.0.9.
1174 | */
1175 | LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3,
1176 | };
1177 |
1178 | /** \ingroup libusb_asyncio
1179 | * Isochronous packet descriptor. */
1180 | struct libusb_iso_packet_descriptor {
1181 | /** Length of data to request in this packet */
1182 | unsigned int length;
1183 |
1184 | /** Amount of data that was actually transferred */
1185 | unsigned int actual_length;
1186 |
1187 | /** Status code for this packet */
1188 | enum libusb_transfer_status status;
1189 | };
1190 |
1191 | struct libusb_transfer;
1192 |
1193 | /** \ingroup libusb_asyncio
1194 | * Asynchronous transfer callback function type. When submitting asynchronous
1195 | * transfers, you pass a pointer to a callback function of this type via the
1196 | * \ref libusb_transfer::callback "callback" member of the libusb_transfer
1197 | * structure. libusb will call this function later, when the transfer has
1198 | * completed or failed. See \ref libusb_asyncio for more information.
1199 | * \param transfer The libusb_transfer struct the callback function is being
1200 | * notified about.
1201 | */
1202 | typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
1203 |
1204 | /** \ingroup libusb_asyncio
1205 | * The generic USB transfer structure. The user populates this structure and
1206 | * then submits it in order to request a transfer. After the transfer has
1207 | * completed, the library populates the transfer with the results and passes
1208 | * it back to the user.
1209 | */
1210 | struct libusb_transfer {
1211 | /** Handle of the device that this transfer will be submitted to */
1212 | libusb_device_handle *dev_handle;
1213 |
1214 | /** A bitwise OR combination of \ref libusb_transfer_flags. */
1215 | uint8_t flags;
1216 |
1217 | /** Address of the endpoint where this transfer will be sent. */
1218 | unsigned char endpoint;
1219 |
1220 | /** Type of the endpoint from \ref libusb_transfer_type */
1221 | unsigned char type;
1222 |
1223 | /** Timeout for this transfer in milliseconds. A value of 0 indicates no
1224 | * timeout. */
1225 | unsigned int timeout;
1226 |
1227 | /** The status of the transfer. Read-only, and only for use within
1228 | * transfer callback function.
1229 | *
1230 | * If this is an isochronous transfer, this field may read COMPLETED even
1231 | * if there were errors in the frames. Use the
1232 | * \ref libusb_iso_packet_descriptor::status "status" field in each packet
1233 | * to determine if errors occurred. */
1234 | enum libusb_transfer_status status;
1235 |
1236 | /** Length of the data buffer */
1237 | int length;
1238 |
1239 | /** Actual length of data that was transferred. Read-only, and only for
1240 | * use within transfer callback function. Not valid for isochronous
1241 | * endpoint transfers. */
1242 | int actual_length;
1243 |
1244 | /** Callback function. This will be invoked when the transfer completes,
1245 | * fails, or is cancelled. */
1246 | libusb_transfer_cb_fn callback;
1247 |
1248 | /** User context data to pass to the callback function. */
1249 | void *user_data;
1250 |
1251 | /** Data buffer */
1252 | unsigned char *buffer;
1253 |
1254 | /** Number of isochronous packets. Only used for I/O with isochronous
1255 | * endpoints. */
1256 | int num_iso_packets;
1257 |
1258 | /** Isochronous packet descriptors, for isochronous transfers only. */
1259 | struct libusb_iso_packet_descriptor iso_packet_desc
1260 | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
1261 | [] /* valid C99 code */
1262 | #else
1263 | [0] /* non-standard, but usually working code */
1264 | #endif
1265 | ;
1266 | };
1267 |
1268 | /** \ingroup libusb_misc
1269 | * Capabilities supported by an instance of libusb on the current running
1270 | * platform. Test if the loaded library supports a given capability by calling
1271 | * \ref libusb_has_capability().
1272 | */
1273 | enum libusb_capability {
1274 | /** The libusb_has_capability() API is available. */
1275 | LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
1276 | /** Hotplug support is available on this platform. */
1277 | LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
1278 | /** The library can access HID devices without requiring user intervention.
1279 | * Note that before being able to actually access an HID device, you may
1280 | * still have to call additional libusb functions such as
1281 | * \ref libusb_detach_kernel_driver(). */
1282 | LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
1283 | /** The library supports detaching of the default USB driver, using
1284 | * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
1285 | LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
1286 | };
1287 |
1288 | /** \ingroup libusb_lib
1289 | * Log message levels.
1290 | * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
1291 | * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
1292 | * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
1293 | * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
1294 | * and error messages are printed to stderr
1295 | * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
1296 | * warnings and errors to stderr
1297 | */
1298 | enum libusb_log_level {
1299 | LIBUSB_LOG_LEVEL_NONE = 0,
1300 | LIBUSB_LOG_LEVEL_ERROR,
1301 | LIBUSB_LOG_LEVEL_WARNING,
1302 | LIBUSB_LOG_LEVEL_INFO,
1303 | LIBUSB_LOG_LEVEL_DEBUG,
1304 | };
1305 |
1306 | int LIBUSB_CALL libusb_init(libusb_context **ctx);
1307 | void LIBUSB_CALL libusb_exit(libusb_context *ctx);
1308 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
1309 | const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1310 | int LIBUSB_CALL libusb_has_capability(uint32_t capability);
1311 | const char * LIBUSB_CALL libusb_error_name(int errcode);
1312 | int LIBUSB_CALL libusb_setlocale(const char *locale);
1313 | const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
1314 |
1315 | ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
1316 | libusb_device ***list);
1317 | void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
1318 | int unref_devices);
1319 | libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
1320 | void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
1321 |
1322 | int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
1323 | int *config);
1324 | int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
1325 | struct libusb_device_descriptor *desc);
1326 | int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
1327 | struct libusb_config_descriptor **config);
1328 | int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
1329 | uint8_t config_index, struct libusb_config_descriptor **config);
1330 | int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
1331 | uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
1332 | void LIBUSB_CALL libusb_free_config_descriptor(
1333 | struct libusb_config_descriptor *config);
1334 | int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
1335 | struct libusb_context *ctx,
1336 | const struct libusb_endpoint_descriptor *endpoint,
1337 | struct libusb_ss_endpoint_companion_descriptor **ep_comp);
1338 | void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
1339 | struct libusb_ss_endpoint_companion_descriptor *ep_comp);
1340 | int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
1341 | struct libusb_bos_descriptor **bos);
1342 | void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
1343 | int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
1344 | struct libusb_context *ctx,
1345 | struct libusb_bos_dev_capability_descriptor *dev_cap,
1346 | struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
1347 | void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
1348 | struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
1349 | int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
1350 | struct libusb_context *ctx,
1351 | struct libusb_bos_dev_capability_descriptor *dev_cap,
1352 | struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
1353 | void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
1354 | struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
1355 | int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
1356 | struct libusb_bos_dev_capability_descriptor *dev_cap,
1357 | struct libusb_container_id_descriptor **container_id);
1358 | void LIBUSB_CALL libusb_free_container_id_descriptor(
1359 | struct libusb_container_id_descriptor *container_id);
1360 | uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
1361 | uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
1362 | int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
1363 | LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
1364 | int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
1365 | libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
1366 | uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
1367 | int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
1368 | int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
1369 | unsigned char endpoint);
1370 | int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
1371 | unsigned char endpoint);
1372 |
1373 | int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
1374 | void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
1375 | libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
1376 |
1377 | int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev_handle,
1378 | int configuration);
1379 | int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev_handle,
1380 | int interface_number);
1381 | int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev_handle,
1382 | int interface_number);
1383 |
1384 | libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
1385 | libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
1386 |
1387 | int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev_handle,
1388 | int interface_number, int alternate_setting);
1389 | int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev_handle,
1390 | unsigned char endpoint);
1391 | int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev_handle);
1392 |
1393 | int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev_handle,
1394 | uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1395 | int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev_handle,
1396 | unsigned char *endpoints, int num_endpoints);
1397 |
1398 | unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
1399 | size_t length);
1400 | int LIBUSB_CALL libusb_dev_mem_free(libusb_device_handle *dev_handle,
1401 | unsigned char *buffer, size_t length);
1402 |
1403 | int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev_handle,
1404 | int interface_number);
1405 | int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
1406 | int interface_number);
1407 | int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
1408 | int interface_number);
1409 | int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
1410 | libusb_device_handle *dev_handle, int enable);
1411 |
1412 | /* async I/O */
1413 |
1414 | /** \ingroup libusb_asyncio
1415 | * Get the data section of a control transfer. This convenience function is here
1416 | * to remind you that the data does not start until 8 bytes into the actual
1417 | * buffer, as the setup packet comes first.
1418 | *
1419 | * Calling this function only makes sense from a transfer callback function,
1420 | * or situations where you have already allocated a suitably sized buffer at
1421 | * transfer->buffer.
1422 | *
1423 | * \param transfer a transfer
1424 | * \returns pointer to the first byte of the data section
1425 | */
1426 | static inline unsigned char *libusb_control_transfer_get_data(
1427 | struct libusb_transfer *transfer)
1428 | {
1429 | return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
1430 | }
1431 |
1432 | /** \ingroup libusb_asyncio
1433 | * Get the control setup packet of a control transfer. This convenience
1434 | * function is here to remind you that the control setup occupies the first
1435 | * 8 bytes of the transfer data buffer.
1436 | *
1437 | * Calling this function only makes sense from a transfer callback function,
1438 | * or situations where you have already allocated a suitably sized buffer at
1439 | * transfer->buffer.
1440 | *
1441 | * \param transfer a transfer
1442 | * \returns a casted pointer to the start of the transfer data buffer
1443 | */
1444 | static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
1445 | struct libusb_transfer *transfer)
1446 | {
1447 | return (struct libusb_control_setup *)(void *) transfer->buffer;
1448 | }
1449 |
1450 | /** \ingroup libusb_asyncio
1451 | * Helper function to populate the setup packet (first 8 bytes of the data
1452 | * buffer) for a control transfer. The wIndex, wValue and wLength values should
1453 | * be given in host-endian byte order.
1454 | *
1455 | * \param buffer buffer to output the setup packet into
1456 | * This pointer must be aligned to at least 2 bytes boundary.
1457 | * \param bmRequestType see the
1458 | * \ref libusb_control_setup::bmRequestType "bmRequestType" field of
1459 | * \ref libusb_control_setup
1460 | * \param bRequest see the
1461 | * \ref libusb_control_setup::bRequest "bRequest" field of
1462 | * \ref libusb_control_setup
1463 | * \param wValue see the
1464 | * \ref libusb_control_setup::wValue "wValue" field of
1465 | * \ref libusb_control_setup
1466 | * \param wIndex see the
1467 | * \ref libusb_control_setup::wIndex "wIndex" field of
1468 | * \ref libusb_control_setup
1469 | * \param wLength see the
1470 | * \ref libusb_control_setup::wLength "wLength" field of
1471 | * \ref libusb_control_setup
1472 | */
1473 | static inline void libusb_fill_control_setup(unsigned char *buffer,
1474 | uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
1475 | uint16_t wLength)
1476 | {
1477 | struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
1478 | setup->bmRequestType = bmRequestType;
1479 | setup->bRequest = bRequest;
1480 | setup->wValue = libusb_cpu_to_le16(wValue);
1481 | setup->wIndex = libusb_cpu_to_le16(wIndex);
1482 | setup->wLength = libusb_cpu_to_le16(wLength);
1483 | }
1484 |
1485 | struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
1486 | int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
1487 | int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
1488 | void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
1489 | void LIBUSB_CALL libusb_transfer_set_stream_id(
1490 | struct libusb_transfer *transfer, uint32_t stream_id);
1491 | uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
1492 | struct libusb_transfer *transfer);
1493 |
1494 | /** \ingroup libusb_asyncio
1495 | * Helper function to populate the required \ref libusb_transfer fields
1496 | * for a control transfer.
1497 | *
1498 | * If you pass a transfer buffer to this function, the first 8 bytes will
1499 | * be interpreted as a control setup packet, and the wLength field will be
1500 | * used to automatically populate the \ref libusb_transfer::length "length"
1501 | * field of the transfer. Therefore the recommended approach is:
1502 | * -# Allocate a suitably sized data buffer (including space for control setup)
1503 | * -# Call libusb_fill_control_setup()
1504 | * -# If this is a host-to-device transfer with a data stage, put the data
1505 | * in place after the setup packet
1506 | * -# Call this function
1507 | * -# Call libusb_submit_transfer()
1508 | *
1509 | * It is also legal to pass a NULL buffer to this function, in which case this
1510 | * function will not attempt to populate the length field. Remember that you
1511 | * must then populate the buffer and length fields later.
1512 | *
1513 | * \param transfer the transfer to populate
1514 | * \param dev_handle handle of the device that will handle the transfer
1515 | * \param buffer data buffer. If provided, this function will interpret the
1516 | * first 8 bytes as a setup packet and infer the transfer length from that.
1517 | * This pointer must be aligned to at least 2 bytes boundary.
1518 | * \param callback callback function to be invoked on transfer completion
1519 | * \param user_data user data to pass to callback function
1520 | * \param timeout timeout for the transfer in milliseconds
1521 | */
1522 | static inline void libusb_fill_control_transfer(
1523 | struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1524 | unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
1525 | unsigned int timeout)
1526 | {
1527 | struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
1528 | transfer->dev_handle = dev_handle;
1529 | transfer->endpoint = 0;
1530 | transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
1531 | transfer->timeout = timeout;
1532 | transfer->buffer = buffer;
1533 | if (setup)
1534 | transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
1535 | + libusb_le16_to_cpu(setup->wLength));
1536 | transfer->user_data = user_data;
1537 | transfer->callback = callback;
1538 | }
1539 |
1540 | /** \ingroup libusb_asyncio
1541 | * Helper function to populate the required \ref libusb_transfer fields
1542 | * for a bulk transfer.
1543 | *
1544 | * \param transfer the transfer to populate
1545 | * \param dev_handle handle of the device that will handle the transfer
1546 | * \param endpoint address of the endpoint where this transfer will be sent
1547 | * \param buffer data buffer
1548 | * \param length length of data buffer
1549 | * \param callback callback function to be invoked on transfer completion
1550 | * \param user_data user data to pass to callback function
1551 | * \param timeout timeout for the transfer in milliseconds
1552 | */
1553 | static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
1554 | libusb_device_handle *dev_handle, unsigned char endpoint,
1555 | unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1556 | void *user_data, unsigned int timeout)
1557 | {
1558 | transfer->dev_handle = dev_handle;
1559 | transfer->endpoint = endpoint;
1560 | transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
1561 | transfer->timeout = timeout;
1562 | transfer->buffer = buffer;
1563 | transfer->length = length;
1564 | transfer->user_data = user_data;
1565 | transfer->callback = callback;
1566 | }
1567 |
1568 | /** \ingroup libusb_asyncio
1569 | * Helper function to populate the required \ref libusb_transfer fields
1570 | * for a bulk transfer using bulk streams.
1571 | *
1572 | * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1573 | *
1574 | * \param transfer the transfer to populate
1575 | * \param dev_handle handle of the device that will handle the transfer
1576 | * \param endpoint address of the endpoint where this transfer will be sent
1577 | * \param stream_id bulk stream id for this transfer
1578 | * \param buffer data buffer
1579 | * \param length length of data buffer
1580 | * \param callback callback function to be invoked on transfer completion
1581 | * \param user_data user data to pass to callback function
1582 | * \param timeout timeout for the transfer in milliseconds
1583 | */
1584 | static inline void libusb_fill_bulk_stream_transfer(
1585 | struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1586 | unsigned char endpoint, uint32_t stream_id,
1587 | unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1588 | void *user_data, unsigned int timeout)
1589 | {
1590 | libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
1591 | length, callback, user_data, timeout);
1592 | transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
1593 | libusb_transfer_set_stream_id(transfer, stream_id);
1594 | }
1595 |
1596 | /** \ingroup libusb_asyncio
1597 | * Helper function to populate the required \ref libusb_transfer fields
1598 | * for an interrupt transfer.
1599 | *
1600 | * \param transfer the transfer to populate
1601 | * \param dev_handle handle of the device that will handle the transfer
1602 | * \param endpoint address of the endpoint where this transfer will be sent
1603 | * \param buffer data buffer
1604 | * \param length length of data buffer
1605 | * \param callback callback function to be invoked on transfer completion
1606 | * \param user_data user data to pass to callback function
1607 | * \param timeout timeout for the transfer in milliseconds
1608 | */
1609 | static inline void libusb_fill_interrupt_transfer(
1610 | struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1611 | unsigned char endpoint, unsigned char *buffer, int length,
1612 | libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1613 | {
1614 | transfer->dev_handle = dev_handle;
1615 | transfer->endpoint = endpoint;
1616 | transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
1617 | transfer->timeout = timeout;
1618 | transfer->buffer = buffer;
1619 | transfer->length = length;
1620 | transfer->user_data = user_data;
1621 | transfer->callback = callback;
1622 | }
1623 |
1624 | /** \ingroup libusb_asyncio
1625 | * Helper function to populate the required \ref libusb_transfer fields
1626 | * for an isochronous transfer.
1627 | *
1628 | * \param transfer the transfer to populate
1629 | * \param dev_handle handle of the device that will handle the transfer
1630 | * \param endpoint address of the endpoint where this transfer will be sent
1631 | * \param buffer data buffer
1632 | * \param length length of data buffer
1633 | * \param num_iso_packets the number of isochronous packets
1634 | * \param callback callback function to be invoked on transfer completion
1635 | * \param user_data user data to pass to callback function
1636 | * \param timeout timeout for the transfer in milliseconds
1637 | */
1638 | static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
1639 | libusb_device_handle *dev_handle, unsigned char endpoint,
1640 | unsigned char *buffer, int length, int num_iso_packets,
1641 | libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
1642 | {
1643 | transfer->dev_handle = dev_handle;
1644 | transfer->endpoint = endpoint;
1645 | transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
1646 | transfer->timeout = timeout;
1647 | transfer->buffer = buffer;
1648 | transfer->length = length;
1649 | transfer->num_iso_packets = num_iso_packets;
1650 | transfer->user_data = user_data;
1651 | transfer->callback = callback;
1652 | }
1653 |
1654 | /** \ingroup libusb_asyncio
1655 | * Convenience function to set the length of all packets in an isochronous
1656 | * transfer, based on the num_iso_packets field in the transfer structure.
1657 | *
1658 | * \param transfer a transfer
1659 | * \param length the length to set in each isochronous packet descriptor
1660 | * \see libusb_get_max_packet_size()
1661 | */
1662 | static inline void libusb_set_iso_packet_lengths(
1663 | struct libusb_transfer *transfer, unsigned int length)
1664 | {
1665 | int i;
1666 | for (i = 0; i < transfer->num_iso_packets; i++)
1667 | transfer->iso_packet_desc[i].length = length;
1668 | }
1669 |
1670 | /** \ingroup libusb_asyncio
1671 | * Convenience function to locate the position of an isochronous packet
1672 | * within the buffer of an isochronous transfer.
1673 | *
1674 | * This is a thorough function which loops through all preceding packets,
1675 | * accumulating their lengths to find the position of the specified packet.
1676 | * Typically you will assign equal lengths to each packet in the transfer,
1677 | * and hence the above method is sub-optimal. You may wish to use
1678 | * libusb_get_iso_packet_buffer_simple() instead.
1679 | *
1680 | * \param transfer a transfer
1681 | * \param packet the packet to return the address of
1682 | * \returns the base address of the packet buffer inside the transfer buffer,
1683 | * or NULL if the packet does not exist.
1684 | * \see libusb_get_iso_packet_buffer_simple()
1685 | */
1686 | static inline unsigned char *libusb_get_iso_packet_buffer(
1687 | struct libusb_transfer *transfer, unsigned int packet)
1688 | {
1689 | int i;
1690 | size_t offset = 0;
1691 | int _packet;
1692 |
1693 | /* oops..slight bug in the API. packet is an unsigned int, but we use
1694 | * signed integers almost everywhere else. range-check and convert to
1695 | * signed to avoid compiler warnings. FIXME for libusb-2. */
1696 | if (packet > INT_MAX)
1697 | return NULL;
1698 | _packet = (int) packet;
1699 |
1700 | if (_packet >= transfer->num_iso_packets)
1701 | return NULL;
1702 |
1703 | for (i = 0; i < _packet; i++)
1704 | offset += transfer->iso_packet_desc[i].length;
1705 |
1706 | return transfer->buffer + offset;
1707 | }
1708 |
1709 | /** \ingroup libusb_asyncio
1710 | * Convenience function to locate the position of an isochronous packet
1711 | * within the buffer of an isochronous transfer, for transfers where each
1712 | * packet is of identical size.
1713 | *
1714 | * This function relies on the assumption that every packet within the transfer
1715 | * is of identical size to the first packet. Calculating the location of
1716 | * the packet buffer is then just a simple calculation:
1717 | * buffer + (packet_size * packet)
1718 | *
1719 | * Do not use this function on transfers other than those that have identical
1720 | * packet lengths for each packet.
1721 | *
1722 | * \param transfer a transfer
1723 | * \param packet the packet to return the address of
1724 | * \returns the base address of the packet buffer inside the transfer buffer,
1725 | * or NULL if the packet does not exist.
1726 | * \see libusb_get_iso_packet_buffer()
1727 | */
1728 | static inline unsigned char *libusb_get_iso_packet_buffer_simple(
1729 | struct libusb_transfer *transfer, unsigned int packet)
1730 | {
1731 | int _packet;
1732 |
1733 | /* oops..slight bug in the API. packet is an unsigned int, but we use
1734 | * signed integers almost everywhere else. range-check and convert to
1735 | * signed to avoid compiler warnings. FIXME for libusb-2. */
1736 | if (packet > INT_MAX)
1737 | return NULL;
1738 | _packet = (int) packet;
1739 |
1740 | if (_packet >= transfer->num_iso_packets)
1741 | return NULL;
1742 |
1743 | return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
1744 | }
1745 |
1746 | /* sync I/O */
1747 |
1748 | int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
1749 | uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
1750 | unsigned char *data, uint16_t wLength, unsigned int timeout);
1751 |
1752 | int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
1753 | unsigned char endpoint, unsigned char *data, int length,
1754 | int *actual_length, unsigned int timeout);
1755 |
1756 | int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
1757 | unsigned char endpoint, unsigned char *data, int length,
1758 | int *actual_length, unsigned int timeout);
1759 |
1760 | /** \ingroup libusb_desc
1761 | * Retrieve a descriptor from the default control pipe.
1762 | * This is a convenience function which formulates the appropriate control
1763 | * message to retrieve the descriptor.
1764 | *
1765 | * \param dev_handle a device handle
1766 | * \param desc_type the descriptor type, see \ref libusb_descriptor_type
1767 | * \param desc_index the index of the descriptor to retrieve
1768 | * \param data output buffer for descriptor
1769 | * \param length size of data buffer
1770 | * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
1771 | */
1772 | static inline int libusb_get_descriptor(libusb_device_handle *dev_handle,
1773 | uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
1774 | {
1775 | return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
1776 | LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
1777 | 0, data, (uint16_t) length, 1000);
1778 | }
1779 |
1780 | /** \ingroup libusb_desc
1781 | * Retrieve a descriptor from a device.
1782 | * This is a convenience function which formulates the appropriate control
1783 | * message to retrieve the descriptor. The string returned is Unicode, as
1784 | * detailed in the USB specifications.
1785 | *
1786 | * \param dev_handle a device handle
1787 | * \param desc_index the index of the descriptor to retrieve
1788 | * \param langid the language ID for the string descriptor
1789 | * \param data output buffer for descriptor
1790 | * \param length size of data buffer
1791 | * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
1792 | * \see libusb_get_string_descriptor_ascii()
1793 | */
1794 | static inline int libusb_get_string_descriptor(libusb_device_handle *dev_handle,
1795 | uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
1796 | {
1797 | return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
1798 | LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
1799 | langid, data, (uint16_t) length, 1000);
1800 | }
1801 |
1802 | int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
1803 | uint8_t desc_index, unsigned char *data, int length);
1804 |
1805 | /* polling and timeouts */
1806 |
1807 | int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
1808 | void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
1809 | void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
1810 | int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
1811 | int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
1812 | void LIBUSB_CALL libusb_interrupt_event_handler(libusb_context *ctx);
1813 | void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
1814 | void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
1815 | int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
1816 |
1817 | int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
1818 | struct timeval *tv);
1819 | int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
1820 | struct timeval *tv, int *completed);
1821 | int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
1822 | int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
1823 | int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
1824 | struct timeval *tv);
1825 | int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
1826 | int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
1827 | struct timeval *tv);
1828 |
1829 | /** \ingroup libusb_poll
1830 | * File descriptor for polling
1831 | */
1832 | struct libusb_pollfd {
1833 | /** Numeric file descriptor */
1834 | int fd;
1835 |
1836 | /** Event flags to poll for from . POLLIN indicates that you
1837 | * should monitor this file descriptor for becoming ready to read from,
1838 | * and POLLOUT indicates that you should monitor this file descriptor for
1839 | * nonblocking write readiness. */
1840 | short events;
1841 | };
1842 |
1843 | /** \ingroup libusb_poll
1844 | * Callback function, invoked when a new file descriptor should be added
1845 | * to the set of file descriptors monitored for events.
1846 | * \param fd the new file descriptor
1847 | * \param events events to monitor for, see \ref libusb_pollfd for a
1848 | * description
1849 | * \param user_data User data pointer specified in
1850 | * libusb_set_pollfd_notifiers() call
1851 | * \see libusb_set_pollfd_notifiers()
1852 | */
1853 | typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
1854 | void *user_data);
1855 |
1856 | /** \ingroup libusb_poll
1857 | * Callback function, invoked when a file descriptor should be removed from
1858 | * the set of file descriptors being monitored for events. After returning
1859 | * from this callback, do not use that file descriptor again.
1860 | * \param fd the file descriptor to stop monitoring
1861 | * \param user_data User data pointer specified in
1862 | * libusb_set_pollfd_notifiers() call
1863 | * \see libusb_set_pollfd_notifiers()
1864 | */
1865 | typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
1866 |
1867 | const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
1868 | libusb_context *ctx);
1869 | void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
1870 | void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
1871 | libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
1872 | void *user_data);
1873 |
1874 | /** \ingroup libusb_hotplug
1875 | * Callback handle.
1876 | *
1877 | * Callbacks handles are generated by libusb_hotplug_register_callback()
1878 | * and can be used to deregister callbacks. Callback handles are unique
1879 | * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
1880 | * on an already deregisted callback.
1881 | *
1882 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1883 | *
1884 | * For more information, see \ref libusb_hotplug.
1885 | */
1886 | typedef int libusb_hotplug_callback_handle;
1887 |
1888 | /** \ingroup libusb_hotplug
1889 | *
1890 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1891 | *
1892 | * Flags for hotplug events */
1893 | typedef enum {
1894 | /** Default value when not using any flags. */
1895 | LIBUSB_HOTPLUG_NO_FLAGS = 0,
1896 |
1897 | /** Arm the callback and fire it for all matching currently attached devices. */
1898 | LIBUSB_HOTPLUG_ENUMERATE = 1<<0,
1899 | } libusb_hotplug_flag;
1900 |
1901 | /** \ingroup libusb_hotplug
1902 | *
1903 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1904 | *
1905 | * Hotplug events */
1906 | typedef enum {
1907 | /** A device has been plugged in and is ready to use */
1908 | LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01,
1909 |
1910 | /** A device has left and is no longer available.
1911 | * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
1912 | * It is safe to call libusb_get_device_descriptor on a device that has left */
1913 | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02,
1914 | } libusb_hotplug_event;
1915 |
1916 | /** \ingroup libusb_hotplug
1917 | * Wildcard matching for hotplug events */
1918 | #define LIBUSB_HOTPLUG_MATCH_ANY -1
1919 |
1920 | /** \ingroup libusb_hotplug
1921 | * Hotplug callback function type. When requesting hotplug event notifications,
1922 | * you pass a pointer to a callback function of this type.
1923 | *
1924 | * This callback may be called by an internal event thread and as such it is
1925 | * recommended the callback do minimal processing before returning.
1926 | *
1927 | * libusb will call this function later, when a matching event had happened on
1928 | * a matching device. See \ref libusb_hotplug for more information.
1929 | *
1930 | * It is safe to call either libusb_hotplug_register_callback() or
1931 | * libusb_hotplug_deregister_callback() from within a callback function.
1932 | *
1933 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1934 | *
1935 | * \param ctx context of this notification
1936 | * \param device libusb_device this event occurred on
1937 | * \param event event that occurred
1938 | * \param user_data user data provided when this callback was registered
1939 | * \returns bool whether this callback is finished processing events.
1940 | * returning 1 will cause this callback to be deregistered
1941 | */
1942 | typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
1943 | libusb_device *device,
1944 | libusb_hotplug_event event,
1945 | void *user_data);
1946 |
1947 | /** \ingroup libusb_hotplug
1948 | * Register a hotplug callback function
1949 | *
1950 | * Register a callback with the libusb_context. The callback will fire
1951 | * when a matching event occurs on a matching device. The callback is
1952 | * armed until either it is deregistered with libusb_hotplug_deregister_callback()
1953 | * or the supplied callback returns 1 to indicate it is finished processing events.
1954 | *
1955 | * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
1956 | * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
1957 | * already plugged into the machine. Note that libusb modifies its internal
1958 | * device list from a separate thread, while calling hotplug callbacks from
1959 | * libusb_handle_events(), so it is possible for a device to already be present
1960 | * on, or removed from, its internal device list, while the hotplug callbacks
1961 | * still need to be dispatched. This means that when using \ref
1962 | * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
1963 | * of the same device, once from libusb_hotplug_register_callback() and once
1964 | * from libusb_handle_events(); and/or your callback may be called for the
1965 | * removal of a device for which an arrived call was never made.
1966 | *
1967 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1968 | *
1969 | * \param[in] ctx context to register this callback with
1970 | * \param[in] events bitwise or of events that will trigger this callback. See \ref
1971 | * libusb_hotplug_event
1972 | * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
1973 | * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
1974 | * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
1975 | * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
1976 | * \param[in] cb_fn the function to be invoked on a matching event/device
1977 | * \param[in] user_data user data to pass to the callback function
1978 | * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL)
1979 | * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
1980 | */
1981 | int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
1982 | libusb_hotplug_event events,
1983 | libusb_hotplug_flag flags,
1984 | int vendor_id, int product_id,
1985 | int dev_class,
1986 | libusb_hotplug_callback_fn cb_fn,
1987 | void *user_data,
1988 | libusb_hotplug_callback_handle *callback_handle);
1989 |
1990 | /** \ingroup libusb_hotplug
1991 | * Deregisters a hotplug callback.
1992 | *
1993 | * Deregister a callback from a libusb_context. This function is safe to call from within
1994 | * a hotplug callback.
1995 | *
1996 | * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
1997 | *
1998 | * \param[in] ctx context this callback is registered with
1999 | * \param[in] callback_handle the handle of the callback to deregister
2000 | */
2001 | void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
2002 | libusb_hotplug_callback_handle callback_handle);
2003 |
2004 | #ifdef __cplusplus
2005 | }
2006 | #endif
2007 |
2008 | #endif
2009 |
--------------------------------------------------------------------------------
/Source/listdev.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // listdev.cpp
3 | // A sample program to list PL25A1 device and show its information
4 | //
5 | // Created by software team in Prolific on 11/11/2016.
6 | // Copyright (c) 2016 Prolific Corp.. All rights reserved.
7 | //
8 | #include
9 | #include
10 |
11 | #include "libusb.h"
12 | #include "pl25a1.h"
13 |
14 | /*
15 | Main routine
16 | */
17 | int main(void)
18 | {
19 | libusb_device **devices; // Structures representing all USB device detected on the system
20 | int return_code = 0; // Return value from each libusb API
21 | ssize_t no_of_devices; // The number of devices in the device list
22 | int no_of_ports = 0; // The number of elements filled
23 |
24 | libusb_device *device;
25 | int i = 0, j = 0, k = 0;
26 | uint8_t path[8]; // The array that should contain the port numbers
27 | struct libusb_device_descriptor device_descriptor; // structure represents the standard USB device descriptor
28 | struct libusb_config_descriptor *config_desc = NULL; // Structure represents the standard USB configuration descriptor
29 | struct libusb_interface_descriptor interface_descriptor; // A structure represents the standard USB interface descriptor
30 | struct libusb_endpoint_descriptor endpoint; // A structure represents the standard USB endpoint descriptor
31 | struct libusb_device_handle *dev_handle = NULL; /* Structure represents the handles on a USB device */
32 |
33 | // Initialize libusb
34 | return_code = libusb_init(NULL);
35 | if (return_code < LIBUSB_SUCCESS)
36 | return return_code;
37 |
38 | // Returns a list of USB devices currently attached to the system
39 | no_of_devices = libusb_get_device_list(NULL, &devices);
40 | if (no_of_devices < 1)
41 | return (int)no_of_devices;
42 |
43 | printf("Found the folowing devices\n");
44 | while((device = devices[i++]) != NULL) {
45 | return_code = libusb_get_device_descriptor(device, &device_descriptor);
46 | if(return_code < 0) {
47 | fprintf(stderr, "Failed to get device descriptor");
48 | return return_code;
49 | }
50 |
51 | printf("%04x:%04x (bus %d, device %d)",
52 | device_descriptor.idVendor, device_descriptor.idProduct,
53 | libusb_get_bus_number(device), libusb_get_device_address(device));
54 |
55 | // Get the list of all port numbers from root for the specified device
56 | no_of_ports = libusb_get_port_numbers(device, path, sizeof(path));
57 | if (no_of_ports > 0) {
58 | printf(" path: %d", path[0]);
59 | for (k = 1; k < no_of_ports; k++)
60 | printf(".%d", path[k]);
61 | }
62 | printf("\n");
63 |
64 | // Find PL25A1 USB device
65 | if((PROLIFIC_VID == device_descriptor.idVendor) && (PL25A1_PID == device_descriptor.idProduct)) {
66 | // open the target device
67 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
68 | printf("--------------------------------------------------------------\n");
69 | printf(" PL25A1 USB device information\n");
70 |
71 | // Open a device and obtain a device handle
72 | return_code = libusb_open(device, &dev_handle);
73 | if(return_code < 0) {
74 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
75 | libusb_close(dev_handle);
76 |
77 | return return_code;
78 | }
79 | #if defined(__APPLE__)
80 | // Get a USB configuration descriptor based on its index
81 | return_code = libusb_get_config_descriptor(device, 0, &config_desc);
82 | #else
83 | // Get the USB configuration descriptor for the currently active configuration
84 | return_code = libusb_get_active_config_descriptor(device, &config_desc);
85 | #endif
86 |
87 | if(return_code != 0) {
88 | // Close a device handle
89 | libusb_close(dev_handle);
90 | continue;
91 | }
92 | DEBUG("(%s, %s(), L%d) config_desc->bNumInterfaces = %d\n",
93 | __FILE__, __FUNCTION__, __LINE__, config_desc->bNumInterfaces);
94 |
95 | // Find all interfaces in PL25A1
96 | for(j = 0; j < config_desc->bNumInterfaces; j++) {
97 | memcpy(&interface_descriptor, &(config_desc->interface[j].altsetting[0]),
98 | sizeof(struct libusb_interface_descriptor));
99 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
100 | printf(" No. of endpoints = %d\n", interface_descriptor.bNumEndpoints);
101 |
102 | // Find all endpoints in PL25A1
103 | for(k = 0; k < interface_descriptor.bNumEndpoints; k++) {
104 | memcpy(&endpoint, &interface_descriptor.endpoint[k], sizeof(struct libusb_endpoint_descriptor));
105 | DEBUG("(%s, %s(), L%d) endpoint.bmAttributes = %x\n", __FILE__, __FUNCTION__, __LINE__,
106 | endpoint.bmAttributes);
107 |
108 | // Check whether it's control endpoint
109 | if(endpoint.bmAttributes == LIBUSB_TRANSFER_TYPE_CONTROL)
110 | {
111 | DEBUG("(%s, %s(), L%d) \n", __FILE__, __FUNCTION__, __LINE__);
112 | printf(" Found control endpoint No. %d\n", k);
113 | }
114 |
115 | // Check while it's bulk endpoint
116 | if(endpoint.bmAttributes == LIBUSB_TRANSFER_TYPE_BULK)
117 | {
118 | DEBUG("(%s, %s(), L%d) \n", __FILE__, __FUNCTION__, __LINE__);
119 | printf(" Found bulk endpoint No. %d", k);
120 |
121 | // Check whether it's bulk in
122 | if((endpoint.bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK)
123 | == LIBUSB_ENDPOINT_IN) {
124 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
125 | printf(" at address = 0x%02x\n", endpoint.bEndpointAddress);
126 |
127 | if(endpoint.bEndpointAddress != BULK_USB2_EP0_IN_ADDR &&
128 | endpoint.bEndpointAddress != BULK_USB2_EP1_IN_ADDR) {
129 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
130 | break;
131 | }
132 | }
133 |
134 | // Check whether it's bulk out
135 | if((endpoint.bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK)
136 | == LIBUSB_ENDPOINT_OUT) {
137 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
138 | printf(" at address = 0x%02x\n", endpoint.bEndpointAddress);
139 |
140 | if(endpoint.bEndpointAddress != BULK_USB2_EP1_OUT_ADDR) {
141 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
142 | break;
143 | }
144 |
145 | }
146 | }
147 | // Check while it's interrup endpoint
148 | if(endpoint.bmAttributes == LIBUSB_TRANSFER_TYPE_INTERRUPT)
149 | {
150 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
151 | printf(" Found interrupt endpoint No. %d at address = 0x%02x\n", k,
152 | endpoint.bEndpointAddress);
153 | }
154 | }
155 | }
156 |
157 | printf("--------------------------------------------------------------\n");
158 | }
159 | }
160 |
161 | // Frees a list of devices previously discovered using libusb_get_device_list()
162 | libusb_free_device_list(devices, 1);
163 |
164 | libusb_exit(NULL);
165 | return LIBUSB_SUCCESS;
166 | }
167 |
--------------------------------------------------------------------------------
/Source/pl25a1.h:
--------------------------------------------------------------------------------
1 | //
2 | // libpl25A1.h
3 | // Library for accessing Prolific 25A1 USB devices
4 | //
5 | // Created by software team in Prolific on 3/14/2017.
6 | // Copyright (c) 2017 Prolific Corp.. All rights reserved.
7 | //
8 |
9 | #ifndef LIBPL25A1_H
10 | #define LIBPL25A1_H
11 |
12 | #define VERSION 0.92 // Sample code version
13 |
14 | #define DEBUG_ENABLE 0 // True for showing debug messages
15 | #if DEBUG_ENABLE
16 | #define DEBUG printf
17 | #else
18 | #define DEBUG(...)
19 | #endif
20 |
21 | // Prolific USB device definitions
22 | #define PROLIFIC_VID 0x067B // Prolific Vender ID
23 | #define PL25A1_PID 0x25A1 // Prolific Product ID
24 | #define BULK_USB2_EP0_IN_ADDR 0x81 // Interrupt endpoint
25 | #define BULK_USB2_EP1_OUT_ADDR 0x02 // Bulk endpoint 1 Out Address
26 | #define BULK_USB2_EP1_IN_ADDR 0x83 // Bulk endpoint 1 In Address
27 | #define BULK_USB2_EP1_FIFO_SIZE 2048 // FIFO size in PL25A1 USB device is 2KB
28 | #define BULK_USB2_TIMEOUT 5000 // Bulk transfer Timeout in millisecond
29 | #define SLEEP_TIME 1000 // Default sleep time in millisecond
30 |
31 | // Error codes
32 | #define PL_ERROR_SUCCESS 0 // No error
33 | #define PL_ERROR_WRONG_PARA -100 // Wrong input parameter format
34 | #define PL_ERROR_NO_DEVICE -101 // No PL25A1 USB device was found
35 | #define PL_ERROR_WRONG_STATUS -102 // Fail to get PL25A1 USB device status
36 | #define PL_ERROR_WRONG_DEVICE_NO -103 // Fail to get PL25A1 USB device status
37 |
38 | // Hardware connection status
39 | #define DEVICE_STATUS_LOCAL_SUSPEND 0x0001 // Local device is in suspend status
40 | #define DEVICE_STATUS_LOCAL_UNPLUG 0x0002 // Local device is unplug
41 | #define DEVICE_STATUS_REMOTE_SUSPEND 0x0100 // Remote device is in suspend status
42 | #define DEVICE_STATUS_REMOTE_UNPLUG 0x0200 // Remote device is unplug
43 |
44 | // Sender and receiver's definitions
45 | #define PROGRAM_ROLE_UNKNOWN 0
46 | #define PROGRAM_ROLE_SENDER 1 /* The sender of this sample program */
47 | #define PROGRAM_ROLE_RECEIVER 2 /* The receiver of this sample program */
48 |
49 | // Vendor-specific Requests
50 | #define DEVICE_STATUS_LEN 2 // The byte length of return data from GET_STATUS
51 | typedef struct _DEV_STATUS
52 | {
53 | unsigned int localSuspend : 1; // Local device was suspend when it's 1
54 | unsigned int localUnplug : 1; // Local device was unplug when it's 1
55 | unsigned int pad : 6;
56 | unsigned int RemoteSuspend : 1; // Remote device was suspend when it's 1
57 | unsigned int RemoteUnplug : 1; // Remote device was unplug when it's 1
58 | //unsigned int pad2 : 6;
59 | } DEV_STATUS;
60 | /*
61 | Get Device Statuses
62 | DEV_STATUS is a 2-byte array. Byte 0 is for local device status and byte 1 is for remote device status.
63 | For each byte, the following bits indicate:
64 | Bit0: suspend bit, 1 represent suspend
65 | Bit1: unplug bit, 1 represent unplug and 0 represent attached
66 | */
67 | #define VENDOR_SPECIFIC_REQ_GET_STATUS(DEV_HANDLE, DEV_STATUS) \
68 | libusb_control_transfer(DEV_HANDLE, 0xC0, 0xFB, 0, 0, DEV_STATUS, DEVICE_STATUS_LEN, 0)
69 | #endif
70 |
71 |
--------------------------------------------------------------------------------
/Source/plusb.c:
--------------------------------------------------------------------------------
1 | /*
2 | * PL-2301/2302 USB host-to-host link cables
3 | * Copyright (C) 2000-2005 by David Brownell
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, see .
17 | */
18 |
19 | // #define DEBUG // error path messages, extra info
20 | // #define VERBOSE // more; success messages
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 |
32 | /*
33 | * Prolific PL-2301/PL-2302 driver ... http://www.prolific.com.tw/
34 | *
35 | * The protocol and handshaking used here should be bug-compatible
36 | * with the Linux 2.2 "plusb" driver, by Deti Fliegl.
37 | *
38 | * HEADS UP: this handshaking isn't all that robust. This driver
39 | * gets confused easily if you unplug one end of the cable then
40 | * try to connect it again; you'll need to restart both ends. The
41 | * "naplink" software (used by some PlayStation/2 deveopers) does
42 | * the handshaking much better! Also, sometimes this hardware
43 | * seems to get wedged under load. Prolific docs are weak, and
44 | * don't identify differences between PL2301 and PL2302, much less
45 | * anything to explain the different PL2302 versions observed.
46 | *
47 | * NOTE: pl2501 has several modes, including pl2301 and pl2302
48 | * compatibility. Some docs suggest the difference between 2301
49 | * and 2302 is only to make MS-Windows use a different driver...
50 | *
51 | * pl25a1 glue based on patch from Tony Gibbs. Prolific "docs" on
52 | * this chip are as usual incomplete about what control messages
53 | * are supported.
54 | */
55 |
56 | /*
57 | * Bits 0-4 can be used for software handshaking; they're set from
58 | * one end, cleared from the other, "read" with the interrupt byte.
59 | */
60 | #define PL_S_EN (1<<7) /* (feature only) suspend enable */
61 | /* reserved bit -- rx ready (6) ? */
62 | #define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */
63 | #define PL_RESET_OUT (1<<4) /* reset output pipe */
64 | #define PL_RESET_IN (1<<3) /* reset input pipe */
65 | #define PL_TX_C (1<<2) /* transmission complete */
66 | #define PL_TX_REQ (1<<1) /* transmission received */
67 | #define PL_PEER_E (1<<0) /* peer exists */
68 |
69 | static inline int
70 | pl_vendor_req(struct usbnet *dev, u8 req, u8 val, u8 index)
71 | {
72 | return usbnet_read_cmd(dev, req,
73 | USB_DIR_IN | USB_TYPE_VENDOR |
74 | USB_RECIP_DEVICE,
75 | val, index, NULL, 0);
76 | }
77 |
78 | static inline int
79 | pl_clear_QuickLink_features(struct usbnet *dev, int val)
80 | {
81 | return pl_vendor_req(dev, 1, (u8) val, 0);
82 | }
83 |
84 | static inline int
85 | pl_set_QuickLink_features(struct usbnet *dev, int val)
86 | {
87 | return pl_vendor_req(dev, 3, (u8) val, 0);
88 | }
89 |
90 | static int pl_reset(struct usbnet *dev)
91 | {
92 | int status;
93 |
94 | /* some units seem to need this reset, others reject it utterly.
95 | * FIXME be more like "naplink" or windows drivers.
96 | */
97 | if (dev->udev->descriptor.idProduct != 0x25a1)
98 | {
99 | status = pl_set_QuickLink_features(dev,
100 | PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E);
101 | if (status != 0 && netif_msg_probe(dev))
102 | netif_dbg(dev, link, dev->net, "pl_reset --> %d\n", status);
103 | }
104 | return 0;
105 | }
106 |
107 | static const struct driver_info prolific_info = {
108 | .description = "Prolific PL-2301/PL-2302/PL-25A1",
109 | .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT,
110 | /* some PL-2302 versions seem to fail usb_set_interface() */
111 | .reset = pl_reset,
112 | };
113 |
114 |
115 | /*-------------------------------------------------------------------------*/
116 |
117 | /*
118 | * Proilific's name won't normally be on the cables, and
119 | * may not be on the device.
120 | */
121 |
122 | static const struct usb_device_id products [] = {
123 |
124 | /* full speed cables */
125 | {
126 | USB_DEVICE(0x067b, 0x0000), // PL-2301
127 | .driver_info = (unsigned long) &prolific_info,
128 | }, {
129 | USB_DEVICE(0x067b, 0x0001), // PL-2302
130 | .driver_info = (unsigned long) &prolific_info,
131 | },
132 |
133 | /* high speed cables */
134 | {
135 | USB_DEVICE(0x067b, 0x25a1), /* PL-25A1, no eeprom */
136 | .driver_info = (unsigned long) &prolific_info,
137 | }, {
138 | USB_DEVICE(0x050d, 0x258a), /* Belkin F5U258/F5U279 (PL-25A1) */
139 | .driver_info = (unsigned long) &prolific_info,
140 | }, {
141 | USB_DEVICE(0x3923, 0x7825), /* National Instruments USB
142 | * Host-to-Host Cable
143 | */
144 | .driver_info = (unsigned long) &prolific_info,
145 | },
146 |
147 | { }, // END
148 | };
149 | MODULE_DEVICE_TABLE(usb, products);
150 |
151 | static struct usb_driver plusb_driver = {
152 | .name = "plusb",
153 | .id_table = products,
154 | .probe = usbnet_probe,
155 | .disconnect = usbnet_disconnect,
156 | .suspend = usbnet_suspend,
157 | .resume = usbnet_resume,
158 | .disable_hub_initiated_lpm = 1,
159 | };
160 |
161 | module_usb_driver(plusb_driver);
162 |
163 | MODULE_AUTHOR("David Brownell");
164 | MODULE_DESCRIPTION("Prolific PL-2301/2302/25A1 USB Host to Host Link Driver (Modified by Prolific)");
165 | MODULE_LICENSE("GPL");
166 |
--------------------------------------------------------------------------------
/Source/signing_key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCe9KQPVlbC8NVH
3 | K4Z3AMlYlrKf63MpM+g2EorA7Tu4UP3kz+V9WJowKuAqgec/tQ3VqLUTQ0WyPFs7
4 | 6AftI0nM2c0D8vnoMPA3oiuKPuhT///k6j2GQVr/itDntDpfM4lsgVXicAKXFn1M
5 | KZpYKETDc2VGyWlE82mu2Hkm5hYggNTktkNnq4vFMadpm45c9XY5O6hsU2viSxuv
6 | PzF6EkNiQ5LZlb8S5rHzFUkv5MS8t9PlE2aFUxrb2QcUJ+XZlYR9Lg2+3kGO3zNW
7 | oahHiqLlUnLk4imaG7via8JlXnA5pavjCX2baAYlAJRcDSL4B4legHzWjRq7VTcZ
8 | Vm9MqlrFH++VkXJY8+8pyAr1J43tvLn1mRZB58MFwDVvJoLHRq3SKiFmnE7sDFH5
9 | 2lLl57GC2hlg6v/ayPq8eAB4LojtdVXGx00mfNAJr/8fIfOiJoyvw37pDfH6I5QC
10 | SPBGyBOfvfEnmpFVWB3k1GuYVp4ey5ZhP95f4URJqtVgJwqLfbQMkhIVMUmcunCl
11 | HhErJQfSg+XG6+V6V3wPfXI75mqs959DtT+3BfrpNf6ZOz7dSZXgoBbC0dbBPJVY
12 | yOdvxikdcTVjstZJkQ6HyMVb5ujIikn31EUwV2YOpiZRMbzW5UeUeS9WChWh3Xcj
13 | dARpwk479hTrakswdwkrSx+GTeIWPQIDAQABAoICAFI2ZcQo+6bHuQeeU2WpWnof
14 | NzPPKzjcR/XvkSRHjuO9wBNgE2nJMbZH9rkFhv1EP2uKXl0gJiQRY36Qe8kCv2Dc
15 | JVUtjmOxLA0aKzrNXoxTk55qKHgPxWj1+yZb6PTkSud73VfIZw6N6zBBNDr0WNxe
16 | CruZ4IBxBPARtleQGVGmUHYabrJn31qWW+gbNH6P1h2z5WBhpSLdhewV2xkv6Poh
17 | yQoQkUrNVqxLDhdfUwHocgfBCP1cBkA+95JNMGxhEK1N7H4TpgSnHH5qDgcyhR3m
18 | jtYiwzGZtotdAKY9Of4W2dgLSJPgMY1hx1n00WlHPJ1MB0VQpcrOQDkyo04breYF
19 | 0EFRKPO/SExph77E7XpQw9hAsY5l8JUO5HfKp5xd/J4VEm8qy2ec7dLbcpXFKE7r
20 | oUTHRiej8UX3rUFNjJ6bCYlScZKsxhPj58lS7I7Kf7swNtLwDQdF6o5qOyu4gAEl
21 | DYRvpEhFj5XAS0ou+8vfjvv4B/0XPiXxF6ciBBkOJT44QXWgXpfpoHv06fiZqBGl
22 | lZ1txDd0B5erLIJTGMRBw7k4hH78oup85fVq2HwkNwMk1yA9SaOaqmht6HxyQitD
23 | Jy20ypSc1nfU8MKf6u8j46tGSsJfFrK7Bm9RkCxnhBqoomBQaX2COwGyUL0PPQwV
24 | 8V718ZRp0bxQBoheMPhhAoIBAQDR/yw2GWQ8ZLn/PU0L8pt3u7A6C0J9raLcwjh+
25 | HKM7XeYXOBQgS8iBsDhVk1wTtIyLqfjlwuiHGBcqso1L8xlWfwQtmxMV09bTtvm+
26 | +kdZyvIVLuFDngE1mHtpqYNDDvU098xmBVVJkpa+vsF8arOq6vv19jSbht6dPvKz
27 | qPSggTQAlmgl7FgwSY/G7IeJV+8hEPOZjh7VTADWICfiUDmIucIbw1zRhRTf/4+3
28 | shTTfdB+MoBEJHdc/nypgY6ceSkFjSSaLmsZdWoDF66pJe6kg/icf/ZtyhTXaa5A
29 | /rRmhQ5ZMXheHL1+lNnx3VZIEsCt+nIK5QhFC6Zn2vFbcsgzAoIBAQDBxwfEhZG/
30 | PnXu9RvWZMSJhgb7wlG126mVfyBPGkKyAPuWzfr05Lq1yoqG0mFZOp7Jz8X4OcCT
31 | gYlChnadmefhY/1MdPPQp3wTHZIfUcv5TC5N7Waoja2+qOZcNpYtQpWXbK/gEvq5
32 | 1hSBVf8yIJsyWdy/JwcWKjIVKIWLtMO9P82msWfKBLCRs8J2srSehZG3PmrE8h1G
33 | IyjqWvqVBx8RTlAF5Ywp7swPTSSTdM3NnnEyysjk/UNgPRzUh9FfWdB9pNtAl10c
34 | s/fNd9h/Nuzg27GvHW8/4ZDnvfKx6N37KTjAXnhycExD30wBf/Vy59XEtXmemCrE
35 | hebBSlGac/fPAoIBAQDJZLN93rQmx2MpyhyODMnU9od34zyNU20R0qJjMAvL762v
36 | LvT+VC+jUOF2ELEJpOn1N7mggGCIzy3IoRypbicqsP3MzyBqmpM40A6MfXLYRq4M
37 | ar1XH72BLQ+OsidUtI+tkMjSPuMggBlaLY9aRuqwTFP/+3NQhPQSUkBo1Oxm0gKR
38 | Xa3cUOHyzVm6KTWDHnYTfDJjXc1sOkvDD2uwu8exvJTQE3h85+ixOmMWhQ88FTlT
39 | DhO9RkvDP71Gwx2GKxyQWmB0DXhhHh3hgWDcj6hi1r4jOQWZHWkHfi7D3oIcoBa2
40 | q58Igv+o2hB6yQ7qaDGpqLqegDCCJz4b8/ns/hPJAoIBAQCtY/yNWr9pkuhQI77+
41 | /jfmnqkNCXm38pAyFwi//02CneKBtFpEW46+MDf4H7O/9fYzutj4HiU1WAmMH2lv
42 | 6FFWmvQCP/wSzmr1Z9Zic/zCW+prDGx5khzPp65JAQcsBJJ6ZmSRaiozs12xxVOO
43 | dSKp0UL3QGLU8HjT+ehVdDBZ3QeVitTGLaAZH/J357w6xGX4w78h70tGgRuRaEsk
44 | orSn9Z0hSZ87vlOVtX9u+mtU+9tqiY1taTmqmcR8X/N3EJTAeI0/pLFKh7bKgdyV
45 | KH6ZTbwWZ44uaRYSZyMNEsPeg6omZ+H69IUpjlsiVG86nDvpwkDLKnnKU86BUpDm
46 | VbJ9AoIBAClyfw2ftfD3D8X/wO+XMCgjjo/3I4uWGPhiRdZUtl5ar2vfAvR6zL7q
47 | eayWYqS+SgbZsu1/dN6ti9ga8VTqyF82nOtnubaD4cMJ3a3w/eEgDnR6s8l97gCp
48 | kNnj2ExQxAm3yn1IajBqZOubDUol5KLKyIlmXSw6cOIwSvslyAzGp0XrZ+VMXaC9
49 | 13P1ypMy7RzpeKgjAbf98m3zdphUYjeCWxmPodiLgMMIxHkQsxj1ntOeLSaQ10kO
50 | X/c7kKbAuPsONv4oB/DhmfafxQlfjJdBWzCZdzvElrPmx0zZG/PeaAJ3cXgWAnqz
51 | nXT5MooZbuGbuewRMmaDmFbeXR3fy1c=
52 | -----END PRIVATE KEY-----
53 | -----BEGIN CERTIFICATE-----
54 | MIIFPjCCAyagAwIBAgIJAPYFVcuXpZx+MA0GCSqGSIb3DQEBDQUAMC4xLDAqBgNV
55 | BAMMI0J1aWxkIHRpbWUgYXV0b2dlbmVyYXRlZCBrZXJuZWwga2V5MCAXDTE3MDMz
56 | MTEyNTUzNloYDzIxMTcwMzA3MTI1NTM2WjAuMSwwKgYDVQQDDCNCdWlsZCB0aW1l
57 | IGF1dG9nZW5lcmF0ZWQga2VybmVsIGtleTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
58 | ADCCAgoCggIBAJ70pA9WVsLw1UcrhncAyViWsp/rcykz6DYSisDtO7hQ/eTP5X1Y
59 | mjAq4CqB5z+1DdWotRNDRbI8WzvoB+0jSczZzQPy+egw8DeiK4o+6FP//+TqPYZB
60 | Wv+K0Oe0Ol8ziWyBVeJwApcWfUwpmlgoRMNzZUbJaUTzaa7YeSbmFiCA1OS2Q2er
61 | i8Uxp2mbjlz1djk7qGxTa+JLG68/MXoSQ2JDktmVvxLmsfMVSS/kxLy30+UTZoVT
62 | GtvZBxQn5dmVhH0uDb7eQY7fM1ahqEeKouVScuTiKZobu+JrwmVecDmlq+MJfZto
63 | BiUAlFwNIvgHiV6AfNaNGrtVNxlWb0yqWsUf75WRcljz7ynICvUnje28ufWZFkHn
64 | wwXANW8mgsdGrdIqIWacTuwMUfnaUuXnsYLaGWDq/9rI+rx4AHguiO11VcbHTSZ8
65 | 0Amv/x8h86ImjK/DfukN8fojlAJI8EbIE5+98SeakVVYHeTUa5hWnh7LlmE/3l/h
66 | REmq1WAnCot9tAySEhUxSZy6cKUeESslB9KD5cbr5XpXfA99cjvmaqz3n0O1P7cF
67 | +uk1/pk7Pt1JleCgFsLR1sE8lVjI52/GKR1xNWOy1kmRDofIxVvm6MiKSffURTBX
68 | Zg6mJlExvNblR5R5L1YKFaHddyN0BGnCTjv2FOtqSzB3CStLH4ZN4hY9AgMBAAGj
69 | XTBbMAwGA1UdEwEB/wQCMAAwCwYDVR0PBAQDAgeAMB0GA1UdDgQWBBT9d/MrFC5K
70 | jc+XO3cpteJQ/+GIazAfBgNVHSMEGDAWgBT9d/MrFC5Kjc+XO3cpteJQ/+GIazAN
71 | BgkqhkiG9w0BAQ0FAAOCAgEAI0jzRGFZP1BkTlF0FdhxdpsqYTpmD+D+tKqs/1uW
72 | eH4/iFXa9yC+iXOae9qGcqp5ort9YDLj8vsGuvqhBsgqQXoj9P93Lkb4uJth72Go
73 | ZPl//wQAx8LNQr1KdAt5NBhNNkAOHCzMtCKFMERlue41dijYsbptzP458mnSF43j
74 | QNNZU95HFH622cs5WsOtK7WxhopyWS+8EKlgtciLWFeHRKb0I6RYfuuHB31MDjAD
75 | rM8NBz4m3Qt7ByaD6pPqSgIbQroNCS8pQ91JBzwWV5xCDguJnLF4/ryYH0LhpHXg
76 | x/yXvAuWdB6HttFNu/9mKvTUGOMiP17rQDqP7YSc/imtbCAOScnbqEhEFbnAvcgt
77 | lMuGX+TJm1uU72aeJJW/zuWEzQmv3iusqipdS2Y+2gpSQfpQeGT+7wf9VdPEjVgk
78 | 7zxXUUtrNwoqs5chieGm0DUTTLdIK+jB0PTx28VkNlph/OKNrSVoGTaWTT7B+ZkU
79 | jn0s91BSJxmtVm0s2igu2/hRF0BpYcwfu5hNY+6lrmmnldVaE7aLuoBLhqj1rN+n
80 | vALuzDV16BnS66UyxZ9AwxxONnOqzExNQXb8MxWDiMw4azJUa9FraWf3r1P+zCT9
81 | gWd6ioPMq/mULNr2F153YVrMDJTucWmoDBrwRAYi0doQvWQTBnYW1ZP9QqbD6wpG
82 | K40=
83 | -----END CERTIFICATE-----
84 |
--------------------------------------------------------------------------------
/Source/signing_key.x509:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProlificCom/PL25A1_Libusb_SDK/fd621892a4c608501ab690f9f7d473bd1771d512/Source/signing_key.x509
--------------------------------------------------------------------------------
/Source/transmit.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // transmit.cpp
3 | // A simplified program to transmit data from sender to receiver
4 | //
5 | // Created by software team in Prolific on 3/14/2017.
6 | // Copyright (c) 2017 Prolific Corp.. All rights reserved.
7 | //
8 | #include
9 | #include
10 | #include
11 | #include "libusb.h"
12 | #include "pl25a1.h"
13 | #if !defined(_WIN32)
14 | #include
15 | #include
16 | #include
17 | #endif
18 |
19 | static int gProgRole = PROGRAM_ROLE_UNKNOWN; /* The role which this program play */
20 | static bool gkilled = false; /* Be true to kill the thread and then exit this program */
21 | static int g_bulk_interface_no = 0; /* The interface No. you wish to claim */
22 | #define DATA_TRANSFER_SIZE 512 /* 512 bytes for each transfer round */
23 | #define TRANSFER_ROUND_NO 2 /* The number of rounds sender will transmit */
24 |
25 | /*
26 | The called function when the process gets the specified signal(s)
27 | */
28 | static void signal_handler(int signum)
29 | {
30 | gkilled = true;
31 | }
32 |
33 | /*
34 | The receiver thread for receiving data
35 | */
36 | void* receiver_task(void *param)
37 | {
38 | int i; // Index for a loop
39 | int round = 0; // Round number for a loop
40 | int return_code; // Return value of each Prolific API
41 | unsigned char *recvBuf = (unsigned char *)malloc(sizeof(char) * DATA_TRANSFER_SIZE); // Buffer for receiving data
42 | int transferred_size = 0; // Received data in bytes
43 | struct libusb_device_handle **dev_handle = (struct libusb_device_handle **)param; /* Structure of
44 | the opened PL25A1 device handle */
45 |
46 | printf("Flush Endpoint IN FIFO first\n");
47 | return_code = libusb_bulk_transfer(
48 | *dev_handle,
49 | BULK_USB2_EP1_IN_ADDR,
50 | recvBuf,
51 | BULK_USB2_EP1_FIFO_SIZE,
52 | &transferred_size,
53 | BULK_USB2_TIMEOUT
54 | );
55 |
56 | printf("Start to receive the data\n");
57 |
58 | // This tread continuously receive data from the sender
59 | while (!gkilled) {
60 | // Perform a USB bulk transfer
61 | return_code = libusb_bulk_transfer(
62 | *dev_handle,
63 | BULK_USB2_EP1_IN_ADDR,
64 | recvBuf,
65 | DATA_TRANSFER_SIZE,
66 | &transferred_size,
67 | BULK_USB2_TIMEOUT
68 | );
69 |
70 | if (return_code == LIBUSB_ERROR_TIMEOUT) {
71 | // libusb keep return LIBUSB_ERROR_TIMEOUT if no data were be received, and this thread
72 | // keep trying to receive any one
73 | continue;
74 | } else if (return_code != LIBUSB_SUCCESS) {
75 | // Error occurs except LIBUSB_ERROR_TIMEOUT
76 | printf("Fail receiving data from bulk, return_code = %d\n", return_code);
77 | break;
78 | }
79 |
80 | printf ("Receive %d bytes from the sender on round %d\n", transferred_size, round++);
81 |
82 | // Show content of the received data
83 | for (i = 0; i < transferred_size; i++) {
84 | if ((i % 0x10) == 0)
85 | printf("\n");
86 | printf("0x%02x ", recvBuf[i]);
87 | }
88 | printf("\n\n");
89 | }
90 |
91 | free(recvBuf);
92 | return NULL;
93 | }
94 |
95 | /*
96 | The sender thread for sending data
97 | */
98 | void* sender_task(void *param)
99 | {
100 | int i; // Index for a loop
101 | int return_code; // Return value of each Prolific API
102 | unsigned char *sendBuf = (unsigned char *)malloc(sizeof(char) * DATA_TRANSFER_SIZE); // Buffer for sending data
103 | int transferred_size = 0; // Sent data in bytes
104 | struct libusb_device_handle **dev_handle = (struct libusb_device_handle **)param; /* Structure of
105 | the opened PL25A1 device handle */
106 |
107 | // Create the data pattern "sendBuf" to be sent to the receiver
108 | for (i = 0; i < DATA_TRANSFER_SIZE; i++) {
109 | sendBuf[i] = i % 0x100;
110 | }
111 |
112 | printf("Start to send the data\n");
113 |
114 | // This thread send test pattern TRANSFER_ROUND_NO times
115 | for (i = 0; i < TRANSFER_ROUND_NO - 1 && !gkilled; i++) {
116 | transferred_size = 0;
117 |
118 | // Send the data to the sender
119 | return_code = libusb_bulk_transfer (
120 | *dev_handle,
121 | BULK_USB2_EP1_OUT_ADDR,
122 | sendBuf,
123 | DATA_TRANSFER_SIZE,
124 | &transferred_size,
125 | BULK_USB2_TIMEOUT
126 | );
127 |
128 | if (return_code != LIBUSB_SUCCESS) {
129 | printf("Failed writing data to bulk, return_code = %d\n", return_code);
130 | break;
131 | }
132 |
133 | printf ("Sent %d bytes to the receiver\n", transferred_size);
134 |
135 | // Sleep for a while
136 | #if !defined(_WIN32)
137 | usleep(SLEEP_TIME * 1000);
138 | #else
139 | Sleep(SLEEP_TIME);
140 | #endif
141 | }
142 |
143 | // Divide last 512 bytes into 511 bytes and 1 byte to ensure USB host sends short packet in the end.
144 | return_code = libusb_bulk_transfer(
145 | *dev_handle,
146 | BULK_USB2_EP1_OUT_ADDR,
147 | sendBuf,
148 | DATA_TRANSFER_SIZE - 1,
149 | &transferred_size,
150 | BULK_USB2_TIMEOUT
151 | );
152 |
153 | if (return_code != LIBUSB_SUCCESS) {
154 | printf("Failed writing data to bulk, return_code = %d\n", return_code);
155 | }
156 |
157 | printf("Sent %d bytes to the receiver\n", transferred_size);
158 |
159 | return_code = libusb_bulk_transfer(
160 | *dev_handle,
161 | BULK_USB2_EP1_OUT_ADDR,
162 | sendBuf + DATA_TRANSFER_SIZE - 1,
163 | 1,
164 | &transferred_size,
165 | BULK_USB2_TIMEOUT
166 | );
167 |
168 | if (return_code != LIBUSB_SUCCESS) {
169 | printf("Failed writing data to bulk, return_code = %d\n", return_code);
170 | }
171 |
172 | printf("Sent %d bytes to the receiver\n", transferred_size);
173 |
174 |
175 | free(sendBuf);
176 | return NULL;
177 | }
178 |
179 | /*
180 | Main routine
181 | */
182 | int main(int argc, char* argv[])
183 | {
184 | bool found_PL25A1_device = false;
185 | int i = 0; // Indexes for the loops
186 | libusb_device **devices; // Structures representing all USB device detected on the system
187 | libusb_device *device; // Structure representing one USB device detected on the system
188 | int return_code = 0; // Return value from each libusb API
189 | ssize_t no_of_devices; // The number of devices in the device list
190 | #if !defined(_WIN32)
191 | pthread_t thread; // For thread creation
192 | #endif
193 | struct libusb_device_descriptor device_descriptor; // structure represents the standard USB device descriptor
194 | struct libusb_config_descriptor *config_desc = NULL; // Structure represents the standard USB configuration descriptor
195 | struct libusb_device_handle *dev_handle = NULL; /* Structure represents the handles on a USB device */
196 |
197 | // Check command parameters and Initialize the transmission
198 | if (argc != 2) {
199 | printf("Usage:\n\t%s [send/recv]\n", argv[0]);
200 | return PL_ERROR_WRONG_PARA;
201 | } else if (strcmp(argv[1], "send") == 0) {
202 | gProgRole = PROGRAM_ROLE_SENDER;
203 | } else if (strcmp(argv[1], "recv") == 0) {
204 | gProgRole = PROGRAM_ROLE_RECEIVER;
205 | } else {
206 | printf("Usage:\n\t%s [send/recv]\n", argv[0]);
207 | return PL_ERROR_WRONG_PARA;
208 | }
209 |
210 | // Register the signals to exit the program
211 | signal(SIGINT, signal_handler);
212 | #if !defined(_WIN32)
213 | signal(SIGKILL, signal_handler);
214 | signal(SIGQUIT, signal_handler);
215 | signal(SIGSTOP, signal_handler);
216 | #endif
217 | signal(SIGILL, signal_handler);
218 |
219 | // Initialize libusb
220 | return_code = libusb_init(NULL);
221 | if (return_code < LIBUSB_SUCCESS)
222 | return return_code;
223 |
224 | // Returns a list of USB devices currently attached to the system
225 | no_of_devices = libusb_get_device_list(NULL, &devices);
226 | if (no_of_devices < 1)
227 | return PL_ERROR_WRONG_DEVICE_NO;
228 |
229 | // printf("Found the folowing devices\n");
230 | while((device = devices[i++]) != NULL) {
231 | return_code = libusb_get_device_descriptor(device, &device_descriptor);
232 | if(return_code < 0) {
233 | fprintf(stderr, "Failed to get device descriptor");
234 | return return_code;
235 | }
236 |
237 | // Find PL25A1 USB device
238 | if((PROLIFIC_VID == device_descriptor.idVendor) && (PL25A1_PID == device_descriptor.idProduct)) {
239 | found_PL25A1_device = true;
240 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
241 | printf("Found PL25A1 USB device!\n");
242 |
243 | // Open a device and obtain a device handle
244 | return_code = libusb_open(device, &dev_handle);
245 | if(return_code < 0) {
246 | DEBUG("(%s, %s(), L%d)\n", __FILE__, __FUNCTION__, __LINE__);
247 | libusb_close(dev_handle);
248 |
249 | return return_code;
250 | }
251 |
252 | #if defined(__APPLE__)
253 | // Get a USB configuration descriptor based on its index
254 | return_code = libusb_get_config_descriptor(device, 0, &config_desc);
255 | #else
256 | // Get the USB configuration descriptor for the currently active configuration
257 | return_code = libusb_get_active_config_descriptor(device, &config_desc);
258 | #endif
259 | if(return_code != 0) {
260 | // Close a device handle
261 | libusb_close(dev_handle);
262 | continue;
263 | }
264 | DEBUG("(%s, %s(), L%d) config_desc->bNumInterfaces = %d\n",
265 | __FILE__, __FUNCTION__, __LINE__, config_desc->bNumInterfaces);
266 | }
267 | }
268 |
269 | // Check whether any PL25A1 USB device was found
270 | if(!found_PL25A1_device)
271 | {
272 | printf("No PL25A1 USB device was found!\n");
273 | return PL_ERROR_NO_DEVICE;
274 | }
275 |
276 | #if !defined(_WIN32)
277 | // Check whether a kernel driver is attached to interface #0. If so, it need to be detached
278 | if(libusb_kernel_driver_active(dev_handle, g_bulk_interface_no))
279 | {
280 | return_code = libusb_detach_kernel_driver(dev_handle, g_bulk_interface_no);
281 | DEBUG("(%s, %s(), L%d) return_code = %d\n", __FILE__, __FUNCTION__, __LINE__, return_code);
282 | }
283 | #endif
284 |
285 | // Claim an interface on a given device handle
286 | return_code = libusb_claim_interface(dev_handle, g_bulk_interface_no);
287 | DEBUG("(%s, %s(), L%d) return_code = %d\n", __FILE__, __FUNCTION__, __LINE__, return_code);
288 |
289 | // Check local and remote device statuses
290 | DEV_STATUS dev_status;
291 | memset((void *)&dev_status, 0xFF, sizeof(DEV_STATUS));
292 | while (1)
293 | {
294 | // Get device statuses from vendor command
295 | return_code = VENDOR_SPECIFIC_REQ_GET_STATUS(dev_handle, (unsigned char *)&dev_status);
296 | if (return_code < DEVICE_STATUS_LEN)
297 | {
298 | printf("Fail to get PL25A1 USB device status!\n");
299 | return PL_ERROR_WRONG_STATUS;
300 | }
301 | printf("Local device status: %s, %s\n", dev_status.localSuspend ? "Suspend" : "Active",
302 | dev_status.localUnplug ? "Unplug" : "Attached");
303 | printf("Remote device status: %s, %s\n", dev_status.RemoteSuspend ? "Suspend" : "Active",
304 | dev_status.RemoteUnplug ? "Unplug" : "Attached");
305 | // Break the loop when the remote device was attached
306 | if (!dev_status.RemoteUnplug)
307 | break;
308 | #if !defined(_WIN32)
309 | usleep(SLEEP_TIME * 1000);
310 | #else
311 | Sleep(SLEEP_TIME);
312 | #endif
313 | }
314 |
315 | #if defined(_WIN32)
316 | // Run sender or receiver for data transfer
317 | if (gProgRole == PROGRAM_ROLE_RECEIVER) {
318 | // Run receiver's function
319 | receiver_task((void*)&dev_handle);
320 | }
321 | else if (gProgRole == PROGRAM_ROLE_SENDER) {
322 | // Run sender's function
323 | sender_task((void*)&dev_handle);
324 | }
325 | #else
326 | // Create one sender and one receiver for data transfer
327 | if (gProgRole == PROGRAM_ROLE_RECEIVER) {
328 | // Create a thread to run sender's task.
329 | return_code = pthread_create(&thread, NULL, receiver_task, (void*) &dev_handle);
330 | if (return_code != 0) {
331 | printf("Unable to create sender thread.\n");
332 | return -1;
333 | }
334 |
335 | pthread_join(thread, NULL);
336 |
337 | } else if (gProgRole == PROGRAM_ROLE_SENDER) {
338 | // Create a thread to run receiver's task.
339 | return_code = pthread_create(&thread, NULL, sender_task, (void*) &dev_handle);
340 | if (return_code != 0) {
341 | printf("Unable to create receiver thread.\n");
342 | return -1;
343 | }
344 |
345 | pthread_join(thread, NULL);
346 | }
347 | #endif
348 | // Frees a list of devices previously discovered using libusb_get_device_list()
349 | libusb_free_device_list(devices, 1);
350 |
351 | // Exit libusb
352 | libusb_exit(NULL);
353 | return PL_ERROR_SUCCESS;
354 | }
355 |
--------------------------------------------------------------------------------
/Xcode/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | # CocoaPods
31 | #
32 | # We recommend against adding the Pods directory to your .gitignore. However
33 | # you should judge for yourself, the pros and cons are mentioned at:
34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
35 | #
36 | # Pods/
37 |
38 | # Carthage
39 | #
40 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
41 | # Carthage/Checkouts
42 |
43 | Carthage/Build
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51 |
52 | fastlane/report.xml
53 | fastlane/screenshots
54 |
55 | # Code Injection
56 | #
57 | # After new code Injection tools there's a generated folder /iOSInjectionProject
58 | # https://github.com/johnno1962/injectionforxcode
59 |
60 | iOSInjectionProject/
--------------------------------------------------------------------------------
/Xcode/PL25A1/PL25A1.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXAggregateTarget section */
10 | 5D65795F1E7A78E500C66472 /* all */ = {
11 | isa = PBXAggregateTarget;
12 | buildConfigurationList = 5D6579601E7A78E500C66472 /* Build configuration list for PBXAggregateTarget "all" */;
13 | buildPhases = (
14 | );
15 | dependencies = (
16 | 5D6579641E7A78F400C66472 /* PBXTargetDependency */,
17 | 5D6579661E7A78F400C66472 /* PBXTargetDependency */,
18 | 5D6579681E7A78F400C66472 /* PBXTargetDependency */,
19 | 5D65796A1E7A78F400C66472 /* PBXTargetDependency */,
20 | );
21 | name = all;
22 | productName = all;
23 | };
24 | /* End PBXAggregateTarget section */
25 |
26 | /* Begin PBXBuildFile section */
27 | 5D4146091E7A6F6300C3986D /* pl25a1.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D4146081E7A6F6300C3986D /* pl25a1.h */; };
28 | 5D41460D1E7A6F6E00C3986D /* benchmark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460A1E7A6F6E00C3986D /* benchmark.cpp */; };
29 | 5D41460E1E7A6F6E00C3986D /* transmit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460B1E7A6F6E00C3986D /* transmit.cpp */; };
30 | 5D41460F1E7A6F6E00C3986D /* listdev.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460C1E7A6F6E00C3986D /* listdev.cpp */; };
31 | 5D4146101E7A6F7E00C3986D /* listdev.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460C1E7A6F6E00C3986D /* listdev.cpp */; };
32 | 5D4146171E7A6FC500C3986D /* liblibusb.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D980F3E1E7A657500BBEB9B /* liblibusb.a */; };
33 | 5D41461D1E7A6FDA00C3986D /* transmit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460B1E7A6F6E00C3986D /* transmit.cpp */; };
34 | 5D4146241E7A709300C3986D /* liblibusb.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D980F3E1E7A657500BBEB9B /* liblibusb.a */; };
35 | 5D41462A1E7A70A000C3986D /* benchmark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D41460A1E7A6F6E00C3986D /* benchmark.cpp */; };
36 | 5D980F441E7A66AB00BBEB9B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D980EF61E7A3FA100BBEB9B /* IOKit.framework */; };
37 | 5D980F451E7A66B500BBEB9B /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D980EF81E7A3FA900BBEB9B /* CoreFoundation.framework */; };
38 | 5D980F461E7A671300BBEB9B /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980ED21E7A3F1800BBEB9B /* core.c */; };
39 | 5D980F471E7A671300BBEB9B /* descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980ED31E7A3F1800BBEB9B /* descriptor.c */; };
40 | 5D980F481E7A671300BBEB9B /* hotplug.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980ED41E7A3F1800BBEB9B /* hotplug.c */; };
41 | 5D980F4A1E7A671300BBEB9B /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980ED61E7A3F1800BBEB9B /* io.c */; };
42 | 5D980F4D1E7A671300BBEB9B /* strerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980ED91E7A3F1800BBEB9B /* strerror.c */; };
43 | 5D980F4E1E7A671300BBEB9B /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980EDA1E7A3F1800BBEB9B /* sync.c */; };
44 | 5D980F511E7A671300BBEB9B /* threads_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980F061E7A417600BBEB9B /* threads_posix.c */; };
45 | 5D980F531E7A671300BBEB9B /* poll_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980F031E7A415D00BBEB9B /* poll_posix.c */; };
46 | 5D980F551E7A671300BBEB9B /* darwin_usb.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D980F001E7A413900BBEB9B /* darwin_usb.c */; };
47 | 5D980F561E7A671300BBEB9B /* darwin_usb.h in Sources */ = {isa = PBXBuildFile; fileRef = 5D980F011E7A413900BBEB9B /* darwin_usb.h */; };
48 | 5D980F571E7A673C00BBEB9B /* hotplug.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980ED51E7A3F1800BBEB9B /* hotplug.h */; };
49 | 5D980F581E7A673C00BBEB9B /* libusb.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980ED71E7A3F1800BBEB9B /* libusb.h */; };
50 | 5D980F591E7A673C00BBEB9B /* libusbi.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980ED81E7A3F1800BBEB9B /* libusbi.h */; };
51 | 5D980F5A1E7A673C00BBEB9B /* version_nano.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980EDB1E7A3F1800BBEB9B /* version_nano.h */; };
52 | 5D980F5B1E7A673C00BBEB9B /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980EDC1E7A3F1800BBEB9B /* version.h */; };
53 | 5D980F5C1E7A673C00BBEB9B /* threads_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980F071E7A417600BBEB9B /* threads_posix.h */; };
54 | 5D980F5D1E7A673C00BBEB9B /* poll_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980F041E7A415D00BBEB9B /* poll_posix.h */; };
55 | 5D980F5E1E7A673C00BBEB9B /* darwin_usb.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980F011E7A413900BBEB9B /* darwin_usb.h */; };
56 | 5D980F621E7A690B00BBEB9B /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D980F611E7A690B00BBEB9B /* config.h */; };
57 | 5D980F7D1E7A6B0600BBEB9B /* liblibusb.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D980F3E1E7A657500BBEB9B /* liblibusb.a */; };
58 | /* End PBXBuildFile section */
59 |
60 | /* Begin PBXContainerItemProxy section */
61 | 5D4146131E7A6FC500C3986D /* PBXContainerItemProxy */ = {
62 | isa = PBXContainerItemProxy;
63 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
64 | proxyType = 1;
65 | remoteGlobalIDString = 5D980F3D1E7A657500BBEB9B;
66 | remoteInfo = libusb;
67 | };
68 | 5D4146201E7A709300C3986D /* PBXContainerItemProxy */ = {
69 | isa = PBXContainerItemProxy;
70 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
71 | proxyType = 1;
72 | remoteGlobalIDString = 5D980F3D1E7A657500BBEB9B;
73 | remoteInfo = libusb;
74 | };
75 | 5D6579631E7A78F400C66472 /* PBXContainerItemProxy */ = {
76 | isa = PBXContainerItemProxy;
77 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
78 | proxyType = 1;
79 | remoteGlobalIDString = 5D980F3D1E7A657500BBEB9B;
80 | remoteInfo = libusb;
81 | };
82 | 5D6579651E7A78F400C66472 /* PBXContainerItemProxy */ = {
83 | isa = PBXContainerItemProxy;
84 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
85 | proxyType = 1;
86 | remoteGlobalIDString = 5D980F631E7A6A4B00BBEB9B;
87 | remoteInfo = listdev;
88 | };
89 | 5D6579671E7A78F400C66472 /* PBXContainerItemProxy */ = {
90 | isa = PBXContainerItemProxy;
91 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
92 | proxyType = 1;
93 | remoteGlobalIDString = 5D4146111E7A6FC500C3986D;
94 | remoteInfo = transmit;
95 | };
96 | 5D6579691E7A78F400C66472 /* PBXContainerItemProxy */ = {
97 | isa = PBXContainerItemProxy;
98 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
99 | proxyType = 1;
100 | remoteGlobalIDString = 5D41461E1E7A709300C3986D;
101 | remoteInfo = benchmark;
102 | };
103 | 5D980F7B1E7A6AF600BBEB9B /* PBXContainerItemProxy */ = {
104 | isa = PBXContainerItemProxy;
105 | containerPortal = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
106 | proxyType = 1;
107 | remoteGlobalIDString = 5D980F3D1E7A657500BBEB9B;
108 | remoteInfo = libusb;
109 | };
110 | /* End PBXContainerItemProxy section */
111 |
112 | /* Begin PBXCopyFilesBuildPhase section */
113 | 5D4146181E7A6FC500C3986D /* CopyFiles */ = {
114 | isa = PBXCopyFilesBuildPhase;
115 | buildActionMask = 2147483647;
116 | dstPath = /usr/share/man/man1/;
117 | dstSubfolderSpec = 0;
118 | files = (
119 | );
120 | runOnlyForDeploymentPostprocessing = 1;
121 | };
122 | 5D4146251E7A709300C3986D /* CopyFiles */ = {
123 | isa = PBXCopyFilesBuildPhase;
124 | buildActionMask = 2147483647;
125 | dstPath = /usr/share/man/man1/;
126 | dstSubfolderSpec = 0;
127 | files = (
128 | );
129 | runOnlyForDeploymentPostprocessing = 1;
130 | };
131 | 5D980F751E7A6A4B00BBEB9B /* CopyFiles */ = {
132 | isa = PBXCopyFilesBuildPhase;
133 | buildActionMask = 2147483647;
134 | dstPath = /usr/share/man/man1/;
135 | dstSubfolderSpec = 0;
136 | files = (
137 | );
138 | runOnlyForDeploymentPostprocessing = 1;
139 | };
140 | /* End PBXCopyFilesBuildPhase section */
141 |
142 | /* Begin PBXFileReference section */
143 | 5D4146081E7A6F6300C3986D /* pl25a1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pl25a1.h; path = ../../Source/pl25a1.h; sourceTree = ""; };
144 | 5D41460A1E7A6F6E00C3986D /* benchmark.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = benchmark.cpp; path = ../../Source/benchmark.cpp; sourceTree = ""; };
145 | 5D41460B1E7A6F6E00C3986D /* transmit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = transmit.cpp; path = ../../Source/transmit.cpp; sourceTree = ""; };
146 | 5D41460C1E7A6F6E00C3986D /* listdev.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = listdev.cpp; path = ../../Source/listdev.cpp; sourceTree = ""; };
147 | 5D41461C1E7A6FC500C3986D /* transmit */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmit; sourceTree = BUILT_PRODUCTS_DIR; };
148 | 5D4146291E7A709300C3986D /* benchmark */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = benchmark; sourceTree = BUILT_PRODUCTS_DIR; };
149 | 5D980ED21E7A3F1800BBEB9B /* core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = core.c; path = ../../../libusb/libusb/core.c; sourceTree = ""; };
150 | 5D980ED31E7A3F1800BBEB9B /* descriptor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = descriptor.c; path = ../../../libusb/libusb/descriptor.c; sourceTree = ""; };
151 | 5D980ED41E7A3F1800BBEB9B /* hotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hotplug.c; path = ../../../libusb/libusb/hotplug.c; sourceTree = ""; };
152 | 5D980ED51E7A3F1800BBEB9B /* hotplug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hotplug.h; path = ../../../libusb/libusb/hotplug.h; sourceTree = ""; };
153 | 5D980ED61E7A3F1800BBEB9B /* io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = io.c; path = ../../../libusb/libusb/io.c; sourceTree = ""; };
154 | 5D980ED71E7A3F1800BBEB9B /* libusb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libusb.h; path = ../../../libusb/libusb/libusb.h; sourceTree = ""; };
155 | 5D980ED81E7A3F1800BBEB9B /* libusbi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libusbi.h; path = ../../../libusb/libusb/libusbi.h; sourceTree = ""; };
156 | 5D980ED91E7A3F1800BBEB9B /* strerror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = strerror.c; path = ../../../libusb/libusb/strerror.c; sourceTree = ""; };
157 | 5D980EDA1E7A3F1800BBEB9B /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync.c; path = ../../../libusb/libusb/sync.c; sourceTree = ""; };
158 | 5D980EDB1E7A3F1800BBEB9B /* version_nano.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = version_nano.h; path = ../../../libusb/libusb/version_nano.h; sourceTree = ""; };
159 | 5D980EDC1E7A3F1800BBEB9B /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = version.h; path = ../../../libusb/libusb/version.h; sourceTree = ""; };
160 | 5D980EF61E7A3FA100BBEB9B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
161 | 5D980EF81E7A3FA900BBEB9B /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
162 | 5D980F001E7A413900BBEB9B /* darwin_usb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = darwin_usb.c; path = ../../../libusb/libusb/os/darwin_usb.c; sourceTree = ""; };
163 | 5D980F011E7A413900BBEB9B /* darwin_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = darwin_usb.h; path = ../../../libusb/libusb/os/darwin_usb.h; sourceTree = ""; };
164 | 5D980F031E7A415D00BBEB9B /* poll_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = poll_posix.c; path = ../../../libusb/libusb/os/poll_posix.c; sourceTree = ""; };
165 | 5D980F041E7A415D00BBEB9B /* poll_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = poll_posix.h; path = ../../../libusb/libusb/os/poll_posix.h; sourceTree = ""; };
166 | 5D980F061E7A417600BBEB9B /* threads_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = threads_posix.c; path = ../../../libusb/libusb/os/threads_posix.c; sourceTree = ""; };
167 | 5D980F071E7A417600BBEB9B /* threads_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = threads_posix.h; path = ../../../libusb/libusb/os/threads_posix.h; sourceTree = ""; };
168 | 5D980F3E1E7A657500BBEB9B /* liblibusb.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibusb.a; sourceTree = BUILT_PRODUCTS_DIR; };
169 | 5D980F611E7A690B00BBEB9B /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = ../../libusb/Xcode/config.h; sourceTree = ""; };
170 | 5D980F791E7A6A4B00BBEB9B /* listdev */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = listdev; sourceTree = BUILT_PRODUCTS_DIR; };
171 | /* End PBXFileReference section */
172 |
173 | /* Begin PBXFrameworksBuildPhase section */
174 | 5D4146161E7A6FC500C3986D /* Frameworks */ = {
175 | isa = PBXFrameworksBuildPhase;
176 | buildActionMask = 2147483647;
177 | files = (
178 | 5D4146171E7A6FC500C3986D /* liblibusb.a in Frameworks */,
179 | );
180 | runOnlyForDeploymentPostprocessing = 0;
181 | };
182 | 5D4146231E7A709300C3986D /* Frameworks */ = {
183 | isa = PBXFrameworksBuildPhase;
184 | buildActionMask = 2147483647;
185 | files = (
186 | 5D4146241E7A709300C3986D /* liblibusb.a in Frameworks */,
187 | );
188 | runOnlyForDeploymentPostprocessing = 0;
189 | };
190 | 5D980F3B1E7A657500BBEB9B /* Frameworks */ = {
191 | isa = PBXFrameworksBuildPhase;
192 | buildActionMask = 2147483647;
193 | files = (
194 | 5D980F451E7A66B500BBEB9B /* CoreFoundation.framework in Frameworks */,
195 | 5D980F441E7A66AB00BBEB9B /* IOKit.framework in Frameworks */,
196 | );
197 | runOnlyForDeploymentPostprocessing = 0;
198 | };
199 | 5D980F721E7A6A4B00BBEB9B /* Frameworks */ = {
200 | isa = PBXFrameworksBuildPhase;
201 | buildActionMask = 2147483647;
202 | files = (
203 | 5D980F7D1E7A6B0600BBEB9B /* liblibusb.a in Frameworks */,
204 | );
205 | runOnlyForDeploymentPostprocessing = 0;
206 | };
207 | /* End PBXFrameworksBuildPhase section */
208 |
209 | /* Begin PBXGroup section */
210 | 5D4146071E7A6F4000C3986D /* source */ = {
211 | isa = PBXGroup;
212 | children = (
213 | 5D41460A1E7A6F6E00C3986D /* benchmark.cpp */,
214 | 5D41460B1E7A6F6E00C3986D /* transmit.cpp */,
215 | 5D41460C1E7A6F6E00C3986D /* listdev.cpp */,
216 | 5D4146081E7A6F6300C3986D /* pl25a1.h */,
217 | );
218 | name = source;
219 | sourceTree = "";
220 | };
221 | 5D980EB71E7A3E2F00BBEB9B = {
222 | isa = PBXGroup;
223 | children = (
224 | 5D4146071E7A6F4000C3986D /* source */,
225 | 5D980F611E7A690B00BBEB9B /* config.h */,
226 | 5D980ED11E7A3ED000BBEB9B /* libusb */,
227 | 5D980EF51E7A3FA100BBEB9B /* Frameworks */,
228 | 5D980EC11E7A3E2F00BBEB9B /* Products */,
229 | );
230 | sourceTree = "";
231 | };
232 | 5D980EC11E7A3E2F00BBEB9B /* Products */ = {
233 | isa = PBXGroup;
234 | children = (
235 | 5D980F3E1E7A657500BBEB9B /* liblibusb.a */,
236 | 5D980F791E7A6A4B00BBEB9B /* listdev */,
237 | 5D41461C1E7A6FC500C3986D /* transmit */,
238 | 5D4146291E7A709300C3986D /* benchmark */,
239 | );
240 | name = Products;
241 | sourceTree = "";
242 | };
243 | 5D980ED11E7A3ED000BBEB9B /* libusb */ = {
244 | isa = PBXGroup;
245 | children = (
246 | 5D980ED21E7A3F1800BBEB9B /* core.c */,
247 | 5D980ED31E7A3F1800BBEB9B /* descriptor.c */,
248 | 5D980ED41E7A3F1800BBEB9B /* hotplug.c */,
249 | 5D980ED51E7A3F1800BBEB9B /* hotplug.h */,
250 | 5D980ED61E7A3F1800BBEB9B /* io.c */,
251 | 5D980ED71E7A3F1800BBEB9B /* libusb.h */,
252 | 5D980ED81E7A3F1800BBEB9B /* libusbi.h */,
253 | 5D980ED91E7A3F1800BBEB9B /* strerror.c */,
254 | 5D980EDA1E7A3F1800BBEB9B /* sync.c */,
255 | 5D980EDB1E7A3F1800BBEB9B /* version_nano.h */,
256 | 5D980EDC1E7A3F1800BBEB9B /* version.h */,
257 | 5D980EFF1E7A410B00BBEB9B /* os */,
258 | );
259 | name = libusb;
260 | path = PL25A1;
261 | sourceTree = "";
262 | };
263 | 5D980EF51E7A3FA100BBEB9B /* Frameworks */ = {
264 | isa = PBXGroup;
265 | children = (
266 | 5D980EF81E7A3FA900BBEB9B /* CoreFoundation.framework */,
267 | 5D980EF61E7A3FA100BBEB9B /* IOKit.framework */,
268 | );
269 | name = Frameworks;
270 | sourceTree = "";
271 | };
272 | 5D980EFF1E7A410B00BBEB9B /* os */ = {
273 | isa = PBXGroup;
274 | children = (
275 | 5D980F061E7A417600BBEB9B /* threads_posix.c */,
276 | 5D980F071E7A417600BBEB9B /* threads_posix.h */,
277 | 5D980F031E7A415D00BBEB9B /* poll_posix.c */,
278 | 5D980F041E7A415D00BBEB9B /* poll_posix.h */,
279 | 5D980F001E7A413900BBEB9B /* darwin_usb.c */,
280 | 5D980F011E7A413900BBEB9B /* darwin_usb.h */,
281 | );
282 | name = os;
283 | sourceTree = "";
284 | };
285 | /* End PBXGroup section */
286 |
287 | /* Begin PBXHeadersBuildPhase section */
288 | 5D980F3C1E7A657500BBEB9B /* Headers */ = {
289 | isa = PBXHeadersBuildPhase;
290 | buildActionMask = 2147483647;
291 | files = (
292 | 5D980F571E7A673C00BBEB9B /* hotplug.h in Headers */,
293 | 5D980F581E7A673C00BBEB9B /* libusb.h in Headers */,
294 | 5D980F621E7A690B00BBEB9B /* config.h in Headers */,
295 | 5D980F591E7A673C00BBEB9B /* libusbi.h in Headers */,
296 | 5D980F5A1E7A673C00BBEB9B /* version_nano.h in Headers */,
297 | 5D980F5B1E7A673C00BBEB9B /* version.h in Headers */,
298 | 5D980F5C1E7A673C00BBEB9B /* threads_posix.h in Headers */,
299 | 5D980F5D1E7A673C00BBEB9B /* poll_posix.h in Headers */,
300 | 5D980F5E1E7A673C00BBEB9B /* darwin_usb.h in Headers */,
301 | 5D4146091E7A6F6300C3986D /* pl25a1.h in Headers */,
302 | );
303 | runOnlyForDeploymentPostprocessing = 0;
304 | };
305 | /* End PBXHeadersBuildPhase section */
306 |
307 | /* Begin PBXNativeTarget section */
308 | 5D4146111E7A6FC500C3986D /* transmit */ = {
309 | isa = PBXNativeTarget;
310 | buildConfigurationList = 5D4146191E7A6FC500C3986D /* Build configuration list for PBXNativeTarget "transmit" */;
311 | buildPhases = (
312 | 5D4146141E7A6FC500C3986D /* Sources */,
313 | 5D4146161E7A6FC500C3986D /* Frameworks */,
314 | 5D4146181E7A6FC500C3986D /* CopyFiles */,
315 | );
316 | buildRules = (
317 | );
318 | dependencies = (
319 | 5D4146121E7A6FC500C3986D /* PBXTargetDependency */,
320 | );
321 | name = transmit;
322 | productName = PL25A1;
323 | productReference = 5D41461C1E7A6FC500C3986D /* transmit */;
324 | productType = "com.apple.product-type.tool";
325 | };
326 | 5D41461E1E7A709300C3986D /* benchmark */ = {
327 | isa = PBXNativeTarget;
328 | buildConfigurationList = 5D4146261E7A709300C3986D /* Build configuration list for PBXNativeTarget "benchmark" */;
329 | buildPhases = (
330 | 5D4146211E7A709300C3986D /* Sources */,
331 | 5D4146231E7A709300C3986D /* Frameworks */,
332 | 5D4146251E7A709300C3986D /* CopyFiles */,
333 | );
334 | buildRules = (
335 | );
336 | dependencies = (
337 | 5D41461F1E7A709300C3986D /* PBXTargetDependency */,
338 | );
339 | name = benchmark;
340 | productName = PL25A1;
341 | productReference = 5D4146291E7A709300C3986D /* benchmark */;
342 | productType = "com.apple.product-type.tool";
343 | };
344 | 5D980F3D1E7A657500BBEB9B /* libusb */ = {
345 | isa = PBXNativeTarget;
346 | buildConfigurationList = 5D980F3F1E7A657500BBEB9B /* Build configuration list for PBXNativeTarget "libusb" */;
347 | buildPhases = (
348 | 5D980F3A1E7A657500BBEB9B /* Sources */,
349 | 5D980F3B1E7A657500BBEB9B /* Frameworks */,
350 | 5D980F3C1E7A657500BBEB9B /* Headers */,
351 | );
352 | buildRules = (
353 | );
354 | dependencies = (
355 | );
356 | name = libusb;
357 | productName = libusb;
358 | productReference = 5D980F3E1E7A657500BBEB9B /* liblibusb.a */;
359 | productType = "com.apple.product-type.library.static";
360 | };
361 | 5D980F631E7A6A4B00BBEB9B /* listdev */ = {
362 | isa = PBXNativeTarget;
363 | buildConfigurationList = 5D980F761E7A6A4B00BBEB9B /* Build configuration list for PBXNativeTarget "listdev" */;
364 | buildPhases = (
365 | 5D980F641E7A6A4B00BBEB9B /* Sources */,
366 | 5D980F721E7A6A4B00BBEB9B /* Frameworks */,
367 | 5D980F751E7A6A4B00BBEB9B /* CopyFiles */,
368 | );
369 | buildRules = (
370 | );
371 | dependencies = (
372 | 5D980F7C1E7A6AF600BBEB9B /* PBXTargetDependency */,
373 | );
374 | name = listdev;
375 | productName = PL25A1;
376 | productReference = 5D980F791E7A6A4B00BBEB9B /* listdev */;
377 | productType = "com.apple.product-type.tool";
378 | };
379 | /* End PBXNativeTarget section */
380 |
381 | /* Begin PBXProject section */
382 | 5D980EB81E7A3E2F00BBEB9B /* Project object */ = {
383 | isa = PBXProject;
384 | attributes = {
385 | LastUpgradeCheck = 0820;
386 | ORGANIZATIONNAME = vcc;
387 | TargetAttributes = {
388 | 5D4146111E7A6FC500C3986D = {
389 | DevelopmentTeam = 8Q8QP5Q88V;
390 | };
391 | 5D41461E1E7A709300C3986D = {
392 | DevelopmentTeam = 8Q8QP5Q88V;
393 | };
394 | 5D65795F1E7A78E500C66472 = {
395 | CreatedOnToolsVersion = 8.2.1;
396 | DevelopmentTeam = 8Q8QP5Q88V;
397 | ProvisioningStyle = Automatic;
398 | };
399 | 5D980F3D1E7A657500BBEB9B = {
400 | CreatedOnToolsVersion = 8.2.1;
401 | DevelopmentTeam = 8Q8QP5Q88V;
402 | ProvisioningStyle = Automatic;
403 | };
404 | 5D980F631E7A6A4B00BBEB9B = {
405 | DevelopmentTeam = 8Q8QP5Q88V;
406 | };
407 | };
408 | };
409 | buildConfigurationList = 5D980EBB1E7A3E2F00BBEB9B /* Build configuration list for PBXProject "PL25A1" */;
410 | compatibilityVersion = "Xcode 3.2";
411 | developmentRegion = English;
412 | hasScannedForEncodings = 0;
413 | knownRegions = (
414 | en,
415 | );
416 | mainGroup = 5D980EB71E7A3E2F00BBEB9B;
417 | productRefGroup = 5D980EC11E7A3E2F00BBEB9B /* Products */;
418 | projectDirPath = "";
419 | projectRoot = "";
420 | targets = (
421 | 5D980F3D1E7A657500BBEB9B /* libusb */,
422 | 5D980F631E7A6A4B00BBEB9B /* listdev */,
423 | 5D4146111E7A6FC500C3986D /* transmit */,
424 | 5D41461E1E7A709300C3986D /* benchmark */,
425 | 5D65795F1E7A78E500C66472 /* all */,
426 | );
427 | };
428 | /* End PBXProject section */
429 |
430 | /* Begin PBXSourcesBuildPhase section */
431 | 5D4146141E7A6FC500C3986D /* Sources */ = {
432 | isa = PBXSourcesBuildPhase;
433 | buildActionMask = 2147483647;
434 | files = (
435 | 5D41461D1E7A6FDA00C3986D /* transmit.cpp in Sources */,
436 | );
437 | runOnlyForDeploymentPostprocessing = 0;
438 | };
439 | 5D4146211E7A709300C3986D /* Sources */ = {
440 | isa = PBXSourcesBuildPhase;
441 | buildActionMask = 2147483647;
442 | files = (
443 | 5D41462A1E7A70A000C3986D /* benchmark.cpp in Sources */,
444 | );
445 | runOnlyForDeploymentPostprocessing = 0;
446 | };
447 | 5D980F3A1E7A657500BBEB9B /* Sources */ = {
448 | isa = PBXSourcesBuildPhase;
449 | buildActionMask = 2147483647;
450 | files = (
451 | 5D980F461E7A671300BBEB9B /* core.c in Sources */,
452 | 5D980F471E7A671300BBEB9B /* descriptor.c in Sources */,
453 | 5D980F481E7A671300BBEB9B /* hotplug.c in Sources */,
454 | 5D980F4A1E7A671300BBEB9B /* io.c in Sources */,
455 | 5D980F4D1E7A671300BBEB9B /* strerror.c in Sources */,
456 | 5D980F4E1E7A671300BBEB9B /* sync.c in Sources */,
457 | 5D41460D1E7A6F6E00C3986D /* benchmark.cpp in Sources */,
458 | 5D41460E1E7A6F6E00C3986D /* transmit.cpp in Sources */,
459 | 5D980F511E7A671300BBEB9B /* threads_posix.c in Sources */,
460 | 5D980F531E7A671300BBEB9B /* poll_posix.c in Sources */,
461 | 5D980F551E7A671300BBEB9B /* darwin_usb.c in Sources */,
462 | 5D980F561E7A671300BBEB9B /* darwin_usb.h in Sources */,
463 | 5D41460F1E7A6F6E00C3986D /* listdev.cpp in Sources */,
464 | );
465 | runOnlyForDeploymentPostprocessing = 0;
466 | };
467 | 5D980F641E7A6A4B00BBEB9B /* Sources */ = {
468 | isa = PBXSourcesBuildPhase;
469 | buildActionMask = 2147483647;
470 | files = (
471 | 5D4146101E7A6F7E00C3986D /* listdev.cpp in Sources */,
472 | );
473 | runOnlyForDeploymentPostprocessing = 0;
474 | };
475 | /* End PBXSourcesBuildPhase section */
476 |
477 | /* Begin PBXTargetDependency section */
478 | 5D4146121E7A6FC500C3986D /* PBXTargetDependency */ = {
479 | isa = PBXTargetDependency;
480 | target = 5D980F3D1E7A657500BBEB9B /* libusb */;
481 | targetProxy = 5D4146131E7A6FC500C3986D /* PBXContainerItemProxy */;
482 | };
483 | 5D41461F1E7A709300C3986D /* PBXTargetDependency */ = {
484 | isa = PBXTargetDependency;
485 | target = 5D980F3D1E7A657500BBEB9B /* libusb */;
486 | targetProxy = 5D4146201E7A709300C3986D /* PBXContainerItemProxy */;
487 | };
488 | 5D6579641E7A78F400C66472 /* PBXTargetDependency */ = {
489 | isa = PBXTargetDependency;
490 | target = 5D980F3D1E7A657500BBEB9B /* libusb */;
491 | targetProxy = 5D6579631E7A78F400C66472 /* PBXContainerItemProxy */;
492 | };
493 | 5D6579661E7A78F400C66472 /* PBXTargetDependency */ = {
494 | isa = PBXTargetDependency;
495 | target = 5D980F631E7A6A4B00BBEB9B /* listdev */;
496 | targetProxy = 5D6579651E7A78F400C66472 /* PBXContainerItemProxy */;
497 | };
498 | 5D6579681E7A78F400C66472 /* PBXTargetDependency */ = {
499 | isa = PBXTargetDependency;
500 | target = 5D4146111E7A6FC500C3986D /* transmit */;
501 | targetProxy = 5D6579671E7A78F400C66472 /* PBXContainerItemProxy */;
502 | };
503 | 5D65796A1E7A78F400C66472 /* PBXTargetDependency */ = {
504 | isa = PBXTargetDependency;
505 | target = 5D41461E1E7A709300C3986D /* benchmark */;
506 | targetProxy = 5D6579691E7A78F400C66472 /* PBXContainerItemProxy */;
507 | };
508 | 5D980F7C1E7A6AF600BBEB9B /* PBXTargetDependency */ = {
509 | isa = PBXTargetDependency;
510 | target = 5D980F3D1E7A657500BBEB9B /* libusb */;
511 | targetProxy = 5D980F7B1E7A6AF600BBEB9B /* PBXContainerItemProxy */;
512 | };
513 | /* End PBXTargetDependency section */
514 |
515 | /* Begin XCBuildConfiguration section */
516 | 5D41461A1E7A6FC500C3986D /* Debug */ = {
517 | isa = XCBuildConfiguration;
518 | buildSettings = {
519 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
520 | PRODUCT_NAME = "$(TARGET_NAME)";
521 | };
522 | name = Debug;
523 | };
524 | 5D41461B1E7A6FC500C3986D /* Release */ = {
525 | isa = XCBuildConfiguration;
526 | buildSettings = {
527 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
528 | PRODUCT_NAME = "$(TARGET_NAME)";
529 | };
530 | name = Release;
531 | };
532 | 5D4146271E7A709300C3986D /* Debug */ = {
533 | isa = XCBuildConfiguration;
534 | buildSettings = {
535 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
536 | PRODUCT_NAME = "$(TARGET_NAME)";
537 | };
538 | name = Debug;
539 | };
540 | 5D4146281E7A709300C3986D /* Release */ = {
541 | isa = XCBuildConfiguration;
542 | buildSettings = {
543 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
544 | PRODUCT_NAME = "$(TARGET_NAME)";
545 | };
546 | name = Release;
547 | };
548 | 5D6579611E7A78E500C66472 /* Debug */ = {
549 | isa = XCBuildConfiguration;
550 | buildSettings = {
551 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
552 | PRODUCT_NAME = "$(TARGET_NAME)";
553 | };
554 | name = Debug;
555 | };
556 | 5D6579621E7A78E500C66472 /* Release */ = {
557 | isa = XCBuildConfiguration;
558 | buildSettings = {
559 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
560 | PRODUCT_NAME = "$(TARGET_NAME)";
561 | };
562 | name = Release;
563 | };
564 | 5D980EC51E7A3E2F00BBEB9B /* Debug */ = {
565 | isa = XCBuildConfiguration;
566 | buildSettings = {
567 | ALWAYS_SEARCH_USER_PATHS = NO;
568 | CLANG_ANALYZER_NONNULL = YES;
569 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
570 | CLANG_CXX_LIBRARY = "libc++";
571 | CLANG_ENABLE_MODULES = YES;
572 | CLANG_ENABLE_OBJC_ARC = YES;
573 | CLANG_WARN_BOOL_CONVERSION = YES;
574 | CLANG_WARN_CONSTANT_CONVERSION = YES;
575 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
576 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
577 | CLANG_WARN_EMPTY_BODY = YES;
578 | CLANG_WARN_ENUM_CONVERSION = YES;
579 | CLANG_WARN_INFINITE_RECURSION = YES;
580 | CLANG_WARN_INT_CONVERSION = YES;
581 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
582 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
583 | CLANG_WARN_UNREACHABLE_CODE = YES;
584 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
585 | CODE_SIGN_IDENTITY = "-";
586 | COPY_PHASE_STRIP = NO;
587 | DEBUG_INFORMATION_FORMAT = dwarf;
588 | ENABLE_STRICT_OBJC_MSGSEND = YES;
589 | ENABLE_TESTABILITY = YES;
590 | GCC_C_LANGUAGE_STANDARD = gnu99;
591 | GCC_DYNAMIC_NO_PIC = NO;
592 | GCC_NO_COMMON_BLOCKS = YES;
593 | GCC_OPTIMIZATION_LEVEL = 0;
594 | GCC_PREPROCESSOR_DEFINITIONS = (
595 | "DEBUG=1",
596 | "$(inherited)",
597 | );
598 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
599 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
600 | GCC_WARN_UNDECLARED_SELECTOR = YES;
601 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
602 | GCC_WARN_UNUSED_FUNCTION = YES;
603 | GCC_WARN_UNUSED_VARIABLE = YES;
604 | MACOSX_DEPLOYMENT_TARGET = 10.11;
605 | MTL_ENABLE_DEBUG_INFO = YES;
606 | ONLY_ACTIVE_ARCH = YES;
607 | SDKROOT = macosx;
608 | };
609 | name = Debug;
610 | };
611 | 5D980EC61E7A3E2F00BBEB9B /* Release */ = {
612 | isa = XCBuildConfiguration;
613 | buildSettings = {
614 | ALWAYS_SEARCH_USER_PATHS = NO;
615 | CLANG_ANALYZER_NONNULL = YES;
616 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
617 | CLANG_CXX_LIBRARY = "libc++";
618 | CLANG_ENABLE_MODULES = YES;
619 | CLANG_ENABLE_OBJC_ARC = YES;
620 | CLANG_WARN_BOOL_CONVERSION = YES;
621 | CLANG_WARN_CONSTANT_CONVERSION = YES;
622 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
623 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
624 | CLANG_WARN_EMPTY_BODY = YES;
625 | CLANG_WARN_ENUM_CONVERSION = YES;
626 | CLANG_WARN_INFINITE_RECURSION = YES;
627 | CLANG_WARN_INT_CONVERSION = YES;
628 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
629 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
630 | CLANG_WARN_UNREACHABLE_CODE = YES;
631 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
632 | CODE_SIGN_IDENTITY = "-";
633 | COPY_PHASE_STRIP = NO;
634 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
635 | ENABLE_NS_ASSERTIONS = NO;
636 | ENABLE_STRICT_OBJC_MSGSEND = YES;
637 | GCC_C_LANGUAGE_STANDARD = gnu99;
638 | GCC_NO_COMMON_BLOCKS = YES;
639 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
640 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
641 | GCC_WARN_UNDECLARED_SELECTOR = YES;
642 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
643 | GCC_WARN_UNUSED_FUNCTION = YES;
644 | GCC_WARN_UNUSED_VARIABLE = YES;
645 | MACOSX_DEPLOYMENT_TARGET = 10.11;
646 | MTL_ENABLE_DEBUG_INFO = NO;
647 | SDKROOT = macosx;
648 | };
649 | name = Release;
650 | };
651 | 5D980F401E7A657500BBEB9B /* Debug */ = {
652 | isa = XCBuildConfiguration;
653 | buildSettings = {
654 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
655 | EXECUTABLE_PREFIX = lib;
656 | PRODUCT_NAME = "$(TARGET_NAME)";
657 | };
658 | name = Debug;
659 | };
660 | 5D980F411E7A657500BBEB9B /* Release */ = {
661 | isa = XCBuildConfiguration;
662 | buildSettings = {
663 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
664 | EXECUTABLE_PREFIX = lib;
665 | PRODUCT_NAME = "$(TARGET_NAME)";
666 | };
667 | name = Release;
668 | };
669 | 5D980F771E7A6A4B00BBEB9B /* Debug */ = {
670 | isa = XCBuildConfiguration;
671 | buildSettings = {
672 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
673 | PRODUCT_NAME = "$(TARGET_NAME)";
674 | };
675 | name = Debug;
676 | };
677 | 5D980F781E7A6A4B00BBEB9B /* Release */ = {
678 | isa = XCBuildConfiguration;
679 | buildSettings = {
680 | DEVELOPMENT_TEAM = 8Q8QP5Q88V;
681 | PRODUCT_NAME = "$(TARGET_NAME)";
682 | };
683 | name = Release;
684 | };
685 | /* End XCBuildConfiguration section */
686 |
687 | /* Begin XCConfigurationList section */
688 | 5D4146191E7A6FC500C3986D /* Build configuration list for PBXNativeTarget "transmit" */ = {
689 | isa = XCConfigurationList;
690 | buildConfigurations = (
691 | 5D41461A1E7A6FC500C3986D /* Debug */,
692 | 5D41461B1E7A6FC500C3986D /* Release */,
693 | );
694 | defaultConfigurationIsVisible = 0;
695 | defaultConfigurationName = Release;
696 | };
697 | 5D4146261E7A709300C3986D /* Build configuration list for PBXNativeTarget "benchmark" */ = {
698 | isa = XCConfigurationList;
699 | buildConfigurations = (
700 | 5D4146271E7A709300C3986D /* Debug */,
701 | 5D4146281E7A709300C3986D /* Release */,
702 | );
703 | defaultConfigurationIsVisible = 0;
704 | defaultConfigurationName = Release;
705 | };
706 | 5D6579601E7A78E500C66472 /* Build configuration list for PBXAggregateTarget "all" */ = {
707 | isa = XCConfigurationList;
708 | buildConfigurations = (
709 | 5D6579611E7A78E500C66472 /* Debug */,
710 | 5D6579621E7A78E500C66472 /* Release */,
711 | );
712 | defaultConfigurationIsVisible = 0;
713 | };
714 | 5D980EBB1E7A3E2F00BBEB9B /* Build configuration list for PBXProject "PL25A1" */ = {
715 | isa = XCConfigurationList;
716 | buildConfigurations = (
717 | 5D980EC51E7A3E2F00BBEB9B /* Debug */,
718 | 5D980EC61E7A3E2F00BBEB9B /* Release */,
719 | );
720 | defaultConfigurationIsVisible = 0;
721 | defaultConfigurationName = Release;
722 | };
723 | 5D980F3F1E7A657500BBEB9B /* Build configuration list for PBXNativeTarget "libusb" */ = {
724 | isa = XCConfigurationList;
725 | buildConfigurations = (
726 | 5D980F401E7A657500BBEB9B /* Debug */,
727 | 5D980F411E7A657500BBEB9B /* Release */,
728 | );
729 | defaultConfigurationIsVisible = 0;
730 | defaultConfigurationName = Release;
731 | };
732 | 5D980F761E7A6A4B00BBEB9B /* Build configuration list for PBXNativeTarget "listdev" */ = {
733 | isa = XCConfigurationList;
734 | buildConfigurations = (
735 | 5D980F771E7A6A4B00BBEB9B /* Debug */,
736 | 5D980F781E7A6A4B00BBEB9B /* Release */,
737 | );
738 | defaultConfigurationIsVisible = 0;
739 | defaultConfigurationName = Release;
740 | };
741 | /* End XCConfigurationList section */
742 | };
743 | rootObject = 5D980EB81E7A3E2F00BBEB9B /* Project object */;
744 | }
745 |
--------------------------------------------------------------------------------
/Xcode/Xcode.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Xcode/Xcode.xcworkspace/xcshareddata/Xcode.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "5A9F7FBFD990A755C835F4FF742C08E9F439F94D",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 |
5 | },
6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7 | "A0A70348AF94C209E8F52F4CE8B75FC1FF60793F" : 9223372036854775807,
8 | "5A9F7FBFD990A755C835F4FF742C08E9F439F94D" : 9223372036854775807
9 | },
10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "E42A0420-4243-4ADF-8FE0-A9C93D7DCDA3",
11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
12 | "A0A70348AF94C209E8F52F4CE8B75FC1FF60793F" : "PL25A1_Libusb_SDK\/libusb\/",
13 | "5A9F7FBFD990A755C835F4FF742C08E9F439F94D" : "PL25A1_Libusb_SDK\/"
14 | },
15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "Xcode",
16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Xcode\/Xcode.xcworkspace",
18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
19 | {
20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "ssh:\/\/k000.prolific.com.tw\/home\/git\/Playground\/vcc\/PL25A1_SDK",
21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "5A9F7FBFD990A755C835F4FF742C08E9F439F94D"
23 | },
24 | {
25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/libusb\/libusb.git",
26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "A0A70348AF94C209E8F52F4CE8B75FC1FF60793F"
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------