2009-01-21 10:21:57 -05:00
|
|
|
/*
|
|
|
|
* Labjack Tools
|
|
|
|
* Copyright (c) 2003-2007 Jim Paris <jim@jtan.com>
|
|
|
|
*
|
|
|
|
* This is free software; you can redistribute it and/or modify it and
|
|
|
|
* it is provided under the terms of version 2 of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation; see COPYING.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NERDJACK_H
|
|
|
|
#define NERDJACK_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "netutil.h"
|
|
|
|
|
|
|
|
#define NERDJACK_CHANNELS 12
|
2009-04-10 11:58:33 -04:00
|
|
|
#define NERDJACK_CLOCK_RATE 66000000
|
2009-01-21 10:21:57 -05:00
|
|
|
#define NERDJACK_DATA_PORT 49155
|
|
|
|
#define NERDJACK_UDP_RECEIVE_PORT 49156
|
2009-02-23 09:39:26 -05:00
|
|
|
#define NERDJACK_COMMAND_PORT 49157
|
2009-01-21 10:21:57 -05:00
|
|
|
|
|
|
|
#define NERDJACK_PACKET_SIZE 1460
|
2009-04-07 11:38:19 -04:00
|
|
|
#define NERDJACK_NUM_SAMPLES 726
|
2009-01-21 10:21:57 -05:00
|
|
|
|
2009-03-19 18:19:05 -04:00
|
|
|
/* Packet structure used in message to start sampling on NerdJack */
|
2010-02-08 16:23:12 -05:00
|
|
|
typedef struct __attribute__ ((__packed__)) {
|
|
|
|
char word[4];
|
|
|
|
unsigned long period;
|
|
|
|
unsigned short channelbit;
|
|
|
|
unsigned char precision;
|
|
|
|
unsigned char prescaler;
|
2009-03-13 16:33:52 -04:00
|
|
|
} getPacket;
|
|
|
|
|
2009-01-21 10:21:57 -05:00
|
|
|
/* Open/close TCP/IP connection to the NerdJack */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerd_open(const char *address, int port);
|
|
|
|
int nerd_close_conn(int data_fd);
|
2009-01-21 10:21:57 -05:00
|
|
|
|
|
|
|
/* Generate the command word for the NerdJack */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerd_generate_command(getPacket * command, int *channel_list,
|
|
|
|
int channel_count, int precision,
|
|
|
|
unsigned long period);
|
2009-01-21 10:21:57 -05:00
|
|
|
|
2009-02-23 09:39:26 -05:00
|
|
|
/* Send given command to NerdJack */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerd_send_command(const char *address, void *command, int length);
|
|
|
|
|
|
|
|
/* Get the version string from NerdJack */
|
|
|
|
int nerd_get_version(const char *address);
|
2009-02-23 09:39:26 -05:00
|
|
|
|
2009-01-21 10:21:57 -05:00
|
|
|
/* Stream data out of the NerdJack */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerd_data_stream(int data_fd, int numChannels, int *channel_list,
|
|
|
|
int precision, int convert, int lines, int showmem,
|
|
|
|
unsigned short *currentcount, unsigned int period,
|
|
|
|
int wasreset);
|
2009-01-21 10:21:57 -05:00
|
|
|
|
|
|
|
/* Detect the IP Address of the NerdJack and return in ipAddress */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerdjack_detect(char *ipAddress);
|
2009-01-21 10:21:57 -05:00
|
|
|
|
|
|
|
/* Choose the best ScanConfig and ScanInterval parameters for the
|
|
|
|
desired scanrate. Returns -1 if no valid config found */
|
2010-02-08 16:23:12 -05:00
|
|
|
int nerdjack_choose_scan(double desired_rate, double *actual_rate,
|
|
|
|
unsigned long *period);
|
2009-01-21 10:21:57 -05:00
|
|
|
|
|
|
|
#endif
|