Home AMX User Forum NetLinx Modules & Duet Modules

DATA_EVENT issues

I cannot figure this out:

Everything works, but I cannot explain the Notification Messages.

At no time am I sending these Module Commands to RS232 Port 5.
The 3 Duet Device DATA_EVENT's that follow my initialization of RS232 Port 5 seem to have been added to the ONLINE portion for RS232 Port 5.... ARGH!

Does anyone know what is happening here?
Is it possible that Netlinx is mixed up with the Notification Messages?

On Boot - from Notifications:

(15:22:38):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
(15:22:39):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
(15:22:39):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
(15:22:39):: Command To [5001:5:1]-[PASSBACK-0]
(15:22:39):: Command To [5001:5:1]-[REINIT]
(15:22:39):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
(15:22:39):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
(15:22:39):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
(15:22:39):: Command To [5001:5:1]-[PASSBACK-0]
(15:22:39):: Command To [5001:5:1]-[REINIT]
(15:22:40):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
(15:22:40):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
(15:22:40):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
(15:22:40):: Command To [5001:5:1]-[PASSBACK-0]
(15:22:40):: Command To [5001:5:1]-[REINIT]
(15:22:49):: Command To [5001:5:1]-[?INPUTPROPERTIES]
(15:22:49):: Command To [5001:5:1]-[?INPUTPROPERTIES]
(15:22:50):: Command To [5001:5:1]-[?INPUTPROPERTIES]

Code from Data event for 5001:5:1

DEFINE_EVENT
DATA_EVENT[dv0RS232_5]
{
ONLINE:
{
SendCommand(Data.Device, 'SET BAUD 9600,N,8,1, 485 DISABLE');
SendCommand(Data.Device, 'HSOFF');
SendCommand(Data.Device, 'XOFF');
SendCommand(Data.Device, 'RXON');
}
STRING:
{
TAVSwitch_Parse(SWITCH_AP_PRECIS_44, dv0RS232_5_Buf);
}
}

Code following the above Event:

DEFINE_EVENT
DATA_EVENT[vDuetDevice1]
{
ONLINE:
{
Wait 100
{
SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
SendCommand(Data.Device, 'PASSBACK-0');
SendCommand(Data.Device, 'REINIT');
Wait 300
{
SendCommand(Data.Device, '?INPUTPROPERTIES');
}
}
}
STRING:
{
TDisplay_ModuleParse(Data.Device, Data.Text);
}
}
STRING:
{
DebugDeviceData(Data.Device, Data.Text);
}
}
DEFINE_EVENT
DATA_EVENT[vDuetDevice2]
{
ONLINE:
{
Wait 100
{
SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
SendCommand(Data.Device, 'PASSBACK-0');
SendCommand(Data.Device, 'REINIT');
Wait 300
{
SendCommand(Data.Device, '?INPUTPROPERTIES');
}
}
}
STRING:
{
TDisplay_ModuleParse(Data.Device, Data.Text);
}
}
DEFINE_EVENT
DATA_EVENT[vDuetDevice3]
{
ONLINE:
{
Wait 100
{
SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
SendCommand(Data.Device, 'PASSBACK-0');
SendCommand(Data.Device, 'REINIT');
Wait 300
{
SendCommand(Data.Device, '?INPUTPROPERTIES');
}
}
}
STRING:
{
TDisplay_ModuleParse(Data.Device, Data.Text);
}
}

