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.

52 lines
1.6 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. {
  29. //+1 for the \0 string terminator
  30. char serial[Serial_Length + 1];
  31. unsigned char relay_count;
  32. unsigned char state;
  33. char * path;
  34. } relay_board;
  35. // Public methods
  36. int enumerate_relay_boards(const char * product, int verbose, int debug);
  37. int operate_relay(const char * path, unsigned char relay, unsigned char state);
  38. int set_serial(const char * path, char * newserial);
  39. relay_board * find_board(const char * serial);
  40. int get_relay_board_count(void);
  41. relay_board * get_relay_boards(void);
  42. void shutdown(void);
  43. #endif