Recognizing a Missed Call on BlackBerry 10 - call

Regarding:
http://developer.blackberry.com/native/reference/cascades/bb_system_phone__calltype.html
Anyone know why I can't get the "Missed" call type to work on the callUpdated slot?
if (bb::system::Phone::CallType::Missed == call.callType()){
missedLed->setColor(bb::device::LedColor::Yellow);
missedLed->flash();
}
doesn't work
but
if (bb::system::Phone::CallType::Incoming == call.callType()){
missedLed->setColor(bb::device::LedColor::Yellow);
missedLed->flash();}
and
if (bb::system::Phone::CallType::Outgoing == call.callType()){
missedLed->setColor(bb::device::LedColor::Yellow);
missedLed->flash();
}
works
Why?
I have all the pro file, hpp stuff, permission etc in there. So those aren't the problem.

Related

Console Screen Hides after implementing a API function from (windows.h)in C

I am new to C language but having experience in higher level language such as java, python.....etc.
I am trying to resize the console window in Windows OS. Using the "SetConsoleWindowInfo and SetConsoleScreenBufferSize" function from "windows.h" header file.
But while I try to run that code the console window hides in the taskbar and nothing is happening. While I try to run the code in vsCode the integrated terminal prints nothing.
Here is my code
void setConsole(short consolePos_X, short consolePos_Y, short consoleWidth, short consoleHeight){
HANDLE wConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT consoleWinSize = {consolePos_X, consolePos_Y, consolePos_X+consoleWidth, consolePos_Y+consoleHeight};
SetConsoleWindowInfo(wConsoleHandle, TRUE, &consoleWinSize);
COORD buffSize = {100, 50};
SetConsoleScreenBufferSize(wConsoleHandle, buffSize);
SetConsoleTitle("Snake Game");
I think the problem is with setting buffersize but I am not sure.
Hope I will get Solution.
Thanks in Advance...!
Change your code as follow:
HANDLE wConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
if (wConsoleHandle == INVALID_HANDLE_VALUE) {
fprintf(stderr, "GetStdHandle failed with error %d\n", GetLastError());
return;
}
There should be no error here, unless your application has no console allocated.
And also change as follow:
if (!SetConsoleWindowInfo(wConsoleHandle, TRUE, &consoleWinSize)) {
fprintf(stderr, "SetConsoleWindowInfo failed with error %d\n", GetLastError());
return;
}
It is likely that the error is 87 (Invalid parameter). Check the values, especially the consoleWinSize. If it is, then look at this and this.
Hey I Found The Solution.
The problem is that the "ConsoleScreenBufferSize" should not be less than the "ConsoleWindowSize" (More info here). But I have used a "BufferSize" which is less than the "ConsoleSize". So the problem aries.
Solution for this problem is just to use the "BufferSize" Greater than or equal to the "ConsoleSize".
As follows:
COORD coord = {consoleWidth, consoleHeight};
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), &coord);
And this just works fine.
If you have anydoubts fell free to comment here.
I will try to answer in my free time
Hope this is useful..!

how do i sequence methods in libgdx

