Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Wilkes
purr-data
Commits
01dc43bb
Commit
01dc43bb
authored
11 years ago
by
Ivica Bukvic
Browse files
Options
Downloads
Patches
Plain Diff
fixed hang bug due to multithreaded nature
parent
4a60e3c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
l2ork_addons/raspberry_pi/disis_gpio/disis_gpio.c
+15
-8
15 additions, 8 deletions
l2ork_addons/raspberry_pi/disis_gpio/disis_gpio.c
with
15 additions
and
8 deletions
l2ork_addons/raspberry_pi/disis_gpio/disis_gpio.c
+
15
−
8
View file @
01dc43bb
...
...
@@ -71,9 +71,9 @@ static void *disisSoftPwmThread(void *val)
digitalWrite
(
*
(
p
->
p_pin
),
LOW
)
;
delayMicroseconds
((
1000
-
*
(
p
->
p_val
))
*
10
);
}
//printf("thread exit %d\n", *(p->p_thread));
//
f
printf(
stderr,
"thread exit %d\n", *(p->p_thread));
*
(
p
->
p_thread
)
=
2
;
return
NULL
;
return
NULL
;
}
/*
...
...
@@ -111,6 +111,7 @@ typedef struct _disis_gpio
int
x_dir
;
int
x_pwm
;
int
x_softpwm
;
int
x_waspwm
;
// 0 = no pwm active, 1 = pwm, 2 = softpwm; this is used when reopening connection to retain last state
int
x_softpwmval
;
int
x_softpwm_thread
;
// -1 = not necessary, 0 = start when necessary, 1 = close thread, 2 = thread has been closed
t_params
x_params
;
...
...
@@ -229,6 +230,11 @@ static void disis_gpio_open(t_disis_gpio *x)
x
->
x_fdvalue
=
open
(
buf
,
O_RDWR
);
if
(
x
->
x_fdvalue
<
0
)
{
post
(
"%s: %s"
,
buf
,
strerror
(
errno
));
}
else
{
if
(
x
->
x_softpwm
)
disis_gpio_togglesoftpwm
(
x
,
1
);
if
(
x
->
x_pwm
)
disis_gpio_togglepwm
(
x
,
1
);
}
}
disis_gpio_reflectstatus
(
x
);
...
...
@@ -241,6 +247,7 @@ static void disis_gpio_close(t_disis_gpio *x)
else
{
if
(
x
->
x_softpwm_thread
==
0
)
{
//disis_gpio_togglesoftpwm(x, 0);
x
->
x_softpwm_thread
=
1
;
while
(
x
->
x_softpwm_thread
!=
2
)
usleep
(
100
);
...
...
@@ -271,9 +278,9 @@ static void disis_gpio_pwm(t_disis_gpio *x, t_float val)
int
out
;
if
(
x
->
x_fdvalue
!=
-
1
&&
(
x
->
x_pwm
||
x
->
x_softpwm
))
{
if
((
int
)
val
<
0
)
out
=
0
;
out
=
0
;
else
if
((
int
)
val
>
1023
)
out
=
1023
;
out
=
1023
;
else
out
=
(
int
)
val
;
if
(
x
->
x_pwm
)
pwmWrite
(
x
->
x_pin
,
out
);
...
...
@@ -288,7 +295,7 @@ static void disis_gpio_pwm(t_disis_gpio *x, t_float val)
static
void
disis_gpio_togglesoftpwm
(
t_disis_gpio
*
x
,
t_float
state
)
{
if
(
x
->
x_fdvalue
!=
-
1
)
{
if
(
x
->
x_softpwm
==
(
int
)
state
)
{
if
(
state
&&
x
->
x_softpwm
_thread
!=
-
1
||
!
state
&&
x
->
x_softpwm_thread
==
-
1
)
{
if
(
x
->
x_softpwm
)
post
(
"disis_gpio: soft pwm already enabled"
);
else
...
...
@@ -299,13 +306,12 @@ static void disis_gpio_togglesoftpwm(t_disis_gpio *x, t_float state)
disis_gpio_togglepwm
(
x
,
0
);
post
(
"disis_gpio: disabling hardware pwm"
);
}
x
->
x_softpwm
=
(
int
)
state
;
if
(
x
->
x_softpwm
)
{
if
(
state
&&
x
->
x_softpwm_thread
==
-
1
)
{
x
->
x_softpwm_thread
=
0
;
x
->
x_softpwmval
=
0
;
disisSoftPwmCreate
(
&
x
->
x_params
);
}
else
{
else
if
(
x
->
x_softpwm_thread
!=
-
1
)
{
x
->
x_softpwm_thread
=
1
;
while
(
x
->
x_softpwm_thread
!=
2
)
usleep
(
100
);
...
...
@@ -314,6 +320,7 @@ static void disis_gpio_togglesoftpwm(t_disis_gpio *x, t_float state)
}
}
}
x
->
x_softpwm
=
(
int
)
state
;
}
static
void
disis_gpio_togglepwm
(
t_disis_gpio
*
x
,
t_float
state
)
...
...
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