Modbus compile error

Hi All,

I have a problem to compile the Modbus class. I created the Makefile with POGO. I have this error:"./obj/ClassFactory.o: In function `Tango::DServer::class_factory()':
/home/tango-cs/Desktop/prova12/Modbus/trunk/src/ClassFactory.cpp:58:
undefined reference to `Serial_ns::SerialClass::init(char const*)'
collect2: error: ld returned 1 exit status
/usr/local/share/pogo/preferences/common_target.opt:102: recipe for
target '/home/tango-cs/DeviceServers/Modbus' failed
make: *** [/home/tango-cs/DeviceServers/Modbus] Error 1
"
I think I have included all the necessary files(for example SerialClass.h).

I'm usingUbuntu 18( TangoBox-9.3).

Thanks.
I have the same issue Salvo. I have improvised a workaround in case you are not going to use the serial method class (just Modbus). The shortcut is to comment the serial method class, pretty drastic but it compiles and works. I don't know if there is major implications in doing that. Hope it helps, if you have solved root problem please contact me.

http://svn.code.sf.net/p/tango-ds/code/DeviceClasses/Communication/Modbus/trunk/src/ClassFactory.cpp

/*—– PROTECTED REGION ID(Modbus::ClassFactory.cpp) ENABLED START —–*/
static const char *RcsId = "$Id: $";
//=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
//
// project : Modbus
//
// This file is part of Tango device class.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Author: $
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================

#include <tango.h>
#ifndef NOSERIAL
#include <SerialClass.h>
#endif
#include <ModbusClass.h>

// Add class header files if needed
/**
* Create Modbus Class singleton and store it in DServer object.
*/

void Tango::DServer::class_factory()
{
// Add method class init if needed
// #ifndef NOSERIAL
// add_class(Serial_ns::SerialClass::init("Serial"));
// #endif
add_class(Modbus_ns::ModbusClass::init("Modbus"));
}
/*—– PROTECTED REGION END —–*/ // Modbus::ClassFactory.cpp
I found a better solution.

I have generated a new makefile with POGO as suggested in this post (https://www.tango-controls.org/community/forum/c/general/development/hi-guidance-needed-in-setting-up-modbus-device-server/) but the resulting makefile is different from the original. So Serial.h, Serial.cpp, SerialClass.h and SerialClass.cpp from SerialLine class must be copied into working directory to compile. Is then when the "undefined reference to" error rises, if we compare both makefiles…

ORIGINAL (http://svn.code.sf.net/p/tango-ds/code/DeviceClasses/Communication/Modbus/trunk/src/Makefile)

#=============================================================================
# MAKE_ENV is the path to find common environment to buil project
#
MAKE_ENV = /segfs/tango/cppserver/env

ifndef NOSERIAL
SERIAL_DIR = /segfs/tango/cppserver/protocols/SerialLine/src
endif

POGO SELF GENERATED (if java-tools is installed from https://people.debian.org/~picca/libtango-java_9.2.5a-1_all.deb package)

#=============================================================================
# MAKE_ENV is the path to find common environment to buil project
#
MAKE_ENV = /usr/share/pogo/preferences
As it can be noticed, SERIAL_DIR is missing in the self generated pogo makefile. The solution that works for me is to download SerialLine (http://svn.code.sf.net/p/tango-ds/code/DeviceClasses/Communication/SerialLine/) and use the original makefile replacing:

MAKE_ENV = /segfs/tango/cppserver/env
for
MAKE_ENV = /usr/share/pogo/preferences

and

SERIAL_DIR = /segfs/tango/cppserver/protocols/SerialLine/src
for
SERIAL_DIR = /yourpathtoclonedSerialLineclass/trunk/src

With SerialLine source directory located you make sure all the SerialLine necessary files used in Modbus are well referenced. Is important then take into account that the original MAKE_ENV and SERIAL_DIR are a particular case of location files for the developer and you may change it to your convenience.

Hope it helps!smile
Edited 3 years ago
 
Register or login to create to post a reply.