I am using libgdx and i have several game objects with different methods i want the methods in my timer to happen one after another but in libgdx they happen all at once i dont know how to fix it
timer.scheduleTask( task = new Task(){ public void run(){
rando =rn.nextInt(8);
Gdx.app.log("the num is", Integer.toString(rando));
if(rando == 0){
bush.rustle();
bush2.rustle2();
bush3.dontrustle3();
bush4.dontrustle4();
enemy.shoot();
enemy2.shoot();
enemy3.godown();
enemy4.godown();
}
if(rando == 1){
bush.dontrustle();
bush2.rustle2();
bush3.rustle3();
bush4.dontrustle4();
enemy.godown();
enemy2.shoot();
enemy3.shoot();
enemy4.godown();
}
if(rando == 2){
bush.rustle();
bush2.dontrustle2();
bush3.rustle3();
bush4.rustle4();
enemy2.godown();
enemy.shoot();
enemy4.shoot();
enemy3.shoot();
}
if(rando == 3){
bush.rustle();
bush2.rustle2();
bush3.rustle3();
bush4.rustle4();
enemy.shoot();
enemy2.goup();
enemy4.goup();
enemy3.shoot();
}
if(rando == 4){
bush.rustle();
bush2.rustle2();
bush3.rustle3();
bush4.rustle4();
enemy2.godown();
enemy.godown();
enemy4.shoot();
enemy3.shoot();
}
how it works is that everytime a number is called a set of methods run but they run all at once i want them to run one after the other
You might look at the libgdx-ai extension. It has some utilities for building up and reacting to events. The state machine is probably overkill for what you want, but might have ideas you can crib from.
See also https://gamedev.stackexchange.com/questions/14568/integrating-an-ai-state-machine-with-actions-that-take-more-than-1-tick
A lighter-weight approach might be something like this: http://vanillajava.blogspot.com/2011/06/java-secret-using-enum-as-state-machine.html (though I recommend doing this mostly as a way to understand the more complex AI library state machine).

Error in output.println() on Processing

I'm trying to read some data from Processing and write it to a file. The data is correct, since I can plot it without problem. However, when I attempt to write it to a file it throws me the following error:
Error, disabling serialEvent() for /dev/ttyACM0
null
Specifically, I've found out where the problem is. It's in this function:
void serialEvent(Serial myPort) {
int inByte = myPort.read();
if (inByte >= 0 && inByte <= 255)
{
// This is what makes the problem arise
output.println("test: " + inByte);
// ...
}
}
I've even changed the line output.println(); with this and then the same function works, printing it to the correct file (but it's obviously not what I want):
// This does work
point(mouseX, mouseY);
output.println(mouseX);
Any idea where the problem might be? I'm using arduino and it passes values from 0 to 255 from serial. The values seem correct, since I can plot them without problem. I've also tried changing println() for print() with no luck.
EDIT. After some testing, I find this really odd. This works:
point(mouseX, mouseY);
output.println(inByte);
While, without the point(), it doesn't work (same error). As a temporary solution, I can put the output.println at the end of the function, but this is obviously not a long-term solution.
I ended up doing a simple check in my code:
if (output != null) {
output.println(t + " " + inByte);
}
It just works. However, I think that polymorphism would be even better here. Having an object that absorbs the text if the output is not initialized, and that prints it to the file if it is.
I had the same problem but here is my solution and it works perfectly.
at the beginning of the code write sth like this:
boolean outputInitialized = false;
after output = createWriter(filename.txt); put following:
outputInitialized = true;
the output.print function has to be included in an if-function:
if (outputInitialized) {
output.println(filename);
}

C_Login fails in PKCS11 in C

Simple issue, but i don't know how to unlock USB Token(epass2003) ,I have try to read PKCS 11 but have no idea how to implement C_Login function for execution in c ,when i am using command line tool (Linux)to do that token is working perfectly fine but with c its not working I have used user type as CKU_USER, Can anyone have knowledge about this, please help
you have to check the return values from the PKCS functions to see if there has been any errors. Try this way and see what happen. If the return code from C_login() is CKR_PIN_LOCKED, then it is clear that you should unlock your card.
CK_RV ret;
ret = C_OpenSession(slot, CKF_SERIAL_SESSION, NULL_PTR, NULL_PTR, &session);
if (ret != CKR_OK){
error_message(ret);
return;
}
readPIN("Intro PIN: ", pin, 4);
ret = (f_C_Login)(hSession,CKU_USER, (unsigned char *) pin,strlen(pin));
if (ret != CKR_OK){
closeSessions(slot);
error_message(ret);
return;
}
A token can get locked due to a certain number of failed login (for TrustKey it is 10). There are provider specific utilities to unlock tokens. You could check Feitian site. There is some pointer to this kind of problem in Gooze forum (though not exactly). Your problem looks quite like a token lock problem.

C programming. Why does 'this' code work but not 'that' code?

Hello I am studying for a test for an intro to C programming class and yesterday I was trying to write this program to print out the even prime numbers between 2 and whatever number the user enters and I spent about 2 hours trying to write it properly and eventually I did it. I have 2 pictures I uploaded below. One of which displays the correct code and the correct output. The other shows one of my first attempts at the problem which didn't work correctly, I went back and made it as similar to the working code as I could without directly copying and pasting everything.
unfortunately new users aren't allowed to post pictures hopefully these links below will work.
This fails, it doesn't print all numbers in range with natural square root:
for (i = 2; i <= x; i++)
{
//non relevant line
a = sqrt(i);
aa = a * a;
if (aa == i);
printf("%d ",i);
}
source: http://i.imgur.com/WGG6n.jpg
While this succeeds, and prints even numbers with natural sqaure root
for (i = 2; i <= x; i++)
{
a = sqrt(i);
aa = a * a;
if (aa == i && ((i/2) *2) == i)
printf("%d ", i);
}
source: http://i.imgur.com/Kpvpq.jpg
Hopefully you can see and read the screen shots I have here. I know that the 'incorrect code' picture does not have the (i/2)*2 == i part but I figured that it would still print just the odd and even numbers, it also has the code to calculate "sqrd" but that shouldn't affect the output. Please correct me if I'm wrong on that last part though.
And Yes I am using Dev-C++ which I've read is kinda crappy of a program but I initally did this on code::blocks and it did the same thing...
Please I would very much appreciate any advice or suggestions as to what I did wrong 2 hours prior to actually getting the darn code to work for me.
Thank you,
Adam
your code in 'that' includes:
if (aa == i);
// ^
printf(...);
[note the ; at the end of the if condition]
Thus, if aa == i - an empty statement happens, and the print always occures, because it is out of the scope of the if statement.
To avoid this issue in the future, you might want to use explicit scoping1 [using {, } after control flow statements] - at least during your first steps of programming the language.
1: spartan programmers will probably hate this statement
Such errors are common. I use "step Over", "Step Into", "Break Points" and "watch window" to debug my program. Using these options, you can execute your program line by line and keep track of the variables used in each line. This way, u'll know which line is not getting executed in the desired way.

Resources