Comments

  • If you enclose your code in {code} tags, your formatting will keep.

    Did you write your own function for SendCommand? If so, may I ask why? The native send_command is more than adequate in my opinion.

    On to the issue. I think it is the waits that are causing the issue. I am willing to bet that by the time the Duet devices come online and the waits trigger, data.device is set to 5001:5:1 due to you receiving strings or other things going on in the system. Data.device is not unique to the data_event where it is called. It holds the information for the last data event that got triggered, not necessarily the one where it is being called from. One way to fix this is to create your own local variable and set it to equal data.device when the event is triggered, then use that local variable inside the wait. That should eliminate the problem.

    Hope that helps.
  • DOH!
    I know I should never use WAITs and especially Netlinx System Vars in a WAIT...

    Thanks for the insight.

    I wrote a SendCommand(...), SendString(...) and SendLevel(...) for debugging.
    They each call their respective Netlinx Functions.

    I can turn the debugging Off in one place, rather than having numerous SEND_STRING 0, '..';
    I don't really need it, as I have been using Notifications more, now that I have been using Netlinx for awhile.

    It is more habit to use the functions I have defined as apposed to their Netlinx equivalent.
  • ericmedleyericmedley Posts: 4,177
    ** fixed your post. **

    Those commands are probably being sent by the Duet module itself. Generally speaking all .comm modules usually do the handling of setting up their respective communications ports and you don't need to do it yourself.

    I cannot figure this out:

    Everything works, but I cannot explain the Notification Messages.

    At no time am I sending these Module Commands to RS232 Port 5.
    The 3 Duet Device DATA_EVENT's that follow my initialization of RS232 Port 5 seem to have been added to the ONLINE portion for RS232 Port 5.... ARGH!

    Does anyone know what is happening here?
    Is it possible that Netlinx is mixed up with the Notification Messages?

    On Boot - from Notifications:

    (15:22:38):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
    (15:22:39):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
    (15:22:39):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
    (15:22:39):: Command To [5001:5:1]-[PASSBACK-0]
    (15:22:39):: Command To [5001:5:1]-[REINIT]
    (15:22:39):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
    (15:22:39):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
    (15:22:39):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
    (15:22:39):: Command To [5001:5:1]-[PASSBACK-0]
    (15:22:39):: Command To [5001:5:1]-[REINIT]
    (15:22:40):: Command To [5001:5:1]-[PROPERTY-Baud_Rate,9600]
    (15:22:40):: Command To [5001:5:1]-[PROPERTY-Device_ID,0]
    (15:22:40):: Command To [5001:5:1]-[PROPERTY-Poll_Time,10000]
    (15:22:40):: Command To [5001:5:1]-[PASSBACK-0]
    (15:22:40):: Command To [5001:5:1]-[REINIT]
    (15:22:49):: Command To [5001:5:1]-[?INPUTPROPERTIES]
    (15:22:49):: Command To [5001:5:1]-[?INPUTPROPERTIES]
    (15:22:50):: Command To [5001:5:1]-[?INPUTPROPERTIES]

    Code from Data event for 5001:5:1
    DEFINE_EVENT
    DATA_EVENT[dv0RS232_5]
    {
    	ONLINE:
    	{
    		SendCommand(Data.Device, 'SET BAUD 9600,N,8,1, 485 DISABLE');
    		SendCommand(Data.Device, 'HSOFF');
    		SendCommand(Data.Device, 'XOFF');
    		SendCommand(Data.Device, 'RXON');
    	}
    	STRING:
    	{
    		TAVSwitch_Parse(SWITCH_AP_PRECIS_44, dv0RS232_5_Buf);
    	}
    }
    
    Code following the above Event:
    
    DEFINE_EVENT
    DATA_EVENT[vDuetDevice1]
    {
    	ONLINE:
    	{
    		Wait 100
    		{
    			SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
    			SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
    			SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
    			SendCommand(Data.Device, 'PASSBACK-0');
    			SendCommand(Data.Device, 'REINIT');
    			Wait 300
    			{
    				SendCommand(Data.Device, '?INPUTPROPERTIES');
    			}
    		}
    	}
    	STRING:
    	{
    		TDisplay_ModuleParse(Data.Device, Data.Text);
    	}
    	}
    	STRING:
    	{
    		DebugDeviceData(Data.Device, Data.Text);
    	}
    }
    DEFINE_EVENT
    DATA_EVENT[vDuetDevice2]
    {
    	ONLINE:
    	{
    		Wait 100
    		{
    			SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
    			SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
    			SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
    			SendCommand(Data.Device, 'PASSBACK-0');
    			SendCommand(Data.Device, 'REINIT');
    			Wait 300
    			{
    				SendCommand(Data.Device, '?INPUTPROPERTIES');
    			}
    		}
    	}
    	STRING:
    	{
    		TDisplay_ModuleParse(Data.Device, Data.Text);
    	}
    }
    DEFINE_EVENT
    DATA_EVENT[vDuetDevice3]
    {
    	ONLINE:
    	{
    		Wait 100
    		{
    			SendCommand(Data.Device, 'PROPERTY-Baud_Rate,9600');
    			SendCommand(Data.Device, 'PROPERTY-Device_ID,0');
    			SendCommand(Data.Device, 'PROPERTY-Poll_Time,10000');
    			SendCommand(Data.Device, 'PASSBACK-0');
    			SendCommand(Data.Device, 'REINIT');
    			Wait 300
    			{
    				SendCommand(Data.Device, '?INPUTPROPERTIES');
    			}
    		}
    	}
    	STRING:
    	{
    		TDisplay_ModuleParse(Data.Device, Data.Text);
    	}
    }
    
  • DOH!
    I know I should never use WAITs and especially Netlinx System Vars in a WAIT...

    Thanks for the insight.

    I wrote a SendCommand(...), SendString(...) and SendLevel(...) for debugging.
    They each call their respective Netlinx Functions.

    I can turn the debugging Off in one place, rather than having numerous SEND_STRING 0, '..';
    I don't really need it, as I have been using Notifications more, now that I have been using Netlinx for awhile.

    It is more habit to use the functions I have defined as apposed to their Netlinx equivalent.
    Gotcha. I was more curious than anything, as that could possibly cause issues itself.
  • Thanks Eric, I will keep that in mind.
    Just out of habit I make sure the controller/modules are set the way I have the hardware set.

    Andrew, I have a global PERSISTENT Var to turn ON/Off Debugging messages with a Virtual Device for the Controller; that way I do not have to recompile the code to turn On/Off Debugging.

    Has not caused issues thus far.

    Thank you both for your insight.
  • viningvining Posts: 4,368
    I use a unique debug var for every device module/include just so I can turn on send_string 0 for the specific code I want to debug. I also use my own send_command, string functions for normal system operation so I can regulate control and feedback but that's basically geared towards UI's not Dev's. By running these through my function I can determine if the command should go to all active "on devpage" UI's or just a single UI that may have just gone "on page". It also allows me to screen dev ids so I can control feedback type. Don't need strings to keypads, etc and I don't want separate functions for each UI type.
  • Vining, that is an even better idea.

    I may just have to incorporate that with an array:

    DEFINE_CONSTANT
    Integer SYSTEM_INCLUDE_COUNT = 10;

    DEFINE_VARIABLE
    PERSISTENT Integer DEBUG_MSG_FLAGS[SYSTEM_INCLUDE_COUNT];

    Then I can just use Control a Device and set the Debug Flag for the Include I want to examine.

    Send Command to
    33001:1:1 "'DEBUG_MSG_FLAGS,<Index>,1'" for ON
    and
    33001:1:1 "'DEBUG_MSG_FLAGS,<Index>,0'" for OFF

    Excellent Idea!

    I have not done any tests to check memory use for Virtual Devices, but do you know if I set aside
    i.e.
    34001:1:0 to use for NI Controller Device Comm,
    if this will require more memory than if I just used Virtual Devices sequentially?
    i.e.
    33001:1:0 for the controller
    33002:1:0 for some other device
    33003:1:0 for some other device
    etc...

    Do you know
  • GregGGregG Posts: 251
    IIRC, regular virtuals take up the same amount of resources regardless of the actual number.

    I think the duet virtuals may take more, but then that might just be the extra system overhead for duet in general.

    One odd thing I seem to recall from a long time ago is that you can't create a virtual device with a port out of order, ie:
    vdvVirt2  = 33001:2:0
    
    didn't actually create a usable virtual device, but:
    vdvVirt1 = 33001:1:0
    vdvVirt2 = 33001:2:0
    
    worked fine.
  • Thanks GregG, that is good to know.

    I just un comment a section of code, as needed, in my Include File:
    Current Project:

    "SYS_Devices.axi"
    //Duet Virtual
    vDuetDevice1 = 41001:1:0;
    //vDuetDevice1_2 = 41001:2:0;
    //vDuetDevice1_3 = 41001:3:0;
    //vDuetDevice1_4 = 41001:4:0;
    //vDuetDevice1_5 = 41001:5:0;
    vDuetDevice2 = 41002:1:0;
    //vDuetDevice2_2 = 41002:2:0;
    //vDuetDevice2_3 = 41002:3:0;
    //vDuetDevice2_4 = 41002:4:0;
    //vDuetDevice2_5 = 41002:5:0;
    //vDuetDevice2_6 = 41002:6:0;
    //vDuetDevice2_7 = 41002:7:0;
    //vDuetDevice2_8 = 41002:8:0;
    vDuetDevice3 = 41003:1:0;
    //vDuetDevice3_2 = 41003:2:0;
    //vDuetDevice3_3 = 41003:3:0;
    //vDuetDevice3_4 = 41003:4:0;
    //vDuetDevice3_5 = 41003:5:0;
    //vDuetDevice3_6 = 41003:6:0;
    //vDuetDevice3_7 = 41003:7:0;
    //vDuetDevice3_8 = 41003:8:0;
    vDuetDevice4 = 41004:1:0;
    //vDuetDevice4_2 = 41004:2:0;
    //vDuetDevice4_3 = 41004:3:0;
    //vDuetDevice4_4 = 41004:4:0;
    //vDuetDevice4_5 = 41004:5:0;
    //vDuetDevice4_6 = 41004:6:0;
    vDuetDevice5 = 41005:1:0;
    //vDuetDevice5_2 = 41005:2:0;
    //vDuetDevice5_3 = 41005:3:0;
    //vDuetDevice5_4 = 41005:4:0;
    //vDuetDevice5_5 = 41005:5:0;
    vDuetDevice6 = 41006:1:0;
    //vDuetDevice6_2 = 41006:2:0;
    //vDuetDevice6_3 = 41006:3:0;
    //vDuetDevice6_4 = 41006:4:0;
    //vDuetDevice6_5 = 41006:5:0;
    vDuetDevice7 = 41007:1:0;
    //vDuetDevice7_2 = 41007:2:0;
    //vDuetDevice7_3 = 41007:3:0;
    //vDuetDevice7_4 = 41007:4:0;
    //vDuetDevice7_5 = 41007:5:0;
    vDuetDevice8 = 41008:1:0;
    //vDuetDevice8_2 = 41008:2:0;
    //vDuetDevice8_3 = 41008:3:0;
    //vDuetDevice8_4 = 41008:4:0;
    //vDuetDevice8_5 = 41008:5:0;
    vDuetDevice9 = 41009:1:0;
    //vDuetDevice9_2 = 41009:2:0;
    //vDuetDevice9_3 = 41009:3:0;
    //vDuetDevice9_4 = 41009:4:0;
    //vDuetDevice9_5 = 41009:5:0;
    vDuetDevice10 = 41010:1:0;
    vDuetDevice10_2 = 41010:2:0;
    vDuetDevice10_3 = 41010:3:0;
    vDuetDevice10_4 = 41010:4:0;
    vDuetDevice10_5 = 41010:5:0;
    vDuetDevice10_6 = 41010:6:0;
    vDuetDevice10_7 = 41010:7:0;
    vDuetDevice10_8 = 41010:8:0;
    vDuetDevice10_9 = 41010:9:0;
    vDuetDevice10_10 = 41010:10:0;
    vDuetDevice10_11 = 41010:11:0;
    vDuetDevice10_12 = 41010:12:0;
    vDuetDevice10_13 = 41010:13:0;
    vDuetDevice11 = 41011:1:0;
    vDuetDevice11_2 = 41011:2:0;
    vDuetDevice11_3 = 41011:3:0;
    vDuetDevice11_4 = 41011:4:0;
    vDuetDevice11_5 = 41011:5:0;
    vDuetDevice11_6 = 41011:6:0;
    vDuetDevice11_7 = 41011:7:0;

    //Virtual
    vDevice1 = 33001:1:0;//Master Comm
    //vDevice2 = 33002:1:0;
    //vDevice2_2 = 33002:2:0;
    //vDevice2_3 = 33002:3:0;
    //vDevice2_4 = 33002:4:0;
    //vDevice2_5 = 33002:5:0;
    //vDevice3 = 33003:1:0;
    //vDevice3_2 = 33003:2:0;
    //vDevice3_3 = 33003:3:0;
    //vDevice3_4 = 33003:4:0;
    //vDevice3_5 = 33003:5:0;
    //vDevice4 = 33004:1:0;
    //vDevice4_2 = 33004:2:0;
    //vDevice4_3 = 33004:3:0;
    //vDevice4_4 = 33004:4:0;
    //vDevice4_5 = 33004:5:0;
    //vDevice5 = 33005:1:0;
    //vDevice5_2 = 33005:2:0;
    //vDevice5_3 = 33005:3:0;
    //vDevice5_4 = 33005:4:0;
    //vDevice5_5 = 33005:5:0;
Sign In or Register to comment.