Closed incucu closed 3 months ago
Hi and thank you for the answer!
The board LED lights and beeper are activated and these work when I play a game via your app. I tried connecting the board with cable and with BT, both connections work well.
Now when I try to run this little test code then all the function return 0 alwyas, doesn't matter if the board is connected or turned off.
`#include "easy_link_c.h"
int main() { if(cl_connect() == 0) { printf("Connection successful.\n"); } else { printf("Connection failed.\n"); return -1; // Exit if connection fails }
if(cl_beep(1000, 200) == 0) {
printf("Beep command successful.\n");
} else {
printf("Beep command failed.\n");
}
const char *led[8] = {"11111111", "00000000", "11111111", "00000000", "11111111", "00000000", "11111111", "00000000"};
printf("Sending LED command...\n");
if(cl_led(led) == 0) {
printf("LED command successful.\n");
} else {
printf("LED command failed.\n");
}
int battery_life = cl_get_battery();
if(battery_life >= 0) {
printf("Battery life: %d%%\n", battery_life);
} else {
printf("Failed to read battery life.\n");
}
return 0;
} `
The result is always the same:
Connection successful. Beep command successful. Sending LED command... LED command successful. Battery life: 0%
I don't know how to continue from here... Hopefully I'm missing something obvious :)
Incucu
_clconnect() wraps the method bChessLink->connect() which returns a boolean; so the value is actually 1 when the connection is successfull and 0 otherwise... the same goes for all other functions that returns an OK/FAIL state
I just tried your exact code, simply switching == 0 with == 1, on a Chessanut Air connected via USB, and it works fine
Thanks for the quick answer!
I see. Then it always fails instead, which makes much more sense :) I am using Chessnut Pro, maybe it works only for the Air? cl_connect() always returns false immediately.
Incucu
It should be the same underlying hardware, but I can't tell with 100% certainty... the one requirement is just cable connection, this SDK doesn't work with BLE, as far as I know, and I hope it gets updated in that regard.
You did compile the library and put "easylink.dll" in the same directory as your test program, correct?
That is enough on my system to connect successfully, control leds and speaker and and receive the moves (positions) updates; I also tried a .NET wrapper and it works just as well with C# and VB.NET
Hi!
Can you please confirm that the way I'm using this SDK is indeed correct? Here is the absolute minimum that I need to do to run my own code:
C:\Users\Incucu\chess> git clone https://github.com/chessnutech/EasyLinkSDK.git C:\Users\Incucu\chess> cd EasyLinkSDK
There I'm creating a new file named demoapp.cpp with the content that I posted above.
Now I modify the CMakeLists.txt file to add demoapp.cpp to the SOURCE_FILES, include SDK directories, and build the executable. The full file looks like this:
cmake_minimum_required(VERSION 3.0.0)
project(EasyLinkSDK VERSION 1.0.0)
add_subdirectory("thirdparty/hidapi")
add_subdirectory("thirdparty/spdlog")
if(CMAKE_HOST_UNIX)
link_libraries(hidapi_hidraw)
elseif(CMAKE_HOST_WIN32)
link_libraries(hidapi)
else()
link_libraries(hidapi)
endif()
# Debug mode
# ADD_DEFINITIONS(-D_DEBUG_FLAG)
link_libraries(spdlog_header_only)
set(SOURCE_FILES EasyLink.h EasyLink.cpp easy_link_c.cpp easy_link_c.h demoapp.cpp)
add_library(easylink SHARED ${SOURCE_FILES})
add_library(easylink_static STATIC ${SOURCE_FILES})
# Set the path to the EasyLinkSDK
set(EASYLINK_SDK_DIR "C:/Users/Incucu/chess/EasyLinkSDK")
# Include the EasyLinkSDK header directory
include_directories(${EASYLINK_SDK_DIR})
# Set the path to the library files
set(EASYLINK_LIB_DIR "${EASYLINK_SDK_DIR}/build/Debug")
# executable demoapp
add_executable(demoapp demoapp.cpp)
# Link against the dynamic library
target_link_libraries(demoapp
${EASYLINK_LIB_DIR}/easylink.lib
)
Now I run the following:
C:\Users\Incucu\chess\EasyLinkSDK> mkdir build C:\Users\Incucu\chess\EasyLinkSDK> cd build C:\Users\Incucu\chess\EasyLinkSDK\build> cmake .. C:\Users\Incucu\chess\EasyLinkSDK\build> cmake --build . C:\Users\Incucu\chess\EasyLinkSDK\build> cd Debug C:\Users\Incucu\chess\EasyLinkSDK\build\Debug> .\demoapp.exe
And now my code gets executed. And easylink.dll is in the same directory as the executable.
Am I missing something or this is the way it should work?
Incucu
Hi!
Can you please confirm that the way I'm using this SDK is indeed correct? Here is the absolute minimum that I need to do to run my own code:
C:\Users\Incucu\chess> git clone https://github.com/chessnutech/EasyLinkSDK.git C:\Users\Incucu\chess> cd EasyLinkSDK
There I'm creating a new file named demoapp.cpp with the content that I posted above.
Now I modify the CMakeLists.txt file to add demoapp.cpp to the SOURCE_FILES, include SDK directories, and build the executable. The full file looks like this:
cmake_minimum_required(VERSION 3.0.0) project(EasyLinkSDK VERSION 1.0.0) add_subdirectory("thirdparty/hidapi") add_subdirectory("thirdparty/spdlog") if(CMAKE_HOST_UNIX) link_libraries(hidapi_hidraw) elseif(CMAKE_HOST_WIN32) link_libraries(hidapi) else() link_libraries(hidapi) endif() # Debug mode # ADD_DEFINITIONS(-D_DEBUG_FLAG) link_libraries(spdlog_header_only) set(SOURCE_FILES EasyLink.h EasyLink.cpp easy_link_c.cpp easy_link_c.h demoapp.cpp) add_library(easylink SHARED ${SOURCE_FILES}) add_library(easylink_static STATIC ${SOURCE_FILES}) # Set the path to the EasyLinkSDK set(EASYLINK_SDK_DIR "C:/Users/Incucu/chess/EasyLinkSDK") # Include the EasyLinkSDK header directory include_directories(${EASYLINK_SDK_DIR}) # Set the path to the library files set(EASYLINK_LIB_DIR "${EASYLINK_SDK_DIR}/build/Debug") # executable demoapp add_executable(demoapp demoapp.cpp) # Link against the dynamic library target_link_libraries(demoapp ${EASYLINK_LIB_DIR}/easylink.lib )
Now I run the following:
C:\Users\Incucu\chess\EasyLinkSDK> mkdir build C:\Users\Incucu\chess\EasyLinkSDK> cd build C:\Users\Incucu\chess\EasyLinkSDK\build> cmake .. C:\Users\Incucu\chess\EasyLinkSDK\build> cmake --build . C:\Users\Incucu\chess\EasyLinkSDK\build> cd Debug C:\Users\Incucu\chess\EasyLinkSDK\build\Debug> .\demoapp.exe
And now my code gets executed. And easylink.dll is in the same directory as the executable.
Am I missing something or this is the way it should work?
Incucu
If you add source files directly, you only need to add the following content to CMakeLists.txt Reminder: No modification is required to the original contents of CMakeLists.txt
add_executable(demoapp demoapp.cpp)
target_link_libraries(demoapp
easylink_static
)
Hello!
I recently received Chessnut Pro, am really happy with the product! Can EasyLinkSDK also be used to build applications for Chessnut Pro?
I was able to build the code using Windows 11 and documented dependencies. But now I'm puzzled about how to connect as the function cl_connect() does take no arguments (COM port, BT?) and seems always to succeed even if no board is connected. cl_beep() and cl_led() seem not to do anything either... So I guess the connection never happens.
Can you please help me a bit with my first steps? :)
Incucu
Currently only USB connection is supported. cl_connect() does not accept any parameters because all hardware connection related information is handled internally.
When developing this interface, I imagined that users do not need to consider how to connect the hardware when using it, so all connection related information is encapsulated internally.
Pro support has been added, please use the latest code
Thank you guys for help and for adding Chessnut Pro support, I am now able to connect! :)
All the best! Incucu
Hello!
I recently received Chessnut Pro, am really happy with the product! Can EasyLinkSDK also be used to build applications for Chessnut Pro?
I was able to build the code using Windows 11 and documented dependencies. But now I'm puzzled about how to connect as the function cl_connect() does take no arguments (COM port, BT?) and seems always to succeed even if no board is connected. cl_beep() and cl_led() seem not to do anything either... So I guess the connection never happens.
Can you please help me a bit with my first steps? :)
Incucu