--- /dev/null
+/Debug/
+/Release/
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hidusb-relay-cmd", "hidusb-relay-cmd(vc2008).vcproj", "{CF9B07CB-509D-43B5-94FC-2BA43427C093}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "usb-relay-dll", "..\lib\usb-relay-dll\usb-relay-dll.vcproj", "{0E07152A-666D-4EB4-9049-BDE08C35A86D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
{CF9B07CB-509D-43B5-94FC-2BA43427C093}.Debug|Win32.Build.0 = Debug|Win32
{CF9B07CB-509D-43B5-94FC-2BA43427C093}.Release|Win32.ActiveCfg = Release|Win32
{CF9B07CB-509D-43B5-94FC-2BA43427C093}.Release|Win32.Build.0 = Release|Win32
+ {0E07152A-666D-4EB4-9049-BDE08C35A86D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0E07152A-666D-4EB4-9049-BDE08C35A86D}.Debug|Win32.Build.0 = Debug|Win32
+ {0E07152A-666D-4EB4-9049-BDE08C35A86D}.Release|Win32.ActiveCfg = Release|Win32
+ {0E07152A-666D-4EB4-9049-BDE08C35A86D}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
--- /dev/null
+How to use USB_RELAY_DEVICE DLL
+
+Version 1.0
+
+Changes to the original DLL:
+============================
+ - Type used for handles changed from int to intptr_t, for 64-bit compatibility.
+ This should be binary compatible with existing 32-bit clients.
+
+
+Windows, Visual C++ applications
+================================
+
+Include file name: usb_relay_device.h
+Library file name: usb_relay_device.lib
+
+Put the following lines in your source file:
+
+ #include <usb_relay_device.h>
+ #pragma comment(lib, "usb_relay_device.lib")
+
+The file usb_relay_device.dll must be installed with your application.
+Use either 32-bit or 64-bit DLL, matching your application.
+The DLL may require VC++ redistributable runtime library.
+
+Using the API:
+--------------
+
+ * usb_relay_init()
+ Call this before calling other functions
+
+ * usb_relay_device_enumerate()
+ Enumerates all Relay devices plugged into the PC.
+ Returns list of usb_relay_device_info structures.
+ Caller should free this list by passing it to usb_relay_device_free_enumerate().
+
+ * usb_relay_device_open()
+ Opens one Relay board device by its usb_relay_device_info structure,
+ obtained from usb_relay_device_enumerate().
+
+ * usb_relay_device_open_with_serial_number
+ Opens one Relay board device by its serial number string.
+ These strings can be obtained from usb_relay_device_enumerate().
+
+ * usb_relay_device_open_one_relay_channel
+ Turns ON one channel of a Relay board.
+ Parameters:
+ - device handle, obtained from usb_relay_device_open()
+ - Index: integer from 1 to the maximal number of channels on a board.
+
+ * usb_relay_device_open_all_relay_channel
+ Turns ON all channels on a board.
+
+ * usb_relay_device_close_one_relay_channel
+ Turns OFF one channel of a Relay board.
+ Parameters:
+ - device handle, obtained from usb_relay_device_open()
+ - Index: integer from 1 to the maximal number of channels on a board.
+
+ * usb_relay_device_close_all_relay_channel()
+ Turns OFF all channels on a board.
+
+ * usb_relay_device_get_status
+ Get status of all channels on a board as a bit mask.
+ The least significant bit in returned value corresponds to channel 1.
+ Bit value 1 means the corresponding relay is switched ON, value 0 means the relay is OFF.
+
+ * usb_relay_device_close
+ Closes the Relay device handle opened by usb_relay_device_open() or
+ usb_relay_device_open_with_serial_number()
+
+ * usb_relay_exit
+ Finalizes the library
+
+Error handling
+---------------
+If error occurred, the API functions that return error code return -1;
+functions that return handles or pointers return NULL.
+Application is responsible to check the returned value.
+
+Notes
+-------
+ * The library does not detect hot plug/unplug of USB devices.
+ * The library is not thread-safe. Client application must ensure that
+ only one thread calls the library.
+
+
+Managed .NET applications (C#, VB.NET)
+======================================
+TBD
+
+Python (CPython)
+================
+TBD
+
+GCC or MinGW applications
+=========================
+TBD
+
--- /dev/null
+/Debug/
+/Release/
--- /dev/null
+// dllmain.cpp : Defines the entry point for the DLL
+
+#include "stdafx.h"
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
--- /dev/null
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+
+
+// TODO: reference additional headers your program requires here
--- /dev/null
+#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
+#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
+#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
+#endif
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="usb-relay-dll"
+ ProjectGUID="{0E07152A-666D-4EB4-9049-BDE08C35A86D}"
+ RootNamespace="usbrelaydll"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;USBRELAYDLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\USB_RELAY_DEVICE.dll"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="D:\winddk\7.1.0\lib\wxp\i386"
+ ModuleDefinitionFile="usb_relay_dll.def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;USBRELAYDLL_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(OutDir)\USB_RELAY_DEVICE.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="D:\winddk\7.1.0\lib\wxp\i386"
+ ModuleDefinitionFile="usb_relay_dll.def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\dllmain.c"
+ >
+ </File>
+ <File
+ RelativePath=".\usb_relay_dll.def"
+ >
+ </File>
+ <File
+ RelativePath=".\usb_relay_lib_win32.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.h"
+ >
+ </File>
+ <File
+ RelativePath="..\usb_relay_device.h"
+ >
+ </File>
+ <File
+ RelativePath="..\usb_relay_hw.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
--- /dev/null
+LIBRARY USB_RELAY_DEVICE
+VERSION 1.0
+
+EXPORTS
+; All exports are CDECL
+
+usb_relay_device_close
+usb_relay_device_close_all_relay_channel
+usb_relay_device_close_one_relay_channel
+usb_relay_device_enumerate
+usb_relay_device_free_enumerate
+usb_relay_device_get_status
+usb_relay_device_open
+usb_relay_device_open_all_relay_channel
+usb_relay_device_open_one_relay_channel
+usb_relay_device_open_with_serial_number
+usb_relay_exit
+usb_relay_init
+
+; END
--- /dev/null
+// Windows version
+
+#include "stdafx.h"
+
+#define USBRL_API __declspec(dllexport)
+#include "../usb_relay_device.h"
+#include "../usb_relay_hw.h"
+
+#include <stdio.h>
+
+#ifdef _MSC_VER
+#pragma comment(lib, "setupapi")
+#pragma comment(lib, "hid")
+#endif /*_MSC_VER*/
+
+#undef ERROR
+#define ERROR (-1)
+#define OK (0)
+
+#define dbgprintf(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
+//#define dbgprintf(fmt, ...) printf(fmt, __VA_ARGS__)
+//#define dbgprintf(fmt, ...) __noop(fmt, __VA_ARGS__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Globals
+
+
+// Public functions:
+
+/** Initialize the USB Relay Library
+@returns: This function returns 0 on success and -1 on error.
+*/
+int USBRL_API usb_relay_init(void)
+{
+ dbgprintf("Init lib\n");
+ return ERROR;
+}
+
+/** Finalize the USB Relay Library.
+This function frees all of the static data associated with USB Relay Library.
+It should be called at the end of execution to avoid memory leaks.
+@returns: This function returns 0 on success and -1 on error.
+*/
+int USBRL_API usb_relay_exit(void)
+{
+ return OK;
+}
+
+/** Enumerate the USB Relay Devices.*/
+struct usb_relay_device_info USBRL_API * usb_relay_device_enumerate(void)
+{
+ return NULL;
+}
+
+
+/** Free an enumeration Linked List*/
+void USBRL_API usb_relay_device_free_enumerate(struct usb_relay_device_info *di)
+{
+ return;
+}
+
+/** Open device by serial number
+@return: This function returns a valid handle to the device on success or NULL on failure.
+Example: usb_relay_device_open_with_serial_number("abcde", 5) */
+intptr_t USBRL_API usb_relay_device_open_with_serial_number(const char *serial_number, unsigned len)
+{
+ return ERROR;
+}
+
+/* Open a USB relay device
+@return: This function returns a valid handle to the device on success or NULL on failure.
+*/
+intptr_t USBRL_API usb_relay_device_open(struct usb_relay_device_info *device_info)
+{
+ return ERROR;
+}
+
+/* Close a USB relay device*/
+void USBRL_API usb_relay_device_close(intptr_t hHandle)
+{
+ return;
+}
+
+/** Turn ON a relay channel on the USB-Relay-Device
+@param index -- which channel your want to open
+@param hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error; 2 -- index is outnumber the number of the usb relay device
+*/
+int USBRL_API usb_relay_device_open_one_relay_channel(intptr_t hHandle, int index)
+{
+ return ERROR;
+}
+
+/** Turn ON all relay channels on the USB-Relay-Device
+@param hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error
+*/
+int USBRL_API usb_relay_device_open_all_relay_channel(intptr_t hHandle)
+{
+ return ERROR;
+}
+
+/** Turn OFF a relay channel on the USB-Relay-Device
+@param index -- which channel your want to close
+@paramhHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error; 2 -- index is outnumber the number of the usb relay device
+*/
+int USBRL_API usb_relay_device_close_one_relay_channel(intptr_t hHandle, int index)
+{
+ return ERROR;
+}
+
+/** Turn OFF all relay channels on the USB-Relay-Device
+@paramter: hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error
+*/
+int USBRL_API usb_relay_device_close_all_relay_channel(intptr_t hHandle)
+{
+ return ERROR;
+}
+
+/*
+Status bits: one bit indicate a relay status.
+bit 0/1/2/3/4/5/6/7/8 indicate channel 1/2/3/4/5/6/7/8 status
+ 1 -- means ON, 0 -- means OFF.
+@returns: 0 -- success; 1 -- error
+*/
+int USBRL_API usb_relay_device_get_status(intptr_t hHandle, unsigned int *status)
+{
+ return ERROR;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
--- /dev/null
+#ifndef USB_RELAY_DEVICE_H__
+#define USB_RELAY_DEVICE_H__
+
+#ifdef WIN32
+#ifndef USBRL_API
+# define USBRL_API __declspec(dllimport)
+#endif
+#ifndef CDECL
+# define CDECL _cdecl
+#endif
+#
+#else /* !WIN32 */
+#
+#ifndef USBRL_API
+# define USBRL_API
+#endif
+#ifndef CDECL
+# define CDECL
+#endif
+#
+#endif /* WIN32 */
+
+#include <stddef.h>
+
+enum usb_relay_device_type
+{
+ USB_RELAY_DEVICE_ONE_CHANNEL = 1,
+ USB_RELAY_DEVICE_TWO_CHANNEL = 2,
+ USB_RELAY_DEVICE_FOUR_CHANNEL = 4,
+ USB_RELAY_DEVICE_EIGHT_CHANNEL = 8
+};
+
+
+/** USB relay board info structure*/
+struct usb_relay_device_info
+{
+ unsigned char *serial_number;
+ char *device_path;
+ enum usb_relay_device_type type;
+ struct usb_relay_device_info* next;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Initialize the USB Relay Library
+@returns: This function returns 0 on success and -1 on error.
+*/
+USBRL_API
+int CDECL usb_relay_init(void);
+
+/** Finalize the USB Relay Library.
+This function frees all of the static data associated with USB Relay Library.
+It should be called at the end of execution to avoid memory leaks.
+@returns:This function returns 0 on success and -1 on error.
+*/
+USBRL_API
+int CDECL usb_relay_exit(void);
+
+
+/** Enumerate the USB Relay Devices.*/
+USBRL_API
+struct usb_relay_device_info * CDECL usb_relay_device_enumerate(void);
+
+
+/** Free an enumeration Linked List*/
+USBRL_API
+void CDECL usb_relay_device_free_enumerate(struct usb_relay_device_info*);
+
+/** Open device that serial number is serial_number
+@return: This function returns a valid handle to the device on success or NULL on failure.
+e.g: usb_relay_device_open_with_serial_number("abcde", 5") */
+USBRL_API
+intptr_t CDECL usb_relay_device_open_with_serial_number(const char *serial_number, unsigned len);
+
+/* Open a USB relay device
+@return: This function returns a valid handle to the device on success or NULL on failure.
+*/
+USBRL_API
+intptr_t CDECL usb_relay_device_open(struct usb_relay_device_info *device_info);
+
+/* Close a USB relay device*/
+USBRL_API
+void CDECL usb_relay_device_close(intptr_t hHandle);
+
+/** Turn ON a relay channel on the USB-Relay-Device
+@param hHandle -- which usb relay device your want to operate
+@param index -- the channel number: 1...max
+@returns: 0 -- success; 1 -- error; 2 -- index is invalid
+*/
+USBRL_API
+int CDECL usb_relay_device_open_one_relay_channel(intptr_t hHandle, int index);
+
+/** Turn ON all relay channels on the USB-Relay-Device
+@param hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error
+*/
+USBRL_API
+int CDECL usb_relay_device_open_all_relay_channel(intptr_t hHandle);
+
+/** Turn OFF a relay channel on the USB-Relay-Device
+@param index -- which channel your want to close
+@param hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error
+*/
+USBRL_API
+int CDECL usb_relay_device_close_one_relay_channel(intptr_t hHandle, int index);
+
+/** Turn OFF all relay channels on the USB-Relay-Device
+@param hHandle -- which usb relay device your want to operate
+@returns: 0 -- success; 1 -- error; 2 -- index is invalid
+*/
+USBRL_API
+int CDECL usb_relay_device_close_all_relay_channel(intptr_t hHandle);
+
+/*
+Status bits: one bit indicate a relay status.
+bit 0/1/2/3/4/5/6/7/8 indicate channel 1/2/3/4/5/6/7/8 status
+Bit value 1 means ON, 0 means OFF.
+@returns: 0 -- success; 1 -- error
+*/
+USBRL_API
+int CDECL usb_relay_device_get_status(intptr_t hHandle, unsigned int *status);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* USB_RELAY_DEVICE_H__ */
--- /dev/null
+#ifndef USB_RELAY_DEVICE_HW__
+#define USB_RELAY_DEVICE_HW__
+
+#define USB_CFG_VENDOR_ID 0x16c0 /* 5824 = voti.nl */
+#define USB_CFG_DEVICE_ID 0x05DF /* obdev's shared PID for HIDs */
+#define USB_CFG_VENDOR_NAME "www.dcttech.com"
+#define USB_CFG_DEVICE_NAME2 "USBRelay2" /* can be relay1... relay8?*/
+
+#endif /*USB_RELAY_DEVICE_HW__*/