You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

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