Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
ethstream
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ba2565dc
authored
Jun 03, 2015
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added clean shutdown of LabJack on ctrl-c
parent
35238c57
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletions
ethstream.c
ethstream.c
View file @
ba2565dc
...
...
@@ -82,11 +82,33 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_li
uint16_t
*
data
,
void
*
context
);
int
columns_left
=
0
;
////////EXTRA GLOBAL VARS///////////
// for clean shutdown //
// added by John Donnal 2015 //
////////////////////////////////////
int
fd_cmd
,
fd_data
;
int
ue9_running
=
0
;
//flag if labjack is currently streaming data
void
handle_sig
(
int
sig
)
{
while
(
columns_left
--
)
{
printf
(
" 0"
);
}
/******************************************************
* added by John Donnal 2015 *
* Close out connection to LabJack, firmware glitches *
* if the stream is not closed correctly *
******************************************************/
if
(
ue9_running
==
1
){
printf
(
"Performing clean shutdown of LabJack
\n
"
);
ue9_stream_stop
(
fd_cmd
);
ue9_buffer_flush
(
fd_cmd
);
ue9_close
(
fd_data
);
ue9_close
(
fd_cmd
);
}
/******************************************************/
fflush
(
stdout
);
exit
(
0
);
}
...
...
@@ -660,7 +682,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
int
convert
,
int
lines
)
{
int
retval
=
-
EAGAIN
;
int
fd_cmd
,
fd_data
;
// int fd_cmd, fd_data; *these are now globals so sighandler can use them*
int
ret
;
static
int
first_call
=
1
;
struct
callbackInfo
ci
=
{
...
...
@@ -730,6 +752,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
}
/* Stream data */
ue9_running
=
1
;
ret
=
ue9_stream_data
(
fd_data
,
channel_count
,
channel_list
,
gain_count
,
gain_list
,
data_callback
,
(
void
*
)
&
ci
);
if
(
ret
<
0
)
{
...
...
@@ -749,6 +772,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
out1:
ue9_close
(
fd_cmd
);
out:
ue9_running
=
0
;
return
retval
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment