On Target Debugging
Version 1.70 of the ZeroBrane IDE is included within the NovAtel API under the zerobrane folder. This version has been customized for use with NovAtel receivers. However, the stock version can be downloaded here: studio.zerobrane.com/support.
Prerequisites
Here are the prerequisites to enable NovAtel receiver on-target Lua debugging:
-
An OEM7 receiver running firmware 7.05.00 or later.
-
A firmware model supporting the user application.
-
An Ethernet connection from a host PC to the receiver.
-
The script to debug must be available on both the PC and the OEM7 receiver.
Note that the mobdebug.lua script, which is used by ZeroBrane for remote debugging, is preloaded into the Lua interpreter and does not need to be added to the Lua script package that is loaded onto the receiver.
PC and Receiver Setup
-
Download and install the ZeroBrane IDE to a PC.
-
Run ZeroBrane IDE (zbstudio.exe). The IDE will open up to a default Project containing some examples.
-
Switch to the Lua 5.3 - NovAtel interpreter, which is the version running on the OEM7. To do this, select Project | Lua Interpreter | Lua 5.3 - NovAtel.
-
The Local console tab at the bottom can be used to experiment with the Lua syntax.
Example:
Welcome to the interactive Lua interpreter. Enter Lua code and press Enter to run it. Use Shift-Enter for multiline code.
Use 'clear' to clear the shell output and the history. Use 'reset' to clear the environment.
Prepend '=' to show complex values on multiple lines. Prepend '!' to force local execution.
MyVar = 123
MyOtherVar = 456
print(MyVar+MyOtherVar)
579
-
On the OEM7 receiver, configure the network using the ETHCONFIG command and IPCONFIG command, and verify that a connection is possible. For example, use a terminal program to connect to an ICOM port and request a VERSION log. For details on how to set this up see Ethernet Configuration
-
On the PC where the ZeroBrane IDE is running, set the location where the scripts that were loaded onto the receiver can be found. To do this select Project | Project Directory | Choose and select the folder. The contents of the selected folder will be packaged and loaded onto the receiver, later in step 9. This example uses the simple debugloop.lua script shown here:\
DebugHostIP = arg[1]
LoopCount = 0
require('mobdebug').start(DebugHostIP)
while 1 do
print(LoopCount)
socket.sleep(1)
LoopCount = LoopCount + 1
end
-
Place a break-point in the script by clicking to the left of the code line as shown below:
-
Turn on the ZeroBrane debug server. To do this ensure that Project | Start Debug Server is checked.
-
Create a Lua script package from the project directory and load it onto the receiver using the steps described in Loading and Running the Application.
-
The OEM7 receiver should now have the same Lua script available to it as the ZeroBrane IDE does. Verify this using the LUAFILESYSTEMSTATUS log and LUAFILELIST log.
log luafilesystemstatus onchanged
<OK
[COM1]<LUAFILESYSTEMSTATUS COM1 0 91.0 UNKNOWN 0 0.343 02444020 b8f8 14581
< MOUNTED ""
log luafilelist
<OK
[COM1]<LUAFILELIST COM1 0 89.0 UNKNOWN 0 54.000 02444020 b447 14581
< 176 20180122 141649 "/lua/debugloop.lua"
[COM1]
-
Start the Lua script, passing the IP address of the PC running ZeroBrane, as the argument. The Lua interpreter will reach out to the debugger running on the host PC to establish the debugging connection.
lua prompt "debugloop.lua 198.161.68.53"
<OK
[COM1]Lua 5.3.4 Copyright (C) 1994-2017Lua.org, PUC-Rio
0
1
2
3
4
5
The ZeroBrane IDE will then be able to control the Lua interpreter on the receiver:
-
Use the debugging controls within the IDE to step through the code and set break points.