I am trying to send a set of CAN frames on to CAN bus. I am using CAPL to program and CANalyzer8.5 to simulate and Panel designer to create a button. My requirement is to first create a button using PANEL designer. Only on button press it should start sending periodic CAN frames on to the bus. I am a bit confused as to how to achieve it. So far I have managed to write two separate programs using CAPL. First program sends data at start periodically. Second code sends data only once when the button is pressed. I want to merge both the codes to start sending periodically on button press.
first code
/*@!Encoding:1252*/
includes
{
}
variables
{
msTimer mytimer;
message 0x100 A={dlc=8};
message 0x200 B={dlc=8};
message 0x300 C={dlc=8};
message 0x400 D={dlc=8};
}
on start
{
setTimer(mytimer,50);
}
on timer mytimer
{
A.byte(0)=0x64;
B.byte(4)=0x32;
C.byte(6)=0x20;
D.byte(7)=0x80;
output(A);
output(B);
output(C);
output(D);
setTimer(mytimer,50);
}
Second Code
/*@!Encoding:1252*/
includes
{
}
variables
{
message 0x100 A={dlc=8};
message 0x200 B={dlc=8};
message 0x300 C={dlc=8};
message 0x400 D={dlc=8};
}
on sysvar test::myButton
{
A.byte(0)=0x64;
B.byte(4)=0x32;
C.byte(6)=0x20;
D.byte(7)=0x80;
output(A);
output(B);
output(C);
output(D);
}
So as mentioned, when i press the button, it should start sending the CAN frames periodically. But the problem is,i cannot call a function within function as below:
on start
{
on sysvar test::myButton
{
....
}
}
please advice me. thank you