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
dbca3e03
Commit
dbca3e03
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
update dongle.c to rely more on hotplug events
parent
afad6212
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dongle.c
+27
-6
27 additions, 6 deletions
dongle.c
with
27 additions
and
6 deletions
dongle.c
+
27
−
6
View file @
dbca3e03
...
@@ -426,9 +426,9 @@ int get_devices_from_path(char *input_path)
...
@@ -426,9 +426,9 @@ int get_devices_from_path(char *input_path)
perror
(
"calloc"
);
perror
(
"calloc"
);
goto
fail_dev
;
goto
fail_dev
;
}
}
dev
->
usb
.
product
=
get_usb_stat
(
input_path
,
de
->
d_name
,
"product"
);
dev
->
usb
.
product
=
get_usb_stat
(
input_path
,
""
,
"product"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
input_path
,
de
->
d_name
,
"idProduct"
);
dev
->
usb
.
product_id
=
get_usb_stat
(
input_path
,
""
,
"idProduct"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
input_path
,
de
->
d_name
,
"idVendor"
);
dev
->
usb
.
vendor_id
=
get_usb_stat
(
input_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
);
...
@@ -650,6 +650,15 @@ int alert(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -650,6 +650,15 @@ int alert(struct ubus_context *ctx, struct ubus_object *obj,
goto
fail
;
goto
fail
;
usb_path
=
(
char
*
)
blobmsg_data
(
tb
[
USB_PATH
]);
usb_path
=
(
char
*
)
blobmsg_data
(
tb
[
USB_PATH
]);
/* FIX THROUGH BASH SCRIPT INSTEAD... */
if
(
strstr
(
usb_path
,
":"
))
{
printf
(
"contained :
\n
"
);
goto
fail
;
}
printf
(
"did not contain :
\n
"
);
printf
(
"%s
\n
"
,
usb_path
);
get_devices_from_path
(
usb_path
);
get_devices_from_path
(
usb_path
);
return
0
;
return
0
;
fail:
fail:
...
@@ -676,13 +685,25 @@ fail:
...
@@ -676,13 +685,25 @@ fail:
return
UBUS_STATUS_INVALID_ARGUMENT
;
return
UBUS_STATUS_INVALID_ARGUMENT
;
}
}
int
update
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
{
printf
(
"lets update!
\n
"
);
get_devices
();
tag_missing_devices
();
return
0
;
}
struct
ubus_method
dongle_object_methods
[]
=
{
struct
ubus_method
dongle_object_methods
[]
=
{
UBUS_METHOD_NOARG
(
"test"
,
test
),
UBUS_METHOD_NOARG
(
"test"
,
test
),
UBUS_METHOD_NOARG
(
"list"
,
print_list
),
UBUS_METHOD_NOARG
(
"list"
,
print_list
),
UBUS_METHOD_NOARG
(
"clear"
,
clear
),
UBUS_METHOD_NOARG
(
"clear"
,
clear
),
UBUS_METHOD
(
"remove_device"
,
remove_device
,
dev_policy
),
UBUS_METHOD
(
"remove_device"
,
remove_device
,
dev_policy
),
UBUS_METHOD
(
"alert"
,
alert
,
usb_policy
)
UBUS_METHOD
(
"alert"
,
alert
,
usb_policy
),
};
UBUS_METHOD_NOARG
(
"update"
,
update
)
};
struct
ubus_object_type
dongle_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
dongle_object_methods
);
struct
ubus_object_type
dongle_object_type
=
UBUS_OBJECT_TYPE
(
"dongle"
,
dongle_object_methods
);
...
@@ -695,7 +716,7 @@ struct ubus_object dongle_object = {
...
@@ -695,7 +716,7 @@ struct ubus_object dongle_object = {
void
uloop_add_get_devices
(
struct
uloop_timeout
*
t
)
void
uloop_add_get_devices
(
struct
uloop_timeout
*
t
)
{
{
uloop_timeout_set
(
t
,
5
000
);
uloop_timeout_set
(
t
,
60
000
);
uloop_timeout_add
(
t
);
uloop_timeout_add
(
t
);
}
}
...
...
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