Home AMX User Forum NetLinx Studio
Options

Button Event not being picked up by dev array

DEFINE_DEVICE
dvtp1_core = 10001:1:0
dvtp2_core = 10002:1:0
debug_port = 33001:1:0

DEFINE_CONSTANT
btnset_tab = {1,2,3}

DEFINE_VARIABLE
dvtp_core[] = { dvtp1_core,dvtp2_core }

DEFINE_EVENT
button_event[dvtp_core,btnset_tab] { //Tabs
   push: { 
      send_string debug_port,"'Panel Tab # ',itoa(button.input.device.number),' Pushed!"
   }
}

I have nearly identical code running successfully on several controllers in several installations, and suddenly, with this latest project, the button event is not getting picked up. I get no message to the debug port.

If I change the DEV array in the button event to a single device, it will pick up the button push on that device. But the moment I use a device array, the button event goes dead.

I'm missing something, but I can't figure it out. Any ideas out there?

Thanks!

Comments

  • Options
    PhreaKPhreaK Posts: 966
    The only issue I can see with that code is that
    DEFINE_VARIABLE
    dvtp_core[] = { dvtp1_core,dvtp2_core }
    
    Should be:
    DEFINE_VARIABLE
    DEV dvtp_core[] = { dvtp1_core,dvtp2_core }
    
  • Options
    viningvining Posts: 4,368
    With out the "DEV" you created an integer array.
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    In case this is not the actual code, there is also a limit to the number of items that can be tied into the same event. I am sure a search will turn up the actual number, but I think it is around 1024. For instance:
    define_constant
    integer nButtons[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
    define_variable
    dev dvTps[] = {dvTp1, dvTp2, ... dvTp100}
    
    define_event
    button_event[dvTps,nButtons]{
        push:{
         //do something
       }
    }
    

    This will appear to work fine as long as you are pushing a button that made it into the event table, but if you try pushing button 20 on dvTp100, nothing will happen. I don't recall if it cuts off the Tps, or the higher button numbers, but it definitely cuts off.

    There is an easy way to solve this tho:
    define_variable
    dev dvTps[] = {dvTp1, dvTp2, ... dvTp100}
    
    define_event
    button_event[dvTps,1]
    button_event[dvTps,2]
    button_event[dvTps,3]
    button_event[dvTps,4]
    button_event[dvTps,5]
    button_event[dvTps,6]
    button_event[dvTps,7]
    button_event[dvTps,8]
    button_event[dvTps,9]
    button_event[dvTps,10]
    button_event[dvTps,11]
    button_event[dvTps,12]
    button_event[dvTps,13]
    button_event[dvTps,14]
    button_event[dvTps,15]
    button_event[dvTps,16]
    button_event[dvTps,17]
    button_event[dvTps,18]
    button_event[dvTps,19]
    button_event[dvTps,20]
    {
        push:{
         //do something
       }
    }
    


    This will work just fine as each table has 100 elements (Not sure of the nomenclature, but hopefully you get the idea).

    Jeff
  • Options
    viningvining Posts: 4,368
    The number of event triggers in the event table when defined the way Jeff showed is 4000 so in that example everything would work w/o a cut off. If you had 50 buttons in the array x 100 TPs (5000 possible event triggers) then the cut off for all TPs would be button 41. Button 40 would work.

    If you use button_event[dvTps,0] you effecively have only 1 event trigger as far has system resources are concerned but you can push buttons up to 65535. You also no longer have hold issues when using the catch all "0".

    http://amxforums.com/showthread.php?t=5943&highlight=event+table
  • Options
    Thanks everyone for the suggestions and info!

    The DEV typing is there in my code, that was just a copy/paste into the browser form mistake.

    I've always got 3 buttons, and every other project has just 2 panels; this one has 3 panels. Hardly anything that should run up against any limits.

    This project is the only one I've got so far that uses the same DEV in more than one DEV array. I ran into this once before now that I think about it, and I did solve it by just stacking button events with a single dev per button event. I'm going to poke around just a bit to see if I can figure this out before I drop back to the stacked button events.
  • Options
    Hmmm.... something far more drastic is wrong. My controller isn't even running DEFINE_START. It's not catching DATA_EVENTs. It's not catching any BUTTON_EVENTs. It almost acts like the Program Run is disabled, but the PRD mode switch is off. Dang...

    Any more ideas out there?
  • Options
    ericmedleyericmedley Posts: 4,177
    Hmmm.... something far more drastic is wrong. My controller isn't even running DEFINE_START. It's not catching DATA_EVENTs. It's not catching any BUTTON_EVENTs. It almost acts like the Program Run is disabled, but the PRD mode switch is off. Dang...

    Any more ideas out there?


    I've had things like this happen a couple times before and it turned out to be the starngest thing. I accidentally typed in some keyword in an unintended place. It would compile without errors but the program was totally jacked.

    In one case I was finding that any variables made non-volatile or persistent were not working. So, any code for things that had persistent variables (like volume or station presets) would compile but not work. You'd never see the button event fire.

    I don't even remember what the heck keyword I typed but it was something up in the top of the file. Sometimies, I'll pop open NS to quickly type in a keyword and hit F1 to check out what it does. I think I did this, got distracted, and forgot to clear it out afterward.

    How I found it was also mind-bogglingly annoying. I basically commented out all the code and complied, uploaded, checked for happiness, then uncommented another section, repieat, repeat, repeat...

    It literally took a whole day of this. But, I eventually did find it.

    If it is this kind of thing, it'll be hard to find since it is obviously compiling. So, it won't be as simple as double-clicking the error notice in the window.
  • Options
    I'm sure you're right, Eric. I'm working on gutting code now. Dang...
  • Options
    FIXED!

    I had made some changes to one of my structures, adding storage for more info, and I think I must have overloaded the memory. In one place in the structure, I had given a character size of 20,000 instead of 2,000. Reducing the size of the CHAR definitions in the structure fixed the problem.

    Thanks everyone!
  • Options
    ericmedleyericmedley Posts: 4,177
    I had made some changes to one of my structures, adding storage for more info, and I think I must have overloaded the memory. In one place in the structure, I had given a character size of 20,000 instead of 2,000. Reducing the size of the CHAR definitions in the structure fixed the problem.

    Thanks everyone!

    Happy Day!
  • Options
    DHawthorneDHawthorne Posts: 4,584
    I would truly love a compiler switch to set the intended target processor type, and then check memory needs and throw a warning if your compiled code is too big. I've done similar things before ... and even had code that ran perfectly well, but couldn't be updated because there wasn't enough memory for the upload.
  • Options
    memory

    Can you change the flash memory in cases like that?
  • Options
    viningvining Posts: 4,368
    Sure, increasing your flash to a larger card would be the proper thing to do.

    You could also (probably) run a clean disc to clear the running program so that there would be enough space for the new program. Since you have to have enough free space for the current running program and the new program to be installed at the same time until the final checksums on the new program are validated and then the new program loaded. Clearing the disc to minimize the current program should free up enough space to allow the new program to load. Unless of course you made some seriously large modification.
Sign In or Register to comment.