Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
111 user(s) are online (77 user(s) are browsing Forums)

Members: 1
Guests: 110

trixie, more...

Headlines

 
  Register To Post  

Waiting for mp_SigBit from RegisterApplication
Just popping in
Just popping in


See User information
I'm trying to Wait for signals coming to my registered application, along withew Ctrl-C and ARexx messages. But I don't seem to get any signals, when waiting for the mp_SigBit from the MsgPort gotten with GetApplicationAttrs. I do however get messages on the MsgPort, when doing a WaitPort.

This is a compilable example, where I test what I want to achieve (so it's not pretty or anything). In my real applicaton, I use the same kind of code, and can successfully receive both Ctrl-C and ARexx signals.
// g++ apptest.cpp -ggdb -lauto -o apptest
//
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/application.h>
#define LOG_DEBUG IDOS->Printf
#define LOG_INFO IDOS->Printf

int main(int argcchar **argv) {   
    
struct MsgPort msgPort NULL;

    
uint32 signal;
    
int loop 10;
    
struct Message msg NULL;
    
msg = new struct Message();

    
uint32 appId 0;
    
appId IApplication->RegisterApplication(
        
"test",
        
REGAPP_URLIdentifier"test.amigaos.se",
        
REGAPP_UniqueApplicationTRUE,
        
TAG_DONE
    
);
    
LOG_INFO("Got appId: %ld\n"appId);
    if(
appId == 0) {
        
LOG_INFO("Couldn't register application!\n");
        return 
20;
    }

    if(!
IApplication->GetApplicationAttrs(appIdAPPATTR_Port, &msgPortTAG_DONE)) {
        
LOG_INFO("Couldn't get application attributes!\n");
        return 
20;
    }
    
LOG_INFO("Got msgPort: %lx, sigbit: %ld\n"msgPortmsgPort->mp_SigBit);

    
// I believe this should be set to signal
    // the mp_SigBit and not only the port?
    // Works equally bad with or without.
    
msgPort->mp_Flags << PA_SIGNAL;

    do {
        
        
// This code works:
        /* Uncomment from here...
        msg = IExec->WaitPort(msgPort);

       
        while(msg != NULL) {
            msg = IExec->GetMsg(msgPort);

            LOG_DEBUG("Got message: %lx! (%ld)\n", msg, loop);
        }
        .... to here. */

        
loop loop-1;
        
// This code doesn't work
        // From here...
        
signal IExec->Wait(SIGBREAKF_CTRL_C msgPort->mp_SigBit );

        if (
signal msgPort->mp_SigBit) {
            
LOG_DEBUG("Got App port!\n");

        } else if (
signal SIGBREAKF_CTRL_C) {

            
LOG_DEBUG("Got Ctrl-C\n");
            
loop=0;
        } else {
            
LOG_DEBUG("Something else\n");
        }
        
// ...to here

    
} while(loop >0);
    
LOG_DEBUG("Aftermainloop.\n");


    
IApplication->UnregisterApplication(appIdNULL);

    return 
0;
}

Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Home away from home
Home away from home


See User information
use this for bit mask.

(1 << msgPort->mp_SigBit)



my_sigs = SIGBREAKF_CTRL_C;
my_sigs |= 1<<msgPort->mp_SigBit;


signal = IExec->Wait( my_sigs );

if you need to remove a bit from bitmask you can do.

my_sigs &= ~ 1<<msgPort->mp_SigBit;

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just popping in
Just popping in


See User information
Great! Quick answer, and absolutely correct! Thanks!

And its kind of obvious -- sigbit.

Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just can't stay away
Just can't stay away


See User information
@jaokim

You are aware that this line from your code is a no-op, right?

// I believe this should be set to signal
// the mp_SigBit and not only the port?
// Works equally bad with or without. 
msgPort->mp_Flags << PA_SIGNAL;


Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just popping in
Just popping in


See User information
@salass00

Looking at it, yes. Probably some left over from my testing. Also, I never delete the allocated MsgPort struct.

Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just can't stay away
Just can't stay away


See User information
Use 1L << msgPort->mp_SigBit. I remember having problems years ago when I was doing 1 << msgPort->mp_SigBit instead of 1L << msgPort->mp_SigBit.

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Home away from home
Home away from home


See User information
@TSK

GCC uses 32bit as standard, but if you use any other other compiler it might not work whit out 'L' as you say, some compilers defaults to 16bit.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just can't stay away
Just can't stay away


See User information
@jaokim

Quote:

Looking at it, yes. Probably some left over from my testing. Also, I never delete the allocated MsgPort struct.


You shouldn't delete the MsgPort you get from application.library. UnregisterApplication() should take care of that for you.

Go to top
Re: Waiting for mp_SigBit from RegisterApplication
Just popping in
Just popping in


See User information
@salas00:
Nor should I do new. The autodoc gave me the impression that it should be a pointer to a MsgPort, when it really should be a pointer to a pointer. So I wound up trying lots of different things.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project