The FANUC FOCAS shared library from the FANUC FOCAS CD A02B-0207-K737 version 4.1 or higher must first be installed and registered in Ubuntu 14.04 LTS.
$ sudo cp libfwlib32.so.1.0.0 /usr/local/lib/libfwlib32.so.1.0.0 $ sudo ldconfig $ sudo ln -s /usr/local/lib/libfwlib32.so.1.0.0 /usr/local/lib/libfwlib32.so
Next up we need to get the MTConnect adapter from GitHub.
$ cd ~ $ git clone https://github.com/mtconnect/adapter.git
We only actually need a limited subset of files from the adapter downloaded from GitHub. For convenience in building the binary we will copy all the needed files to the same directory. (Note, so wildcards can be used more than the needed files are copied.)
$ mkdir fanuc $ cp ~/adapter/fanuc/adapter.ini ~/fanuc/adapter.ini $ cp ~/adapter/fanuc/fanuc.xml ~/fanuc/fanuc.xml $ cp ~/adapter/fanuc/*.cpp ~/fanuc/ $ cp ~/adapter/fanuc/*.hpp ~/fanuc/ $ cp ~/adapter/src/*.cpp ~/fanuc/ $ cp ~/adapter/src/*.hpp ~/fanuc/ $ cp ~/adapter/minIni_07/*.c ~/fanuc/ $ cp ~/adapter/minIni_07/*.h ~/fanuc/
Once the files are in the ~/fanuc/ directory, we need to modify the source code. The GitHub adapter was meant for Windows, and their are several functions that need to be modified.
$ sudo nano ~/fanuc/fanuc_adapter.cpp Remove: #include <excpt.h> Change: __try and __exception to try/catch(...) Change: Sleep(5000) to sleep(5) Change: _strnicmp() to strncasecmp() Add Before : short ret = :: cnc_allclibhndl3... long level = 3; std::string filename = "focas.log"; const char * c = filename.c_str(); short log = ::cnc_startupprocess(level, c); Add After: cnc_freelibhndl.... cnc_exitprocess();
Finally the header file for Linux from the FOCAS cd is copied to the directory. Note the name change required as the source files refer to to Fwlib32.h.
$ sudo cp fwlib32.h ~/fanuc/Fwlib32.h
With the source code modified, its time to compile the binary. Sorry for the sloppy g++ command, this could be cleaned up with a nice CMakeLists.txt.
$ cd ~/fanuc/ $ g++ minIni.c device_datum.cpp fanuc_axis.cpp fanuc_path.cpp service.cpp condition.cpp cutting_tool.cpp string_buffer.cpp logger.cpp client.cpp server.cpp adapter.cpp fanuc_adapter.cpp FanucAdapter.cpp -lfwlib32 -lpthread -o adapter
Finally setup the adapter.ini file with the appropriate settings for your machine and run the binary.
$ ./adapter debug adapter.ini
Conclusion I’m certain one day the source code for the Linux FANUC adapter will be available from GitHub as the code is just a slight adaptation from the Windows version. Until then, I hope you enjoyed this tutorial!
Hello! How i find libfwlib32?
It is on of the Fanuc Focas CD. Call Fanuc and get a quote to purchase the CD.