Mistake - can you find it?
jjames
Posts: 2,908
This was a stooooooopid mistake I made a few days ago and after thinking about what I did to maybe cause the issue - it made sense. Here's the symptoms of the problem: commands being sent out three times (i.e. one button press sent the same command three times.)
Here's the relevant code:
Here's the relevant code:
INTEGER nIR_MBR_COMMANDS[]= { 1 // Play , 2 // Stop , 3 // Pause , 4 // FFWD , 5 // RWD , 6 // Skip + , 7 // Skip - , 8 // Record , 9 // Power Toggle , 10 // 0 , 11 // 1 , 12 // 2 , 13 // 3 , 14 // 4 , 15 // 5 , 16 // 6 , 17 // 7 , 18 // 8 , 19 // 9 , 20 // 10+ , 21 // Enter , 22 // Ch + , 23 // Ch - , 00 // Discrete Power On , 00 // Discrete Power Off , 29 // , 30 // , 31 // , 32 // , 33 // , 34 // , 35 // , 36 // , 37 // , 38 // , 39 // , 40 // , 41 // , 42 // , 43 // , 44 // Menu , 45 // Up , 46 // Down , 47 // Left , 48 // Right , 49 // Select , 50 // Exit / Cancel / Clear , 51 // Info , 52 // Guide , 53 // , 54 // , 55 // Last / Jump , 56 // , 57 // , 58 // , 59 // , 60 // , 61 // , 62 // , 63 // , 64 // , 65 // , 66 // , 67 // , 68 // , 69 // , 70 // , 71 // , 72 // , 73 // , 74 // , 75 // , 76 // , 77 // , 78 // , 79 // , 80 // , 81 // , 82 // , 83 // , 84 // , 85 // , 86 // , 87 // , 88 // , 89 // , 90 // } DEFINE_EVENT BUTTON_EVENT[dvIR,nIR_MBR_COMMANDS] // Bedroom (1-100) { PUSH: { LOCAL_VAR INTEGER nPNL; LOCAL_VAR INTEGER nBTN STACK_VAR INTEGER iSRC; nPNL = 4 nBTN = BUTTON.INPUT.CHANNEL iSRC = nAV_ZONE_SOURCE[nZONE_MBR]; // MANAGE DEVICE CONTROL SWITCH(iSRC) { // SATELLITE COMMANDS CASE nSRC_SAT_ALT: { SELECT { ACTIVE(nBTN>=45 && nBTN<=48): // CONTINUOUS IR OUTPUT (up,down,left,right) TO[dvSAT_MGR,nBTN] // All other buttons ACTIVE(1): SEND_COMMAND dvSAT_MGR,"'SP',nBTN" } } // TIVO COMMANDS CASE nSRC_TIVO: SEND_COMMAND dvSAT_TIVO,"'SP',nBTN" // VCR COMMANDS CASE nSRC_VCR: SEND_COMMAND dvVCR,"'SP',nBTN" } } }
0
Comments
*dr. evil pinky finger thing*
Jeff
--John
I'm just trying to figure out the best format for such a thing. So far I think that the first correct response poster is responsible to come up with the new question for the next week. I am also thinking that only requests for clarification on the question (as long as such clarification isn't the answer) should be allowed on the first day. After the first 24 hrs is up, first correct post wins
The question does not have to be multiple choice. It could be something like: Write code necessary to toggle the state of a button with code 200 on dvPanelFB when button 3 is pushed on dvPanel, but it should only have one goal or lesson to be learned (ie no specing a system and having the forum write it for you )
This could be a fun way to keep the brain turning and I always find that helping others is a good way to reinforce personal knowledge. Plus, everyone likes a competition.
Anyone else think this is a good idea, or should I get a little more sleep?
Jeff
How about a special kind of thread where,
1. If you have not posted in the thread, you are only allowed to see the original post.
2. After you post you can see your post, and the posts of all others before you. Some kind of alert reminds you that by responding to the post you are submitting your final answer.
3. Editing posts in this type of thread would be forbidden.
Any requests for clarification should be made as PMs to the poster and the poster could edit the original post. After a while the poster could "close" the read, at which point anyone can view any post, but still no editing (except by the original poster).
Seems pretty implementable. What do you think, AMXforums admin dudes? Can we have it?
Looking in to it!
Only to everyone except you... seriously. It would work the same way for any of us making the same mistake, though, because we wouldn't be looking at that section expecting to see a bug, we would be looking at it thinking "of course it's zero, there's no mapping for that function". It's always easier to find someone else's bugs than it is to find your own. I think Murphy's Law comes into at some point -- the longer you stare at a piece of code, the more likely it is that someone looking over your shoulder will see the bug in 5 seconds.
Jeremy
Well, alright. I guess time is up. For those who didn't see the problem or couldn't quite pinpoint it - as someone else has said to me before: no wonder why in UI modules they use 9999 for unused buttons. The reason being is that 0 (zero) is what I call a "wildcard." Since there were two zeros in my array (power on & power off) those got activated as well. So - when a button was pressed, the event flow was like this.
Would anyone disagree with my reasoning or maybe someone has a better way of explaining it?
If you search through the forums for help with fixing errors, most of them are like that.
By the way, in addition to your 00 wildcard issue, you're also missing positions 26-28 after it in your array, but I assume that's probably from transferring the code to the post.
--John