Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

NavigationSections in this page:

Table of Contents
maxLevel1

Introduction

In this document we shall provide a basic overview of how to develop C# .NET applications for ATM on a Windows development machine. The following areas will be covered:

  • Configuring the development environment

  • Writing a demo console application

  • Deploying to ATM

  • Debugging

Prerequisites

You will need to download and install the following applications:

  • Xamarin Studio for Windows. This is called MonoDevelop on Linux and to alleviate any incompatibility issues, please download the Windows version from:

  • We will need the Putty SSH tools for automating some remote tasks such as copying files and running the remote debugger

Installing and Configuring the Tools

Run the installer to install Xamarin. Once this is done you need to configure the environment to support remote debugging so you can debug applications running on your ATM device. This is simply a matter of setting the variable MONODEVELOP_SDB_TEST to 1.

  • Right click on the Start Menu and select 'System'

  • Click on 'Advanced System Settings' and then 'Environment Variables'

  • Click 'New' and add MONODEVELOP_SDB_TEST and set value to 1

Now unzip the Putty package and copy it to your C:\Program Files folder. Next add Putty to the PATH environment variable:

  • Right click on the Start Menu and select 'System'

  • Click on 'Advanced System Settings' and then 'Environment Variables'

  • Click on 'Path' and press 'Edit...'

  • Click 'New' and add the path to your Putty installation e.g. 'C:\Program Files (x86)\Putty'

You will need to run putty manually to set up the ssh key for the connection to your ATM device. Run 'cmd' from the Start menu and type:

putty.exe -ssh root@your_ip

then follow the instructions to save the key.

Your First Linux C# Application

So now Xamarin Studio is installed lets use it to build a traditional HelloWorld application:

  • First create a new solution from the File menu or from the left hand shortcut pane

  • Choose Console Project using C#

  • Name your project 'HelloWorld' and select a Project folder if you prefer to change the default location

  • Click 'Create' and the project framework will be generated which will form our Hello World example as is.

Deploying and Debugging Your Application

You have two choices when it comes to debugging your application:

  1. Debug the application locally on your development machine
  2. Remote debug your application on your ATM device

Using method 1 is fine if your application is generic enough and doesn't use ATM specific hardware or drivers however in most cases you will want to run your application directly on the ATM hardware. Debugging locally is simply a matter of running the application from the 'Run' menu or by pressing the 'Run' button on the toolbar. Debugging remotely requires some setup which is explained in the following section.

Note that the configuration below only needs done once per project

PDB to MDB Conversion

Before you can debug applications on Linux, you will need to convert the standard Windows debugging file format to a Mono compatible one. Specifically we are going to convert the .pdb file into a .mdb one.

First we need to download the conversion utility:

  • Right click on Packages in the Solution Explorer and select Add Packages

  • Search for pdb2mdb and select the Mono pdb2mdb package

  • Click Add Package

Now lets configure Xamarin to run this tool after each build:

  • Right click on your project from the solution explorer and select Options

  • Select Build->Custom Commands

  • Choose After Build from the 'Project Operation' pull down menu and enter the following command:

    • ..\packages\Mono.pdb2mdb.0.1.0.20130128\tools\pdb2mdb.exe "${TargetFile}"

  • Click OK and rebuild your project and the .mdb file should be generated within the target build directory

You should end up with the following:

Image Removed

Configure the Remote Debugger

Remotely debugging your application on your ATM device involves the following:

  1. Copy files to the target

  2. Start the remote debugger

  3. Connect to it with Xamarin Studio

You could copy over your files manually with Putty or WinSCP (http://winscp.net/eng/index.php) then manually run the remote debugger each time you want to use it but that soon becomes cumbersome so we will describe the method we use which will automate this process.

  • Right click on the project from the solution explorer

  • Click 'Custom Commands' under 'Run'

  • Select 'Before Execute' from the 'Select a project operation' menu

  • Add the following command:

    • pscp -scp "${TargetDir}\*" root@192.168.1.100:~/

    • Replace the IP address with that of your ATM device

  • Now add a new 'Before Execute' command:

    • plink -ssh root@192.168.1.100 "export DISPLAY=:0; mono --debug --debugger-agent=transport=dt_socket,address=0.0.0.0:2,server=y ${TargetName} > /dev/ttymxc3 &"

    • Replace the IP with that of your ATM device and replace 2 with the port you wish to use.

You should end up with the following:

Image Removed

Click 'Ok' to finish.

These commands use Putty SSH client to send over the files then run a remote command to start the debugger on ATM. The 'export DISPLAY=:0' allows GUI based apps to be run remotely and can be omitted if you are not running a GUI based app. Console based apps have their output redirected to the debug terminal with "> /dev/ttymxc3" so you can watch the output from your application as it occurs.

Running the Debugger

Now that everything is configured you can start your debugging session.

...

Place a breakpoint at the start of your application by clicking the left column beside the line you want to stop at

...

Click on 'Run With...' from the 'Run' menu

...

Click 'Custom Command Mono Soft Debugger'

...

Fill in your IP and Port then click 'Connect'

...

ATDM utilizes Crank's Storyboard IO API for bi-directional communication with the front-end UI and logic. The API provides transport delivery guarantees for messages placed into the queue regardless of the implementation. The maximum transport size of a message and the total queue capacity varies slightly from implementation to implementation; however, a 2K message size should be considered a design limit with the practical implementation limit around a 4K message payload size.

Image Added

Storyboard IO communicates events over a named uni-directional channel. By default, Storyboard applications have a receive channel named after the deployment bundle file (i.e., [bundlename].gapp). It allows backend applications to send events to the Storyboard Application. A custom receive channel can be specified in the command option for sbengine. The Storyboard application can transmit events on one or more channels. The backend software will need to open the channel and listen to events. See Storyboard IO API for more details.

Client applications can use Storyboard IO to create their communication channels and then receive events from that channel from the Storyboard application or any other Storyboard IO client.

CAN Generator

ATDM offers a CAN generator tool with SBIO support. It is configurable to use a specific DBC file and specific output directories for the generated source code. The generator tool will use the configured DBC file to output C and Lua source code to the configured directories. You can access the CAN generator's repo at the following Bitbucket link here.