Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
056b25e1
Commit
056b25e1
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
slight input changes to get_usb_stat
parent
9a5858db
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dongle.c
+14
-9
14 additions, 9 deletions
dongle.c
dongle.h
+1
-1
1 addition, 1 deletion
dongle.h
with
15 additions
and
10 deletions
dongle.c
+
14
−
9
View file @
056b25e1
...
@@ -285,12 +285,12 @@ void remove_newline(char *input)
...
@@ -285,12 +285,12 @@ void remove_newline(char *input)
*
pos
=
'\0'
;
*
pos
=
'\0'
;
}
}
char
*
get_usb_stat
(
char
*
path
,
char
*
dir
,
char
*
stat
)
char
*
get_usb_stat
(
char
*
path
,
char
*
file
)
{
{
char
stat_path
[
PATH_MAX
],
contents
[
1024
];
char
stat_path
[
PATH_MAX
],
contents
[
1024
];
FILE
*
f
;
FILE
*
f
;
snprintf
(
stat_path
,
PATH_MAX
,
"%s
/%s/
%s"
,
path
,
dir
,
stat
);
snprintf
(
stat_path
,
PATH_MAX
,
"%s%s"
,
path
,
file
);
f
=
fopen
(
stat_path
,
"r"
);
f
=
fopen
(
stat_path
,
"r"
);
if
(
!
f
)
{
if
(
!
f
)
{
perror
(
"fopen"
);
perror
(
"fopen"
);
...
@@ -417,18 +417,20 @@ int get_devices_from_path(char *input_path)
...
@@ -417,18 +417,20 @@ int get_devices_from_path(char *input_path)
continue
;
continue
;
}
}
snprintf
(
path
,
PATH_MAX
,
"%s/"
,
input_path
);
snprintf
(
path
,
PATH_MAX
,
"%s/"
,
input_path
);
name
=
get_device_name
(
path
);
name
=
get_device_name
(
path
);
if
(
!
name
)
if
(
!
name
)
continue
;
continue
;
printf
(
"found device inside _from_path %s
\n
"
,
name
);
dev
=
(
struct
device
*
)
calloc
(
1
,
sizeof
(
*
dev
));
dev
=
(
struct
device
*
)
calloc
(
1
,
sizeof
(
*
dev
));
if
(
!
dev
)
{
if
(
!
dev
)
{
perror
(
"calloc"
);
perror
(
"calloc"
);
goto
fail_dev
;
goto
fail_dev
;
}
}
dev
->
usb
.
product
=
get_usb_stat
(
input_path
,
""
,
"product"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
input_path
,
""
,
"idProduct"
);
dev
->
usb
.
product
=
get_usb_stat
(
path
,
"product"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
input_path
,
""
,
"idVendor"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
path
,
"idProduct"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
path
,
"idVendor"
);
dev
->
usb
.
if_name
=
name
;
dev
->
usb
.
if_name
=
name
;
dev
->
ip
=
get_device_ip
(
dev
->
usb
.
if_name
);
dev
->
ip
=
get_device_ip
(
dev
->
usb
.
if_name
);
...
@@ -466,12 +468,14 @@ int get_devices(void)
...
@@ -466,12 +468,14 @@ int get_devices(void)
if
(
strstr
(
de
->
d_name
,
":"
)
||
strstr
(
de
->
d_name
,
"usb"
))
if
(
strstr
(
de
->
d_name
,
":"
)
||
strstr
(
de
->
d_name
,
"usb"
))
continue
;
continue
;
snprintf
(
product_path
,
PATH_MAX
,
"%s%s/product"
,
usb_path
,
de
->
d_name
);
snprintf
(
product_path
,
PATH_MAX
,
"%s%s/product"
,
usb_path
,
de
->
d_name
);
memset
(
&
st
,
0
,
sizeof
(
st
));
memset
(
&
st
,
0
,
sizeof
(
st
));
rv
=
stat
(
product_path
,
&
st
);
rv
=
stat
(
product_path
,
&
st
);
if
(
rv
<
0
)
{
if
(
rv
<
0
)
{
//perror("stat");
//perror("stat");
continue
;
continue
;
}
}
snprintf
(
path
,
PATH_MAX
,
"%s%s/"
,
usb_path
,
de
->
d_name
);
snprintf
(
path
,
PATH_MAX
,
"%s%s/"
,
usb_path
,
de
->
d_name
);
name
=
get_device_name
(
path
);
name
=
get_device_name
(
path
);
if
(
!
name
)
if
(
!
name
)
...
@@ -481,9 +485,10 @@ int get_devices(void)
...
@@ -481,9 +485,10 @@ int get_devices(void)
perror
(
"calloc"
);
perror
(
"calloc"
);
goto
fail_dev
;
goto
fail_dev
;
}
}
dev
->
usb
.
product
=
get_usb_stat
(
usb_path
,
de
->
d_name
,
"product"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
usb_path
,
de
->
d_name
,
"idProduct"
);
dev
->
usb
.
product
=
get_usb_stat
(
path
,
"product"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
usb_path
,
de
->
d_name
,
"idVendor"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
path
,
"idProduct"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
path
,
"idVendor"
);
dev
->
usb
.
if_name
=
name
;
dev
->
usb
.
if_name
=
name
;
dev
->
ip
=
get_device_ip
(
dev
->
usb
.
if_name
);
dev
->
ip
=
get_device_ip
(
dev
->
usb
.
if_name
);
...
...
This diff is collapsed.
Click to expand it.
dongle.h
+
1
−
1
View file @
056b25e1
...
@@ -35,7 +35,7 @@ void free_usb(struct USB *usb);
...
@@ -35,7 +35,7 @@ void free_usb(struct USB *usb);
struct
device
*
search_list
(
char
*
name
);
struct
device
*
search_list
(
char
*
name
);
char
*
lexer
(
char
**
input
,
char
*
delimiter
);
char
*
lexer
(
char
**
input
,
char
*
delimiter
);
void
remove_newline
(
char
*
input
);
void
remove_newline
(
char
*
input
);
char
*
get_usb_stat
(
char
*
path
,
char
*
dir
,
char
*
stat
);
char
*
get_usb_stat
(
char
*
path
,
char
*
file
);
char
*
get_device_name
(
char
*
dir_name
);
char
*
get_device_name
(
char
*
dir_name
);
char
*
get_device_ip
(
char
*
device_name
);
char
*
get_device_ip
(
char
*
device_name
);
int
list_to_blob
(
struct
blob_buf
*
bb
);
int
list_to_blob
(
struct
blob_buf
*
bb
);
...
...
This diff is collapsed.
Click to expand it.
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