error: cannot allocate an object of abstract type ‘FRONTEND_RFInfo_In_i - redhawksdr

Using:
Redhawk 1.9 / CentOS 6.4 (32 bit) / C++ implementation
Creating a new FRONTEND::TUNER device
Using default setting on code generation
The following error message happens when I add the following port required for FRONTEND Digital Tuner and regenerate the code.
<ports>
<provides repid="IDL:FRONTEND/DigitalTuner:1.0" providesname="DigitalTuner"/>
<provides repid="IDL:FRONTEND/RFInfo:1.0" providesname="RFInfo"/>
</ports>
Error message (Problems window):
cannot allocate an object of abstract type
‘FRONTEND_RFInfo_In_i’ TestFrontEndDevice_base.cpp /TestFrontEndDevice/cpp line 50 C/C++ Problem
Error message (console):
port_impl.h:56: note: because the following virtual functions are
pure within ‘FRONTEND_RFInfo_In_i’:
/usr/local/redhawk/core/include/redhawk/FRONTEND/RFInfo.h:323: note:
virtual void FRONTEND::_impl_RFInfo::rf_flow_id(const char*)
/usr/local/redhawk/core/include/redhawk/FRONTEND/RFInfo.h:325: note:
virtual void FRONTEND::_impl_RFInfo::rfinfo_pkt(const
FRONTEND::RFInfoPkt&)
make: * [TestFrontEndDevice-TestFrontEndDevice_base.o] Error 1

There appears to be a bug in the code generation for the RFInfo class. If you compare the signatures of the generated code in the port_impl.h file to those of the "unimplemented" ones above, you'll notice that for the rf_flow_id function in port_impl.h there is no const keyword. The same can be said about the rfinfo_pkt method. It is missing the const keyword and an ampersand in the function declaration.
To fix this, simply add the const keywords and the ampersand in the appropriate places in both the declaration in the port_impl.h file and the definition in the port_impl.cpp file.

This is a known issue that has been fixed for the 1.9.1 release.
The problem is the result of the RFInfo port function signatures in
the generated port_impl.* files being different from those in the
parent/base class, which also happen to be pure virtual. To fix the
issue in your code, you'll need to add "const" to rf_flow_id, and both
"const" and "&" to rfinfo_pkt, as shown below:
In port_impl.h:
- void rf_flow_id( char* data);
+ void rf_flow_id( const char* data);
- void rfinfo_pkt( FRONTEND::RFInfoPkt data);
+ void rfinfo_pkt( const FRONTEND::RFInfoPkt& data);
In port_impl.cpp:
-void FRONTEND_RFInfo_In_i::rf_flow_id( char* data)
+void FRONTEND_RFInfo_In_i::rf_flow_id( const char* data)
-void FRONTEND_RFInfo_In_i::rfinfo_pkt( FRONTEND::RFInfoPkt data)
+void FRONTEND_RFInfo_In_i::rfinfo_pkt( const FRONTEND::RFInfoPkt& data)

Related

How to fix v8 deprecated GetFunction?

I'm trying to repair node-osmium so that it works with Node 12 as I've got some old code I'd like to run.
v8 has now fully deprecated a lot of APIs that do not signal failure properly. These were previously only warnings of deprecation soon, they're now errors so it will no longer build. I (think I've) fixed most of these by following this CPP STYLE GUIDE.md's use maybe version of v8 APIs section.
But, i'm stuck with this error for GetFunction:
../src/utils.hpp:39:67: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(T::constructor)->GetFunction(), 1, &ext);
I assume it's a similar fix as the other functions, but where do I get the context from in this constructor?
extract from node-osmium/src/utils.hpp:
namespace node_osmium {
template<class T>
auto unwrap(const v8::Local<v8::Object>& object) -> decltype(Nan::ObjectWrap::Unwrap<T>(object)->get()) {
return Nan::ObjectWrap::Unwrap<T>(object)->get();
}
template<class T, class... Args>
v8::Local<v8::Object> new_external(Args&&... args) {
Nan::EscapableHandleScope scope;
v8::Local<v8::Value> ext = Nan::New<v8::External>(new T(std::forward<Args>(args)...));
Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(T::constructor)->GetFunction(context), 1, &ext);
if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Buffer instance");
return scope.Escape(maybe_local.ToLocalChecked());
}
v8::Local<v8::Value> create_js_box(const osmium::Box& box);
osmium::osm_entity_bits::type object_to_entity_bits(v8::Local<v8::Object> options);
} // namespace node_osmium

Broken code generation for out function parameters

I made my own interface, simplistic version looks like this:
#ifndef _FOO_IDL_
#define _FOO_IDL_
module FOO {
typedef unsigned long Bar;
interface FOOInterface {
void getBar(out FOO::Bar b);
};
};
#endif
After that I made "REDHAWK IDL Project", used that IDL, compiled, installed.
Then I made Redhawk component, added output port and used that interface on it, did code generation. During compilation I got error:
port_impl.h:26:29: error: expected ‘,’ or ‘...’ before ‘&&’ token
void getBar(FOO::Bar&& b);
It looks like code generator adds excessive ampersand. What could I do about it?
Thank you.

Pubnub library not compiling on Particle Photon

