3 callback (interrupt) functions – ElmoMC Multi-Axis Motion Controller-Maestro User Manual
Page 96

sync_coun
t
SYNC messages. Default value 50.
message
int msgID,
int data1,
int data2
int
Posts messages from the Maestro to the
host computer. The user chooses the
message ID according to logic of the
application. Function returns 0 if the
message was not accepted by even one
listener. Otherwise returned value is equal
to 1.
messagex
int msgID,
int data1,
int data2
int
Posts message from the Maestro to host
computer (as in the previous case). But
the message in this case includes
automatically obtained CAN bus time in
microseconds.
systime
- int Returns system defined time in
milliseconds.
systimex
- int Returns CAN bus time in microseconds.
5.6.3
Callback (interrupt) Functions
MAXL supports a callback function mechanism. The callback function is called, by the
system, when a specific event occurs.
Below is an sample callback definition:
function @callback-name ( argument-list )
function-body
end function
MAXL supports the following callback functions (note: the functions begin with an
"@"):
• @perror(int error_number) – called when a runtime error occurs
error_number contains error code.
When a runtime error occurs the MAXL program status is set to ABORT.
If the @perror callback function was declared, the function will be called
first and program finished with a HALT status. Use the restart keyword in
@perror callback function to restart program. Without the callback
function, the program would stop immediately upon reaching a runtime
error.
• @emcy(int busID, int nodeID, int first4bytes, int second4bytes) – called
when the CANopen EMERGENCY message appears on the bus.
o
BusID – CAN bus identifier [0,1].
o
NodeID – CAN node identifier [1,127].
o
First4bytes – first 4 bytes CAN message data.
o
Second4bytes – last 4 bytes CAN message data.
Maestro
Software Manual
MAXL Program Language
MAN-MASSW (Ver. Q)
5-34