Commit 8bb6de6c by Daisy Green

added binary output mode for nerdjack

parent 01359f47
Showing with 21 additions and 5 deletions
......@@ -429,7 +429,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
double voltline[numChannels];
unsigned short dataline[numChannels];
uint16_t dataline[numChannels];
unsigned short packetsready = 0;
unsigned short adcused = 0;
......@@ -544,7 +544,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
case CONVERT_HEX:
case CONVERT_DEC:
dataline[i] =
(unsigned short)(datapoint -
(uint16_t)(datapoint -
INT16_MIN);
break;
}
......@@ -553,12 +553,16 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
if (linesdumped != 0) {
//Now print the group
switch (convert) {
case CONVERT_VOLTS:
for (i = 0; i < numChannels; i++) {
if (printf("%lf ", voltline[i])
< 0)
goto bad;
}
if (printf("\n") < 0)
goto bad;
break;
case CONVERT_HEX:
for (i = 0; i < numChannels; i++) {
......@@ -566,6 +570,9 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
< 0)
goto bad;
}
if (printf("\n") < 0)
goto bad;
break;
default:
case CONVERT_DEC:
......@@ -574,10 +581,18 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
< 0)
goto bad;
}
if (printf("\n") < 0)
goto bad;
break;
case CONVERT_BINARY:
if (fwrite(dataline,
sizeof(uint16_t), numChannels, stdout) < 0)
goto bad;
// }
break;
}
if (printf("\n") < 0)
goto bad;
//If we're counting lines, decrement them
if (lines != 0) {
......@@ -694,4 +709,4 @@ int nerd_close_conn(int data_fd)
shutdown(data_fd, 2);
close(data_fd);
return 0;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment