field 'info' must be a network type - tinyos

I'm a beginner and I try to create a struct in nesc for a tinyos app, but i have this error that i don't know how to fix.
Any ideas?
The code of the struct is:
typedef nx_struct Message
{
nx_uint16_t ID
float info;
} messaget;

I think you're just missing a semicolon after ID. Also, the name you are giving your type is very close to message_t which is already used by TinyOS - I would recommend giving it a more descriptive name, like MyInformationMessage_t.

You missed a ; after nx_uint16_t ID. A sample message may go like this:
typedef nx_struct test_message
{
nx_uint16_t ID
float info;
} test_message_t;
If you want to learn more about how to use structs to define message formats and directly access messages. You may refer to section 3.5.3 Platform-independent types in TinyOS Programming
, a Book by David Gay and Philip A. Levis.

Related

omnet++/veins : some sumo/traci commands seem to be not implemented

I would like to use some sumo/traci commands that seem to be not implemented in omnet++/veins, such as :
traffic light commands setRedYellowGreenState(tlsID, state) for example
junction command
and other commands
What is the simplest way to be able to use these commands from omnet++/veins?
Thank you very much for the help.
Regards :)
You can find the existing client source code for interacting with SUMO in TraCICommandInterface.cc, for example to set a TL program:
TraCIBuffer buf = connection->query(CMD_SET_TL_VARIABLE, TraCIBuffer()
<< static_cast<uint8_t>(TL_PROGRAM)
<< trafficLightId
<< static_cast<uint8_t>(TYPE_STRING)
<< program
);
The corresponding server source code can be found in TraCIServerAPI_TLS.cpp, for example to set a TL program:
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// [...] case TL_PROGRAM:
server.readTypeCheckingString(inputStorage, subID)
vars.switchTo(tlsControl, subID);
By investigating how the server is prepared to interact with the client (and how the client is already interacting with the server) you should be able to extend the client according to your wishes.

How can i iterate over a basic blocks in a specific routine in intel pintool?

I tried to iterate over a basic blocks in a specific routine, but i found some problems:
VOID Routine(RTN rtn, VOID *v)
{
RTN_Open(rtn)
for (BBL bbl = RTN_BblHead(rtn); BBL_Valid(bbl); bbl = BBL_Next(bbl))
{ /* some code */ }
RTN_Close(rtn);
}
error: deprecated-declarations,
How can i fix that error, or do it by another way ?
You have a deprecated-declarations warning because RTN_BblHead is now deprecated. Use RTN_InsHead instead.
From include\pin\gen\image.ph:
/* DO NOT EDIT */
/* RTN_BblHead is now deprecated. See RTN_InsHead.
*/
extern PIN_DEPRECATED_API BBL RTN_BblHead(RTN x);
This is also mentioned in the documentation: RTN_BblHead
You can also pass -Wno-deprecated-declarations to GCC to suppress this warning.
Edit
Remember that PIN is above all a DBI (dynamic binary instrumentation) framework: it is extremely good when it comes to instrument the executed code flow, and less good when it needs to break down non executed code.
Routine instrumentation lets the Pintool inspect and instrument an entire routine when the image it is contained in is first loaded' but as the documentation points:
A Pintool can walk the instructions of a routine. There is not enough
information available to break the instructions into BBLs.
Pin find the instructions of a RTN through static discovery, so Pin cannot guarantee that it will find all the instructions in the RTN and this is even more difficult for BBLs. My guess is that they tried at some point (hence the availability of RTN_BblHead in the past) to provide static discovery of BBLs but the discovery rate was too low (or too error prone) to be deemed acceptable, so the function became deprecated.
In short, yes you need to discover a RTN instructions by instructions (knowing that pin might miss some instructions as this is done statically). You can only discover the BBLs of a routine if the routine is executed at some point.

Using ElectricImp server.show() and Arduino

I'm following the sparkfun tutorial for connecting an arduino to electric imp. I only have one arduino and imp, so I'm trying to get whatever I type in the arduino serial monitor to display in the imp node using server.show().
I've modified one of the functions in the sparkfun code to look like this:
function pollUart()
{
imp.wakeup(0.00001, pollUart.bindenv(this)); // schedule the next poll in 10us
local byte = hardware.uart57.read(); // read the UART buffer
// This will return -1 if there is no data to be read.
while (byte != -1) // otherwise, we keep reading until there is no data to be read.
{
// server.log(format("%c", byte)); // send the character out to the server log. Optional, great for debugging
// impeeOutput.set(byte); // send the valid character out the impee's outputPort
server.show(byte)
byte = hardware.uart57.read(); // read from the UART buffer again (not sure if it's a valid character yet)
toggleTxLED(); // Toggle the TX LED
}
}
server.show(byte) is only displaying seemingly random numbers. I have an idea of why this is, I just don't know how to fix it because I'm not that familiar with UARTs and squirrel.
local byte = hardware.uart57.read(); reads in the ascii characters from the arduino in byte form (I think), and they're not being 'translated' into their ascii characters before I use server.show(byte).
How do I do this in squirrel?
Also, I think polling every 10us is the wrong way to go here. I'd like to only poll when there's new information, but I also don't know how to do that in squirrel. Can someone point me to an example where this happens?
Thanks!
I think you are passing the wrong data type to the show method of the server object. The electric imp docs state that it takes a string, server.show(string). I think that local is the correct type to receive the value from hardware.uart57.read(). You can tell from the docs as well. So, you need to find a way to cast your byte to a string. I bet you could find the answer here. From what I read Squirrel use's Unicode so there is a probably a function that takes Unicode bytes and loads them into a string object.

