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
01359f47
authored
Jan 05, 2017
by
YOUR NAME
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added raw binary output mode
parent
0b1ad741
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
.gitignore
ethstream.c
ethstream.h
.gitignore
View file @
01359f47
ethstream
ethstream
ethstream.1
ethstream.1
ethstream.txt
ethstream.txt
*.d
*.o
\ No newline at end of file
ethstream.c
View file @
01359f47
...
@@ -59,6 +59,7 @@ struct options opt[] = {
...
@@ -59,6 +59,7 @@ struct options opt[] = {
{
'f'
,
"forceretry"
,
NULL
,
"retry no matter what happens"
},
{
'f'
,
"forceretry"
,
NULL
,
"retry no matter what happens"
},
{
'c'
,
"convert"
,
NULL
,
"convert output to volts/temperature"
},
{
'c'
,
"convert"
,
NULL
,
"convert output to volts/temperature"
},
{
'H'
,
"converthex"
,
NULL
,
"convert output to hex"
},
{
'H'
,
"converthex"
,
NULL
,
"convert output to hex"
},
{
'B'
,
"convertbinary"
,
NULL
,
"output raw binary data"
},
{
'm'
,
"showmem"
,
NULL
,
"output memory stats with data (NJ only)"
},
{
'm'
,
"showmem"
,
NULL
,
"output memory stats with data (NJ only)"
},
{
'l'
,
"lines"
,
"num"
,
"if set, output this many lines and quit"
},
{
'l'
,
"lines"
,
"num"
,
"if set, output this many lines and quit"
},
{
'h'
,
"help"
,
NULL
,
"this help"
},
{
'h'
,
"help"
,
NULL
,
"this help"
},
...
@@ -102,7 +103,6 @@ void handle_sig(int sig)
...
@@ -102,7 +103,6 @@ void handle_sig(int sig)
* if the stream is not closed correctly *
* if the stream is not closed correctly *
******************************************************/
******************************************************/
if
(
ue9_running
==
1
){
if
(
ue9_running
==
1
){
printf
(
"Performing clean shutdown of LabJack
\n
"
);
ue9_stream_stop
(
fd_cmd
);
ue9_stream_stop
(
fd_cmd
);
ue9_buffer_flush
(
fd_cmd
);
ue9_buffer_flush
(
fd_cmd
);
ue9_close
(
fd_data
);
ue9_close
(
fd_data
);
...
@@ -324,6 +324,15 @@ int main(int argc, char *argv[])
...
@@ -324,6 +324,15 @@ int main(int argc, char *argv[])
}
}
convert
=
CONVERT_HEX
;
convert
=
CONVERT_HEX
;
break
;
break
;
case
'B'
:
if
(
convert
!=
0
)
{
info
(
"specify only one conversion type
\n
"
);
goto
printhelp
;
}
convert
=
CONVERT_BINARY
;
// convert stdout to binary stream
// freopen (NULL,"wb",stdout);
break
;
case
'm'
:
case
'm'
:
showmem
++
;
showmem
++
;
case
'v'
:
case
'v'
:
...
@@ -782,6 +791,16 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_lis
...
@@ -782,6 +791,16 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_lis
struct
callbackInfo
*
ci
=
(
struct
callbackInfo
*
)
context
;
struct
callbackInfo
*
ci
=
(
struct
callbackInfo
*
)
context
;
static
int
lines
=
0
;
static
int
lines
=
0
;
if
(
ci
->
convert
==
CONVERT_BINARY
)
{
/* CONVERT_BINARY */
if
(
fwrite
(
data
,
sizeof
(
uint16_t
),
channels
,
stdout
)
<
0
)
goto
bad
;
lines
++
;
if
(
ci
->
maxlines
&&
lines
>=
ci
->
maxlines
)
return
-
1
;
return
0
;
}
columns_left
=
channels
;
columns_left
=
channels
;
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
if
(
ci
->
convert
==
CONVERT_VOLTS
&&
if
(
ci
->
convert
==
CONVERT_VOLTS
&&
...
@@ -809,7 +828,8 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_lis
...
@@ -809,7 +828,8 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_lis
/* CONVERT_HEX */
/* CONVERT_HEX */
if
(
printf
(
"%04X"
,
data
[
i
])
<
0
)
if
(
printf
(
"%04X"
,
data
[
i
])
<
0
)
goto
bad
;
goto
bad
;
}
else
{
}
else
{
/* CONVERT_DEC */
/* CONVERT_DEC */
if
(
printf
(
"%d"
,
data
[
i
])
<
0
)
if
(
printf
(
"%d"
,
data
[
i
])
<
0
)
goto
bad
;
goto
bad
;
...
...
ethstream.h
View file @
01359f47
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#define CONVERT_DEC 0
#define CONVERT_DEC 0
#define CONVERT_VOLTS 1
#define CONVERT_VOLTS 1
#define CONVERT_HEX 2
#define CONVERT_HEX 2
#define CONVERT_BINARY 3
#define TIMEOUT 5
/* Timeout for connect/send/recv, in seconds */
#define TIMEOUT 5
/* Timeout for connect/send/recv, in seconds */
...
...
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