-
Notifications
You must be signed in to change notification settings - Fork 98
/
libusbrelay.h
64 lines (51 loc) · 1.72 KB
/
libusbrelay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
libusbrelay: Control USB HID connected electrical relay modules
Copyright (C) 2014 Darryl Bond
Library version
Copyright (C) 2019 Sean Mollet
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* relay.h */
#ifndef __USBRELAY_H
#define __USBRELAY_H
//Configuration
#define CMD_ON 0xff
#define CMD_OFF 0xfd
#define CMD_SET_SERIAL 0xfa
typedef enum
{
DCTTECH = 1,
UCREATE = 2,
LCUS = 3
} RELAY_TYPE;
#define Serial_Length 5
extern const char *gitversion;
//Struct for relay boards
typedef struct relay_board {
//+1 for the \0 string terminator
char serial[Serial_Length+1];
unsigned char relay_count;
unsigned char state;
char *path;
RELAY_TYPE module_type;
} relay_board;
//Public methods
int enumerate_relay_boards(const char *product,int verbose, int debug);
int operate_relay(const char *path,unsigned char relay, unsigned char state,int debug);
int set_serial(const char *path,char *newserial,int debug);
relay_board *find_board(const char *serial,int debug);
int get_relay_board_count(void);
relay_board* get_relay_boards(void);
void shutdown(void);
const char *libusbrelay_version(void);
#endif