Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
moberg
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Mattias Fält
moberg
Commits
4e308e6b
Commit
4e308e6b
authored
4 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Add file-locking for serial2002
parent
a813c679
Branches
Branches containing commit
Tags
v0.9.20
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/serial2002/serial2002.c
+7
-0
7 additions, 0 deletions
plugins/serial2002/serial2002.c
plugins/serial2002/serial2002_lib.c
+4
-1
4 additions, 1 deletion
plugins/serial2002/serial2002_lib.c
with
11 additions
and
1 deletion
plugins/serial2002/serial2002.c
+
7
−
0
View file @
4e308e6b
...
...
@@ -451,6 +451,7 @@ static struct moberg_status device_open(struct moberg_device_context *device)
if
(
device
->
port
.
count
==
0
)
{
fd
=
open
(
device
->
port
.
name
,
O_RDWR
);
if
(
fd
<
0
)
{
goto
err_errno
;
}
if
(
lockf
(
fd
,
F_TLOCK
,
0
))
{
goto
err_errno
;
}
struct
termios2
termios2
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
termios2
)
<
0
)
{
goto
err_errno
;
}
termios2
.
c_iflag
=
0
;
...
...
@@ -492,6 +493,7 @@ err_errno:
result
=
MOBERG_ERRNO
(
errno
);
err_result:
if
(
fd
>=
0
)
{
lockf
(
fd
,
F_ULOCK
,
0
);
close
(
fd
);
}
return
result
;
...
...
@@ -502,6 +504,7 @@ static struct moberg_status device_close(struct moberg_device_context *device)
if
(
device
->
port
.
count
<
0
)
{
errno
=
ENODEV
;
goto
err_errno
;
}
device
->
port
.
count
--
;
if
(
device
->
port
.
count
==
0
)
{
lockf
(
device
->
port
.
io
.
fd
,
F_ULOCK
,
0
);
if
(
close
(
device
->
port
.
io
.
fd
)
<
0
)
{
goto
err_errno
;
}
}
return
MOBERG_OK
;
...
...
@@ -531,6 +534,9 @@ static int channel_down(struct moberg_channel *channel)
static
struct
moberg_status
channel_open
(
struct
moberg_channel
*
channel
)
{
struct
moberg_status
result
=
device_open
(
channel
->
context
->
device
);
if
(
!
OK
(
result
))
{
goto
return_result
;
}
int
count
=
0
;
switch
(
channel
->
kind
)
{
case
chan_ANALOGIN
:
...
...
@@ -553,6 +559,7 @@ static struct moberg_status channel_open(struct moberg_channel *channel)
device_close
(
channel
->
context
->
device
);
result
=
MOBERG_ERRNO
(
ENODEV
);
}
return_result:
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
plugins/serial2002/serial2002_lib.c
+
4
−
1
View file @
4e308e6b
...
...
@@ -287,7 +287,10 @@ static void discard_pending(struct serial2002_io *io)
break
;
}
else
{
char
discard
;
read
(
io
->
fd
,
&
discard
,
1
);
err
=
read
(
io
->
fd
,
&
discard
,
1
);
if
(
err
<=
0
)
{
break
;
}
}
}
}
...
...
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