Halt Notifier Plugin for the MPLAB® X IDE
Contents
Overview
The Halt Notifier plugin for MPLAB® X IDE (SW100200) provides the ability to be alerted when a target is halted. Notifications can be customized with actions, for example: issuing an audio alert, sending an email, or running a script.
This can be very useful when debugging your code. The plugin can let you know when the debugging has halted (for example, it has reached a breakpoint). It then notifies you so you can take action if needed.
Install and Launch the Halt Notifier Plugin
Open MPLAB X IDE and install the Halt Notifier plugin. For installation instructions, see Install plug-ins supplied by Microchip.
Once the plugin is installed, from the MPLAB X IDE menu bar select Tools > Embedded > Halt Notifier to launch the plugin.
The default is set to “Disable”. You can enable the halt notifications and select any combination of notification methods.
Add Halt Notifier Icon to Toolbar
By default, the Halt Notifier icon is not visible. The icon can be added to the toolbar in three ways:
Position the pointer over a movable object’s grabber or splitter () in the toolbar to change the pointer to . Right-click and select "HaltNotifier".
Select "Customize" from the bottom of the list of available toolbars - see (2) in Figure 1 - to open the Customize Toolbar dialog - see Figure 2. Locate the icon in the Tools folder labeled “Enable/Disable/Configure Notifications” and drag it to the toolbar.
Using any of the above methods, the Halt Notifier icon is added to the toolbar.
Enable, Disable, and Configure Notifications
Audio, email, and script notifications can be enabled or disabled through the toolbar icon or the Halt Notifier window. You can toggle the state between enable and disable by clicking the icon. Use the drop-down list to open the Halt Notifier window to configure notifications.
Enable Notifications
Disable Notifications
Configure Notifications
Customize Audio Notification
To configure audio settings, check Audio Notification in the Halt Notifier window and click Settings.
In the Audio Settings window, the default audio alert is the beep sound. You can change the alert to an audio file, browse for the file, and specify the duration in seconds. Click OK when done. When a breakpoint is encountered in MPLAB X IDE, an audio file is played.
Customize Email Notification
To configure email settings, check “Email Notification” in the Halt Notifier window and click Settings.
The Email Settings window opens.
- Email ID: In the “Email ID” fields for the Sender’s Address and Recipient’s Address, type the appropriate email addresses (for example, Gmail, Yahoo, Outlook, etc.). Multiple recipients’ addresses can be entered by separating them with a comma (,).
- Password: Type your email account password in the “Password” field.
- Port: SMTP servers normally use port 25, but there are other options. For example, port 587 is supported by most outgoing SMTP servers and it is useful for unencrypted or TLS connections. Port 465 is good for connecting via SSL.
- Authentication: Check if authentication is required.
- Connection Security: The standard SMTP email transfer goes without encryption. To secure it, use STARTTLS or SSL/TLS.
- SMTP Server: In this field, select or type the name of your email server or one provided by your Internet Service Provider. The following are the most popular server names. If yours is not listed, contact your email provider.
Provider | URL | SMTP |
---|---|---|
1&1 | 1and1.com | smtp.1and1.com |
airmail | airmail.net | mail.airmail.net |
aol | aol.com | smtp.aol.com |
at&t | att.net | outbound.att.net |
bluewin | bluewin.ch | smtpauths.bluewin.ch |
bt connect | btconnect.com | mail.btconnect.tom |
comcast | comcast.net | smtp.comcast.net |
earthlink | earthlink.net | smtpauth.earthlink.net |
gmail | gmail.com | smtp.gmail.com |
gmx | gmx.net | mail.gmx.net |
hotpop | hotpop.com | mail.hotpop.com |
libero | libero.it | mail.libero.it |
lycos | lycos.com | smtp.lycos.com |
o2 | o2.com | smtp.o2.com |
orange | orange.net | smtp.orange.net |
outlook.com (formerly hotmail) | outlook.com | smtp.live.com |
tin | tin.it | mail.tin.it |
tiscali | tiscali.co.uk | smtp.tiscali.co.uk |
verizon | verizon.net | outgoing.verizon.net |
virgin | virgin.net | smtp.virgin.net |
wanadoo | wanadoo.fr | smtp.wanadoo.fr |
yahoo | yahoo.com | mail.yahoo.com |
Click OK when done.
When a breakpoint is encountered in MPLABX IDE, an email is sent to the recipient’s address. The email contains information about the Project name, Project directory, Debug directory, and the reason for the halt.
Customize Script Notification
To configure the script settings select “Script Notification” in the Halt Notifier window and click Settings.
In the Script Settings window, you select the script file you want to execute when a halt occurs. The window also shows a list of default scripting languages that are supported. You can add or remove any scripting language or reset the list to the default scripting languages.
Select a Script File
To use Script Notification, you must select a script file in the Script Settings window.
To choose a script file,
click Browse.
The script file language should be within the list of scripting languages in the Script Settings window. If it does not match, add the scripting language (see Add a Scripting Language) to the list and then select the script file.
When MPLAB X IDE encounters a breakpoint, the selected script is executed and the output of the script file, if any, will be directed to the MPLAB X IDE output window. The Project name, Project directory, Debug directory, and reason for halt information will be passed as an argument along with the script (see example below).
A script can contain whatever actions you want to take place when a halt occurs. One example is sending a text message. See the next two topics on how to send a text message using WhatsApp and Twitter.
Example: Python script to send a text message via Verizon
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
python textmsg.py "project_name,project_dir,debug_dir,halt_reason"
"""
import smtplib
import sys
username = "account@gmail.com"
password = "password"
vtext = "1112223333@vtext.com"
my_string = sys.argv[1]
my_list = my_string.split(",")
for i in range(len(my_list)):
str1 = my_list[0]
str2 = my_list[1]
str3 = my_list[2]
str4 = my_list[3]
message = {"Project " + str1
+ "\nProject Directory " + str2
+ "\nDebug Directory " + str3
+ "\nHalt Reason " + str4}
msg = """From %s
To: %s
Subject: text-message
%s""" % (username, vtext, message)
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls
server.login(username,password)
server.sendmail(username,vtext,msg)
server.quit()
Send a Text Message Using Yowsup and WhatsApp Messenger
Yowsup is a Python library that lets you use the WhatsApp service. It allows you to log in and provides you with all the capabilities of an official Whatsapp client. You can create a full-fledged custom Whatsapp client.
Send a Text Message Using Twitter
There are several Twitter APIs available for sending messages. All of Twitter’s APIs are based on the HTTP protocol. Any software you write that uses Twitter’s APIs sends a series of structured messages to Twitter’s servers.
There are many scripting languages supported by Twitter and can be seen in Twitter Tools and Libraries.
Add a Scripting Language
To add a scripting language, click Add. A new row is created within the list.
Double-click in each empty field (do not use the <TAB> key) and type in the appropriate Display Name, Executable, and Extension. When done, press the <ENTER> key. Then, you can select a script file.
Delete a Scripting Language
To delete a scripting language from the list, click anywhere in the row to be deleted and click Delete. See Figure 5. Default scripting languages cannot be deleted.
Reset the Language List
To return the scripting language list to the default settings,
click Reset.
Close the Halt Notifier Window
When you are finished configuring the settings (see Enable, Disable, and Configure Notifications)
Click OK to close the Halt Notifier Settings window.
You can enable/disable or configure notifications via the toolbar icon (see Add Halt Notifier Icon to Toolbar).