-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
561ce66
commit 6855264
Showing
12 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
example/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from debian:buster-slim | ||
|
||
copy . . | ||
|
||
run ./install.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Fanuc FOCAS Library | ||
Header and runtime files for CNC communication | ||
Header and runtime files for CNC communication | ||
|
||
An example of its use can be found in `example/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cmake_minimum_required(VERSION 3.13.4) | ||
project(AnotherFanucExample LANGUAGES C VERSION 0.1) | ||
|
||
add_subdirectory(src) | ||
|
||
set_target_properties(fanuc_example | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
#add_executable(fanuc_example src/main.c) | ||
#target_link_libraries(fanuc_example m fwlib32 pthread) | ||
|
||
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
|
||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/libfolder") | ||
|
||
install (TARGETS fanuc_example | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION bin | ||
ARCHIVE DESTINATION lib | ||
INCLUDES DESTINATION include | ||
DESTINATION /usr/local/bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from debian:buster-slim as base | ||
|
||
workdir /tmp | ||
copy install.sh fwlib32.h libfwlib32* example/extra-deps.sh ./ | ||
run ./install.sh && ./extra-deps.sh | ||
|
||
from base as builder | ||
|
||
run apt-get update && apt-get install -y \ | ||
build-essential \ | ||
cmake | ||
|
||
workdir /usr/src/app | ||
|
||
copy example/ . | ||
|
||
run mkdir build && \ | ||
cd build && \ | ||
cmake .. && \ | ||
make | ||
|
||
from base | ||
|
||
copy --from=builder /usr/src/app/build/bin/fanuc_example /usr/local/bin/ | ||
|
||
cmd fanuc_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Fanuc fwlib example | ||
An example that connects to a machine specified by MACHINE_IP & MACHINE_PORT in `main.c` | ||
|
||
# Docker Instructions | ||
From the `example/` directory: `docker run --rm --network=host -it $(docker build -f Dockerfile ..)` | ||
|
||
# Manual Instructions | ||
0. Install fwlib32 (`install.sh` may work) | ||
1. `mkdir build && cd build` | ||
2. `cmake ..` | ||
3. `make` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
arch=$(arch) | ||
if [ "$arch" = "x86_64" ]; then | ||
dpkg --add-architecture i386 && apt-get update && apt-get install -y gcc-multilib | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
add_executable(fanuc_example main.c) | ||
|
||
#add_library(fwlib32 SHARED IMPORTED) | ||
#set_property(TARGET fwlib32 PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lib/libfwlib32.so) | ||
|
||
set_target_properties(fanuc_example PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") | ||
|
||
target_link_libraries(fanuc_example m fwlib32 pthread) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "fwlib32.h" | ||
#define MACHINE_IP "127.0.0.1" | ||
#define MACHINE_PORT 8193 | ||
|
||
unsigned short libh; | ||
|
||
void cleanup() { | ||
if (cnc_freelibhndl(libh) != EW_OK) | ||
fprintf(stderr, "Failed to free library handle!\n"); | ||
cnc_exitprocess(); | ||
} | ||
|
||
int main() { | ||
unsigned long cncIDs[4]; | ||
char cncID[36]; | ||
|
||
if (cnc_startupprocess(0, "focas.log") != EW_OK) { | ||
fprintf(stderr, "Failed to create required log file!\n"); | ||
exit(EXIT_FAILURE); | ||
return 1; | ||
} | ||
|
||
printf("connecting to machine at %s:%d...\n", MACHINE_IP, MACHINE_PORT); | ||
if (cnc_allclibhndl3(MACHINE_IP, MACHINE_PORT, 10, &libh) != EW_OK) { | ||
fprintf(stderr, "Failed to connect to cnc!\n"); | ||
exit(EXIT_FAILURE); | ||
return 1; | ||
} | ||
atexit(cleanup); | ||
|
||
if (cnc_rdcncid(libh, cncIDs) != EW_OK) { | ||
fprintf(stderr, "Failed to read cnc id!\n"); | ||
exit(EXIT_FAILURE); | ||
return 1; | ||
} | ||
|
||
if (sizeof(long) == 4) { | ||
sprintf(cncID, "%08lx-%08lx-%08lx-%08lx", cncIDs[0] & 0xffffffff, | ||
cncIDs[1] & 0xffffffff, cncIDs[2] & 0xffffffff, | ||
cncIDs[3] & 0xffffffff); | ||
} else { | ||
sprintf(cncID, "%08lx-%08lx-%08lx-%08lx", cncIDs[0] & 0xffffffff, | ||
cncIDs[0] >> 32 & 0xffffffff, cncIDs[1] & 0xffffffff, | ||
cncIDs[1] >> 32 & 0xffffffff); | ||
} | ||
printf("machine id: %s\n", cncID); | ||
|
||
exit(EXIT_SUCCESS); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
version=1.0.5 | ||
platform=linux | ||
arch=$(arch) | ||
base="$(dirname "$(realpath "$0")")" | ||
if [ "$arch" = "x86_64" ] || [ "$arch" = "x86" ]; then | ||
arch=x86 | ||
elif [ "$arch" = "armv7l" ]; then | ||
arch=armv7 | ||
else | ||
echo "unsupported arch" | ||
exit 1 | ||
fi | ||
cp fwlib32.h /usr/include/ | ||
cp "$base/libfwlib32-$platform-$arch.so.$version" "/usr/local/lib/libfwlib32.so.$version" | ||
ln -sf /usr/local/lib/libfwlib32.so.$version /usr/local/lib/libfwlib32.so | ||
ldconfig |