Using sqlite database with qt

Here is my code, there doesn't seem to be anything wrong:
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("thedata.sqlite");
db.open();
QSqlQuery query;
query.prepare("SELECT lastname FROM people where firstname='?' ");
query.bindValue(0, lineEdit->text());
bool x = query.exec();
if(x){
lineEdit_2->setText(query.value(0).toString());
}
else {
QSqlError err;
err = query.lastError();
QMessageBox::about(this,"error",err.text() );
}
When the program is working always it gives the error parameter count mismatch I'm using qt 4.8 and its own headers for using sqlite.
I would be very thankful for any advice, though I searched in google i see many posts in this issue but nothing helped me.
Thank you.
You're prepared statement is wrong, it should be:
quary.prepare("SELECT lastname FROM people where firstname=?");
Notice that there are no single quotes (') around the placeholder. If you put the quotes, it gets passed as a literal to the database, leaving you with a parameter-less query and code that passes too many parameters.
(Changing that variable name to query would be a nice touch too.)
Also you need to check the return value if QSqlQuery::prepare, and print out/display the error message you're getting from that if it fails – otherwise QSqlQuery::exec resets the current error and you'll get a pretty meaningless error message if there was a problem parsing the prepared statement.
if(x){
lineEdit_2->setText(quary.value(0).toString());
}
This is incorrect too. The you need to call (and check the return value of) query.next() to position the result set to the first row returned (if there is one). You can't use .value(X) before you've called .next().

Warning: XXX may not respond to YYY

Hey, I am making some stuff in Objective-C++... And I must say that I am a total newbie when it comes to the Objective-C part... I don't really want to learn it, I kinda just need it for accessing a few Mac APIs (ObjC is such a dumb language).
So - compiling with g++ -x objective-c++ - and I somehow keep getting this warning:
XXX may not respond to YYY
First it was with a NSScreen, now it is with a NSWindow:
NSWindow may not respond to +initWithContentRect:styleMask:backing:defer:
I saw somewhere that I should cast it to id, but didn't work, throwing absolutely cryptic errors...
So - WHAT does this warning actually mean and HOW am I supposed to make it stop?
EDIT: Okay, apparently I need to ALLOCATE an instance first, then I can call its init function... Anyways, now the GCC is reporting:
confused by earlier errors, bailing out
And NOTHING else. This is the ONLY error that it reports. I figured that there is some error in my code that doesn't get reported... So I will post the whole file where the problem is here:
ONXeWindow::ONXeWindow(int px, int py, int sw, int sh, bool resizable){
NSRect wr = NSMakeRect(px, py, sw, sh);
int wf = 1; // titled
wf += 2; // closable
wf += 4; // miniaturizable
wf += (resizable ? 8 : 0); // resizable
wf += (false ? 128 : 0); // metal bg
useWindow = [[NSWindow alloc] initWithContentRect:wr styleMask:wf backing:2 defer:YES];
}
Also, YES, framework AppKit was imported (in the header file) - I am not going to confuse you with my weird file scheme here.
The message isn't really cryptic, you just don't know the language (and don't care to, by your own admission).
Since Objective-C methods are dispatched dynamically at run-time, you can call a method that the compiler doesn't have any knowledge of, however, the compiler is warning you that you're doing so. The + in the beginning of the method name means that you're calling a class method (a - would indicate that you're calling a method on an instance). Since NSWindow has no class method named initWithContentRect:styleMask:backing:defer:, the compiler is giving you a warning, and in this case, it's a pretty good one.
You probably wrote something like:
NSWindow* myWindow = [NSWindow initWithContentRect:rect styleMask:0 backing:0 defer:NO];
when you meant to write something like:
NSWindow* myWindow = [[NSWindow alloc] initWithContentRect:rect styleMask:0 backing:0 defer:NO];
The first one sends the message directly to the class, but this is an instance method. You need to allocate an instance of NSWindow first, then send the init message. Also, clang tends to give much better warning and error messages than gcc. Clang 2.0 also handles C++ and ObjC++ pretty well, so it might be worth it to switch to clang.
Checkout this example, looks like you are not allocating your objects.

Resources