Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ev3-toolbox-matlab
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mindstorms
ev3-toolbox-matlab
Commits
595d4c75
Commit
595d4c75
authored
8 years ago
by
Tim Stadtmann
Browse files
Options
Downloads
Patches
Plain Diff
HIDAPI-interface now creates shorter error IDs
... without using the ID()-function. Fixes issue #50.
parent
23e350ae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/hidapi.m
+17
-17
17 additions, 17 deletions
source/hidapi.m
with
17 additions
and
17 deletions
source/hidapi.m
+
17
−
17
View file @
595d4c75
...
...
@@ -116,7 +116,7 @@ classdef hidapi < handle
end
catch
ME
% Create own exception for clarification
id
=
[
ID
()
,
':'
,
'LoadingLibraryError'
];
id
=
[
hid
.
slib
,
':'
,
'LoadingLibraryError'
];
msg
=
strcat
({
'Could not load library '
},
{
hid
.
slib
},
{
'.'
});
exception
=
MException
(
id
,
msg
);
...
...
@@ -124,7 +124,7 @@ classdef hidapi < handle
if
isempty
(
findstr
(
ME
.
identifier
,
'LoadFailed'
))
...
&&
isempty
(
findstr
(
ME
.
identifier
,
'ErrorLoadingLibrary'
))
...
&&
isempty
(
findstr
(
ME
.
identifier
,
'ErrorInHeader'
))
id
=
[
ID
()
,
':'
,
'InvalidFileNameOrFileMissing'
];
id
=
[
hid
.
slib
,
':'
,
'InvalidFileNameOrFileMissing'
];
msg
=
'Invalid file names were given or files are not available.'
;
cause
=
MException
(
id
,
msg
);
exception
=
addCause
(
exception
,
cause
);
...
...
@@ -221,7 +221,7 @@ classdef hidapi < handle
% (MMI) Assert error case (hid_open returns null-pointer in error case)
assert
(
isLibPointerValid
(
newHandle
)
==
1
,
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to connect to USB device.'
);
hid
.
handle
=
newHandle
;
...
...
@@ -243,7 +243,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to close USB-connection because pointer to USB-device is already invalidated.'
);
% Close the connection
...
...
@@ -275,7 +275,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to read USB-data because pointer to USB-device is invalidated.'
);
% Read data from HID device
...
...
@@ -284,7 +284,7 @@ classdef hidapi < handle
% (MMI) Check the response (No assert as there are multiple cases)
if
res
<
1
% Error occurred
id
=
[
ID
()
,
':'
,
'CommError'
];
id
=
[
hid
.
slib
,
':'
,
'CommError'
];
% Narrow error down
if
res
==
-
1
msg
=
'Connection error (probably lost connection to device)'
;
...
...
@@ -335,7 +335,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to write to USB because pointer to USB-device is invalidated.'
);
% Write the message
...
...
@@ -343,7 +343,7 @@ classdef hidapi < handle
% (MMI) Check the response
assert
(
res
==
length
(
wmsg
),
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to write data via USB.'
);
end
...
...
@@ -374,7 +374,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to read USB-data because pointer to USB-device is invalidated.'
);
% Get the HID info string
...
...
@@ -382,7 +382,7 @@ classdef hidapi < handle
% (MMI) Check the response
assert
(
res
~=-
1
,
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to read HID info string.'
);
% Return the string value
...
...
@@ -408,7 +408,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to set USB-read-mode to non-blocking because pointer to USB-device is invalidated.'
);
% Set non blocking
...
...
@@ -416,7 +416,7 @@ classdef hidapi < handle
% (MMI) Check the response
assert
(
res
~=-
1
,
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to set USB-read-mode to non-blocking.'
);
end
...
...
@@ -436,7 +436,7 @@ classdef hidapi < handle
fprintf
(
'hidapi init\n'
);
end
warning
([
ID
()
,
':'
,
'RedundantCall'
],
...
warning
([
hid
.
slib
,
':'
,
'RedundantCall'
],
...
'The init-function gets called automatically when connecting!'
);
% Init device
...
...
@@ -444,7 +444,7 @@ classdef hidapi < handle
% (MMI) Check the response
assert
(
res
~=-
1
,
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to init USB-device.'
);
end
...
...
@@ -463,7 +463,7 @@ classdef hidapi < handle
fprintf
(
'hidapi exit\n'
);
end
warning
([
ID
()
,
':'
,
'RedundantCall'
],
...
warning
([
hid
.
slib
,
':'
,
'RedundantCall'
],
...
'The exit-function gets called automatically when disconnecting!'
);
% Exit device
...
...
@@ -471,7 +471,7 @@ classdef hidapi < handle
% (MMI) Check the response
assert
(
res
~=-
1
,
...
[
ID
()
,
':'
,
'CommError'
],
...
[
hid
.
slib
,
':'
,
'CommError'
],
...
'Failed to exit USB-device.'
);
end
...
...
@@ -494,7 +494,7 @@ classdef hidapi < handle
% (MMI) Check if pointer is (unexpectedly) already invalidated
assert
(
isLibPointerValid
(
hid
.
handle
)
==
1
,
...
[
ID
()
,
':'
,
'InvalidHandle'
],
...
[
hid
.
slib
,
':'
,
'InvalidHandle'
],
...
'Failed to read USB-error-data because pointer to USB-device is invalidated.'
);
[
~
,
str
]
=
calllib
(
hid
.
slib
,
'hid_error'
,
hid
.
handle
);
...
...
This diff is collapsed.
Click to expand it.
Tim Stadtmann
@tim.stadtmann
·
8 years ago
Author
Developer
#30! Fixes #30!
#30! Fixes #30!
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment