Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
version: 2.1

orbs:
win: circleci/windows@1.0.0

workflows:
version: 2
builds:
jobs:
- build-linux:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- build-windows:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
#- build-mac:
# filters: # required since `deploy` has tag filters AND requires `build`
# tags:
# only: /.*/

jobs:
build-linux:
working_directory: ~/ykush
docker:
- image: gcc
steps:
- checkout
- run:
name: install deps
command: |
apt update
apt install -y libusb-1.0-0 libusb-1.0-0-dev
- run:
name: build
command: |
make
bin/ykushcmd -h
- store_artifacts:
path: bin/ykushcmd
destination: bin/linux/ykushcmd
build-windows:
executor:
name: win/vs2019
shell: powershell.exe
working_directory: ~/ykush
steps:
- checkout
- run:
name: "Install deps"
command: choco install mingw make
- run:
name: "Build 64"
command: |
make -f Makefile_win64
bin/Win64/ykushcmd_win64.exe -h
- store_artifacts:
path: bin/Win64/libhidapi.dll
destination: bin/win64/libhidapi.dll
- store_artifacts:
path: bin/Win64/ykushcmd_win64.exe
destination: bin/win64/ykushcmd.exe
# should install mingw32
#- run:
# name: "Build 32"
# command: |
# make -f Makefile_win32
# bin/Win32/ykushcmd_win32.exe -h
#- store_artifacts:
# path: bin/Win32/libhidapi.dll
# destination: bin/win32/libhidapi.dll
#- store_artifacts:
# path: bin/Win32/ykushcmd_win32.exe
# destination: bin/win32/ykushcmd.exe
#build-mac:
# macos: # indicate that we are using the macOS executor
# xcode: "10.0.0" # indicate our selected version of Xcode
# steps:
# - checkout
# - run:
# name: install deps
# command: brew install gcc make libhid
# - run:
# name: build
# command: |
# make
# bin/ykushcmd -h
# - store_artifacts:
# path: bin/ykushcmd
# destination: bin/macos/ykushcmd
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ PROG_OBJ = $(PROG_SOURCE_FULL:.cpp=.o)
DEFINES += _LINUX_
DEFINES += _LIBUSB_

COMPILE_FLAGS += $(addprefix -D, $(DEFINES))
COMPILE_FLAGS += $(addprefix -D, $(DEFINES)) -Werror

CUR_PATH = $(shell echo $(PWD))
INCLUDEPATHS = $(addprefix -I$(CUR_PATH)/, $(dir $(SOURCE_FULL)) libusb )
LOADPATHS =
LOADPATHS =
LIBS = -lusb-1.0
CPP = g++



ykushcmd : $(PROG_OBJ) $(OBJS)
Expand All @@ -40,5 +40,5 @@ $(OBJS) : %.o : %.cpp %.h


clean :
rm -f bin/yktrl $(OBJS) $(PROG_OBJ)
rm -f bin/ykushcmd $(OBJS) $(PROG_OBJ)

6 changes: 3 additions & 3 deletions Makefile_win32
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ FLAGS = -static-libgcc -static-libstdc++

#Change MinGW exec name to match version instaled in your system
CPP = i686-w64-mingw32-g++
#CPP_WIN32 = i686-w64-mingw32-g++
#CPP_WIN64 = x86_64-w64-mingw32-g++
#CPP_WIN32 = i686-w64-mingw32-g++
#CPP_WIN64 = x86_64-w64-mingw32-g++


ykushcmd_win32.exe : $(PROG_OBJ) $(OBJS)
Expand All @@ -38,5 +38,5 @@ $(OBJS) : %.o : %.cpp %.h


clean :
rm -f bin/Win32/yktrl_win32.exe $(OBJS) $(PROG_OBJ)
rm -f bin/Win32/ykushcmd_win32.exe $(OBJS) $(PROG_OBJ)

10 changes: 5 additions & 5 deletions Makefile_win64
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ PROG_OBJ = $(PROG_SOURCE_FULL:.cpp=.o)

CUR_PATH = $(CURDIR)
INCLUDEPATHS = $(addprefix -I$(CUR_PATH)/, $(dir $(SOURCE_FULL)) hidapi )
LOADPATHS = -L$(CUR_PATH)/hidapi/mingw32
LOADPATHS = -L$(CUR_PATH)/hidapi/mingw64
LIBS = -lhidapi
FLAGS = -static-libgcc -static-libstdc++

#Change MinGW exec name to match version instaled in your system
CPP = x86_64-w64-mingw32-g++
#CPP_WIN32 = i686-w64-mingw32-g++
#CPP_WIN64 = x86_64-w64-mingw32-g++
#CPP_WIN32 = i686-w64-mingw32-g++
#CPP_WIN64 = x86_64-w64-mingw32-g++


ykushcmd_win64.exe : $(PROG_OBJ) $(OBJS)
$(CPP) $(FLAGS) $(LOADPATHS) -o bin/Win32/$@ $(PROG_OBJ) $(OBJS) $(LIBS)
$(CPP) $(FLAGS) $(LOADPATHS) -o bin/Win64/$@ $(PROG_OBJ) $(OBJS) $(LIBS)

