# How to specify custom script when event (none/falling/rising/change) happens
Note: The event is only available in input direction.

Method A (New design and only works after MIL 3.4, recommended):
1. Add hook.
   The hook file cannot be located under /etc/moxa/MoxaComputerInterfaceManager/dio-scripts/
  - Use `mx-interface-mgmt dio add_hook <hook_name> <hook_path>`

2. Set hook and bind with a DI:
  - Use `mx-interface-mgmt dio <dio_name> set_hook <hook_name>`

3. Change the target event by (Can only set one event at a time)
  - Use `mx-inteface-mgmt dio <dio_name> set_event <event>`

Method B (Works for all version):
1. Create the script with the format: <dio_name>.script
   e.g. DI1.script

2. Change the target event by (Can only set one event at a time)
  - Method 1. Modify in /etc/moxa/MoxaComputerInterfaceManager/peripheral-settings.conf ([DIO/DIx])

    - Event=0: none (default)
    - Event=1: falling edge
    - Event=2: rising edge
    - Event=3: change

  - Method 2. Use `mx-inteface-mgmt dio <dio_name> set_event <event>`

3. Remember to make script executable (e.g. chmod +x DI1.script)

4. Any modification will be triggered after restarting the service or use
  `mx-interface-mgmt dio <dio_name> reload` to reload the configuration.
