Compare commits

...

6 Commits

Author SHA1 Message Date
42d83649be Update authors 2016-07-13 15:59:44 -04:00
df740e3e00 Increment version 2016-07-13 15:57:42 -04:00
c2f43c474b Update .gitignore 2016-07-13 15:57:12 -04:00
893debb361 Fix Windows cross-build 2016-07-13 15:56:26 -04:00
John
0b1ad7415d updated version 2015-06-03 11:26:48 -04:00
John
ba2565dc0e added clean shutdown of LabJack on ctrl-c 2015-06-03 10:54:44 -04:00
7 changed files with 39 additions and 7 deletions

7
.gitignore vendored
View File

@ -1,3 +1,10 @@
ethstream ethstream
ethstream.1 ethstream.1
ethstream.txt ethstream.txt
ethstream.exe
*.obj
*.d
*.dobj
*.o

4
README
View File

@ -1,6 +1,8 @@
Labjack/Nerdjack Tools Labjack/Nerdjack Tools
by Jim Paris <jim@jtan.com> by Jim Paris <jim@jtan.com>
with modifications by Zach Clifford <zacharyc@mit.edu> with modifications by
Zach Clifford <zacharyc@mit.edu>
John Donnal <jdonnal@mit.edu>
These tools are for interacting with the LabJack UE9 or the NerdJack These tools are for interacting with the LabJack UE9 or the NerdJack
over the Ethernet interface. More information about the UE9 device: over the Ethernet interface. More information about the UE9 device:

View File

@ -1 +1 @@
1.3 1.3.2

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include "compat.h" #include "compat.h"
#include <windows.h> #include <windows.h>
#include "errno.h"
unsigned int sleep(unsigned int seconds) unsigned int sleep(unsigned int seconds)
{ {

View File

@ -5,9 +5,6 @@
unsigned int sleep(unsigned int seconds); unsigned int sleep(unsigned int seconds);
char *compat_strerror(int errnum); char *compat_strerror(int errnum);
//const char *inet_ntop(int af, void *src, const char *dst, socklen_t cnt); //const char *inet_ntop(int af, void *src, const char *dst, socklen_t cnt);
#define INET_ADDRSTRLEN 16
#define ETIMEDOUT 110
#define ENOTCONN 107
#else #else
#define compat_strerror strerror #define compat_strerror strerror
#endif #endif

View File

@ -82,11 +82,33 @@ int data_callback(int channels, int *channel_list, int gain_count, int *gain_li
uint16_t * data, void *context); uint16_t * data, void *context);
int columns_left = 0; 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) void handle_sig(int sig)
{ {
while (columns_left--) { while (columns_left--) {
printf(" 0"); 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); fflush(stdout);
exit(0); exit(0);
} }
@ -314,6 +336,7 @@ int main(int argc, char *argv[])
case 'V': case 'V':
printf("ethstream " VERSION "\n"); printf("ethstream " VERSION "\n");
printf("Written by Jim Paris <jim@jtan.com>\n"); printf("Written by Jim Paris <jim@jtan.com>\n");
printf("and John Donnal <jdonnal@mit.edu>\n");
printf("and Zachary Clifford <zacharyc@mit.edu>.\n"); printf("and Zachary Clifford <zacharyc@mit.edu>.\n");
printf("This program comes with no warranty and is " printf("This program comes with no warranty and is "
"provided under the GPLv2.\n"); "provided under the GPLv2.\n");
@ -660,7 +683,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
int convert, int lines) int convert, int lines)
{ {
int retval = -EAGAIN; int retval = -EAGAIN;
int fd_cmd, fd_data; // int fd_cmd, fd_data; *these are now globals so sighandler can use them*
int ret; int ret;
static int first_call = 1; static int first_call = 1;
struct callbackInfo ci = { struct callbackInfo ci = {
@ -730,6 +753,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
} }
/* Stream data */ /* Stream data */
ue9_running = 1;
ret = ret =
ue9_stream_data(fd_data, channel_count, channel_list, gain_count, gain_list, data_callback, (void *)&ci); ue9_stream_data(fd_data, channel_count, channel_list, gain_count, gain_list, data_callback, (void *)&ci);
if (ret < 0) { if (ret < 0) {
@ -749,6 +773,7 @@ doStream(const char *address, uint8_t scanconfig, uint16_t scaninterval,
out1: out1:
ue9_close(fd_cmd); ue9_close(fd_cmd);
out: out:
ue9_running = 0;
return retval; return retval;
} }

View File

@ -1,2 +1,2 @@
/* This file was automatically generated. */ /* This file was automatically generated. */
#define VERSION "1.3 (2013-08-09)" #define VERSION "1.3.2 (2016-07-13)"