I am trying to publish a message using pubnub on the Particle Photon. The code snippet below comes straight out of the Pubnub example code.
The code will not compile, with the message from the compiler as follows:
PubNub/PubNub.h:87:47: error: expected class-name before '{' token
class PubSubClient: public PubNub_BASE_CLIENT {
^
PubNub/PubNub.h: In constructor 'PubSubClient::PubSubClient()':
PubNub/PubNub.h:23:28: error: class 'PubSubClient' does not have any field named 'WiFiClient'
#define PubNub_BASE_CLIENT WiFiClient
^
The code for this tiny project is as follows:
// This #include statement was automatically added by the Particle IDE.
#include "PubNub/PubNub.h"
char pubkey[] = "<key here>";
char subkey[] = "<key here>";
char channel[] = "Channel";
void setup() {
Serial.begin(9600);
Particle.publish("Serial set up");
PubNub.begin(pubkey, subkey);
}
void loop() {
TCPClient *client;
char msg[64] = "{\"photon\":\"on\"}";
client = PubNub.publish(channel, msg);
client->stop();
Delay (30000);
}
Has anyone had a similar problem, and if so, can you guide me as to how to fix this.
Thanks.
It looks like the library available in Build IDE was in an older version (0.0.1). Fixed, latest version (0.0.2) has been published.
To update library in your app you need to remove the PubNub library from your app in Apps drawer:
And then go to Libraries drawer, find PubNub library, click Include in App, select your app and confirm:

GoogleTest CMake doesn't recognize TEST_F: Like it's not recognizing GTest something

OK, I admit it, this is a unique case. When we build our application we are using make, so I've included my tests in a test folder under src. Then at the same level as our release folder we have created a unit-test folder that includes all of our source files and our test source files.
But my IDE is CLion, which uses CMake. In my CMakeLists.txt file, I have included:
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(TestProject ${SOURCE_FILES})
target_link_libraries(TestProject ${GTEST_BOTH_LIBRARIES})
I am creating my first Test Fixture. Here is the code:
#include "OPProperties.h"
#include "gtest/gtest.h"
namespace {
// The fixture for testing class OPPropertiesTestTest.
class OPPropertiesTestTest : public ::testing::Test {
protected:
// You can remove any or all of the following functions if its body
// is empty.
OPPropertiesTestTest() {
// You can do set-up work for each test here.
}
virtual ~OPPropertiesTestTest() {
// You can do clean-up work that doesn't throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
virtual void SetUp() {
// Code here will be called immediately after the constructor (right
// before each test).
}
virtual void TearDown() {
// Code here will be called immediately after each test (right
// before the destructor).
}
// Objects declared here can be used by all tests in the test case for OPPropertiesTestTest.
};
TEST_F(OPPropertiesTestTest, ThisTestWillFail) {
EXPECT_EQ(0, 2);
}
} // namespace
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Here is an image capture:
Notice the syntax checker errors in my TEST_F function. When I started to type TEST_F code completion is trying to find a Boost Test Function.
Can someone tell me what else I need to add to the CMakeLists.txt file or what I am not doing that GTest functions are not being recognized?
As πάντα ῥεῖ pointed out, I hadn't actually tried to build the code. When I did I first received a linker error for pthread, so we added the following line the the CMakeLists.txt file:
target_link_libraries(OnePrint pthread)
Then I tried again to build and received these errors:
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_key_create'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_getspecific'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_key_delete'
/home/user/gtest-1.7.0/lib/.libs/libgtest.so: undefined reference to `pthread_setspecific'
collect2: error: ld returned 1 exit status
So, I ran a search on these errors and found this question.
The answer that worked for me was here.

NodeJS, TypeScript and typescript-collections

I'm trying to use the Dictionary class from from typescript-collections within NodeJS:
/// <reference path="../../../scripts/collections.ts" />
var collections = require('../../../scripts/collections');
export class AsyncProcessorCommand implements interfaces.IAsyncProcessorCommand
{
public static Type = 'RabbitMon.AsyncProcessorCommand:RabbitMon';
public GetType = () => 'RabbitMon.AsyncProcessorCommand:RabbitMon';
public ID: string;
constructor(public Action: string, public Arguments?: collections.Dictionary<string, string>) {
this.ID = uuid.v4();
this.Arguments = new collections.Dictionary<string, string>();
//I've also tried the following
//this.Arguments = new collections.Dictionary<string, string>((key: string) => sha1(key));
}
}
But I keep getting the following error on the new Dictionary:
TypeError: undefined is not a function
Anyone know what's going on here? I'm also perfectly happy to substitute a better working TS collections library...
You have a internal vs external modules problem.
The TypeScript Collections library is written as an internal module -- a standard JavaScript file that you could just throw in to a script tag in a webpage.
Node's require, however, is expecting an CommonJS-compatible file that will assign something to exports, in other words an external module. What's happening is that node.js finds collections.js, executes it, and returns you back the exports object from evaluating the file. Because it's just a regular JS file, the exported object is {} -- empty.
The best fix would be:
Replace your reference to collections.ts with one to collections.d.ts, just for correctness's sake (run tsc --d collection.ts to generate this file)
Use some solution for loading "vanilla" JS files in node. A good one-liner (from the linked question) is eval(require('fs').readFileSync('./path/to/file.js', 'utf8'));

Resources