$(PROG_OBJ) : %.o : %.cpp
$(CPP) $(FLAGS) $(PREPROCESSOR_DEFS) $(INCLUDEPATHS) -c $< -o $@
Expand All @@ -38,5 +38,5 @@ $(OBJS) : %.o : %.cpp %.h


clean :
rm -f bin/Win64/yktrl_win32.exe $(OBJS) $(PROG_OBJ)
rm -f bin/Win64/ykushcmd_win64.exe $(OBJS) $(PROG_OBJ)

2 changes: 1 addition & 1 deletion libusb/libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ enum libusb_capability {
* still have to call additional libusb functions such as
* \ref libusb_detach_kernel_driver(). */
LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
/** The library supports detaching of the default USB driver, using
/** The library supports detaching of the default USB driver, using
* \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
};
Expand Down
12 changes: 5 additions & 7 deletions src/commandParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ enum Board {
};


int commandParser(int argc, char** argv)
{
Help help(argv[0]);
int commandParser(int argc, char** argv)
{
Help help(argv[0]);
std::string str_ykush ("ykush");
std::string str_ykush3 ("ykush3");
std::string str_ykush2 ("ykush2");
std::string str_ykushxs ("ykushxs");

if ( argc <= 1) {
help.print_all();
help.print_all();
return 0;
}
}

//Parse input options and define action
if( argc >= 2) {
Expand All @@ -101,14 +101,12 @@ int commandParser(int argc, char** argv)
return ykush_cmd_parser(argc - 1 , &argv[1]);
else
help.print_all();

return -1;
} else {
//YKUSH
return ykush_cmd_parser(argc, argv);
}
}

return 0;
}

Expand Down
35 changes: 18 additions & 17 deletions src/yk_usb_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ limitations under the License.

#ifdef _LIBUSB_
// Uses libusb directly
int UsbDevice::listConnected()
int UsbDevice::listConnected()
{
UsbHid *usbhid = new UsbHid();
struct hid_device_info *devs, *cur_dev;
Expand All @@ -52,23 +52,23 @@ int UsbDevice::listConnected()
}
#else
// Uses hidapi
int UsbDevice::listConnected()
int UsbDevice::listConnected()
{
int i=0;

struct hid_device_info *devs, *cur_dev;

devs = hid_enumerate(vid, pid);
if (devs == NULL)
return 0;

cur_dev = devs;
while (cur_dev) {
i++;
printf("%d. Board found with serial number: %ls\n", i, cur_dev->serial_number);
printf("%d. Board found with serial number: %ls\n", i, cur_dev->serial_number);
cur_dev = cur_dev->next;
}

hid_free_enumeration(devs);

return i;
Expand All @@ -78,16 +78,17 @@ int UsbDevice::listConnected()
UsbDevice::UsbDevice(unsigned int vendor_id, unsigned int product_id) {
pid = product_id;
vid = vendor_id;
usb_serial = NULL;
}


/**
* Sends HID report with the data provided in the input buffer "msg".
* Sends HID report with the data provided in the input buffer "msg".
*
* \param [in] serial Pointer to a char array containing the serial number.
* \param [in] msg Pointer to buffer containing the HID report message to be sent to USB device.
* \param [out] resp_msg Pointer to buffer to which the HID report message replied by the device.
*
*
* \retval 0 No error.
* \retval -1 Unable to open USB device.
* \retval -2 Unable to write HID report to USB device.
Expand All @@ -98,17 +99,17 @@ UsbDevice::UsbDevice(unsigned int vendor_id, unsigned int product_id) {
* output.
*
*
* Precedences:
* Precedences:
*
* Requires that VENDOR_ID and PRODUCT_ID constants are defined.
*
*
*****************************************************************/
#ifdef _LIBUSB_
int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *resp_msg, int report_size)
int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *resp_msg, int report_size)
{
UsbHid *usbhid = new UsbHid();
int res;
int res;

res = usbhid->open(vid, pid, serial);
if (res < 0) {
Expand All @@ -133,8 +134,8 @@ int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *re
return 0;
}
#else
int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *resp_msg, int report_size)
{
int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *resp_msg, int report_size)
{
const size_t newsize = 100;
wchar_t cserial[newsize];
int res, i;
Expand All @@ -144,13 +145,13 @@ int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *re
if (report_size <= 64) {
out_buf[0] = 0;
for (i = 0; i < report_size; i++) {
out_buf[i+1] = msg[i];
out_buf[i+1] = msg[i];
}
} else {
std::cout << "Invalid report size\n";
return -1;
}

if (serial) {
// Convert to a wchar_t*
size_t origsize = strlen(serial) + 1;
Expand All @@ -160,9 +161,9 @@ int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *re

}

// Open the USB device
// Open the USB device
handle = hid_open(vid, pid, serial ? cserial : NULL);

if (handle == NULL) {
//printf("\n\nERROR: Unable to open USB device\n");
return -1;
Expand All @@ -188,7 +189,7 @@ int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *re
resp_msg[i] = in_buf[i];
}

return 0;
return 0;
}
#endif

Expand Down
Loading