Commit 8bb6de6c by Daisy Green

added binary output mode for nerdjack

parent 01359f47
Showing with 19 additions and 4 deletions
...@@ -429,7 +429,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list, ...@@ -429,7 +429,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
double voltline[numChannels]; double voltline[numChannels];
unsigned short dataline[numChannels]; uint16_t dataline[numChannels];
unsigned short packetsready = 0; unsigned short packetsready = 0;
unsigned short adcused = 0; unsigned short adcused = 0;
...@@ -544,7 +544,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list, ...@@ -544,7 +544,7 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
case CONVERT_HEX: case CONVERT_HEX:
case CONVERT_DEC: case CONVERT_DEC:
dataline[i] = dataline[i] =
(unsigned short)(datapoint - (uint16_t)(datapoint -
INT16_MIN); INT16_MIN);
break; break;
} }
...@@ -553,12 +553,16 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list, ...@@ -553,12 +553,16 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
if (linesdumped != 0) { if (linesdumped != 0) {
//Now print the group //Now print the group
switch (convert) { switch (convert) {
case CONVERT_VOLTS: case CONVERT_VOLTS:
for (i = 0; i < numChannels; i++) { for (i = 0; i < numChannels; i++) {
if (printf("%lf ", voltline[i]) if (printf("%lf ", voltline[i])
< 0) < 0)
goto bad; goto bad;
} }
if (printf("\n") < 0)
goto bad;
break; break;
case CONVERT_HEX: case CONVERT_HEX:
for (i = 0; i < numChannels; i++) { for (i = 0; i < numChannels; i++) {
...@@ -566,6 +570,9 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list, ...@@ -566,6 +570,9 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
< 0) < 0)
goto bad; goto bad;
} }
if (printf("\n") < 0)
goto bad;
break; break;
default: default:
case CONVERT_DEC: case CONVERT_DEC:
...@@ -574,10 +581,18 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list, ...@@ -574,10 +581,18 @@ nerd_data_stream(int data_fd, int numChannels, int *channel_list,
< 0) < 0)
goto bad; goto bad;
} }
break;
}
if (printf("\n") < 0) if (printf("\n") < 0)
goto bad; goto bad;
break;
case CONVERT_BINARY:
if (fwrite(dataline,
sizeof(uint16_t), numChannels, stdout) < 0)
goto bad;
// }
break;
}
//If we're counting lines, decrement them //If we're counting lines, decrement them
if (lines != 0) { if (lines != 0) {
......
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