Philippsen's Blog

Everyday findings in my world of .net and related stuff

Archive for the ‘Books and reading stuff’ Category

Using an Apple TV remote with kodi on Raspberry Pi (using Flirc)

Posted by Torben M. Philippsen on March 4, 2017

I have become a big fan of both kodi and Raspberry Pi.

On of the advantages with Kodi is that it works with HDMI cec, wich basically means that You can use Your regular tv remote since all button input signals will be transfered using Your HDMI cable – nice. On most of the tv manufacturers remote controls, the arrow and media buttons are in the bottom region of the remote. For just navigating kodi I started to search for a more simple remote. I wanted a remote of good qaility, nice design and not too expensive. And somehow that lead me into wanting to use an apple tv remote along with kodi. The apple tv remote (3rd gen.) has a simple and very nice aluminum design with just a few simple buttons used to navigate. The price is also very attractive compared to other remotes like Logitech Harmony

samsun_remoteapple-tv-aluminum-remote

Prerquistes:

 

I will not go into details of how to use flirc or kodi – but will focus on the procedure you need to go through. If You need any information about how to configure flirc, please visit their website. If You need to know more about kodi, please visit their wiki.

First step – configure the remote to work with flirc – pairing buttons

One important thing to know about flirc is that it just records keybord commands. Below is how I mapped the Apple tv remote buttons.

Button on apple tv remote Keyboard signal
Left button Left arrow
Right button Right arrow
Up button Up arrow
Down button Down arrow
Center button Enter
Menu button Backspace
Play/Pause button Space

 

Here is a complete list of Kodi keyboard commands

Second step – create kodi keymap

One of the features that makes kodi extremely flexible is that you can create keymaps. This basically means, that You can have a button work one way if you are in one menu and have the same button act in another way in some other menu. Put in another way – one button can act in different ways based on the context in the user interface. Having only seven buttons to configure this is very useful.

So the basic features that I would want to have the apple remote to support?:

  • Navigate left
  • Navigate right
  • Navigate down
  • navigate up
  • Select
  • Play/pause
  • Context menu
  • Navigate back (escaping a menu)

As you migh notice, this is eight commands for seven buttons.

I decided to have the play/pause button work in two different ways.

  1. When wathching movies etc. I want it to play/pause when pressed
  2. When items are highlighted in playlists and in the video submenu I want it to display the context menu for instance for being able to see movie information)

To make a long story short what You basically need to do is to map a keyboard command with a kodi command – and that is what You use the keymap for.

  • Create a remote.xml file
  • Paste this xml snippet

<?xml version="1.0" encoding="UTF-8"?>
<!– This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within XBMC –>
<!– The <global> section is a fall through – they will only be used if the button is not          –>
<!– used in the current window’s section.  Note that there is only handling                       –>
<!– for a single action per button at this stage.                                                 –>
<!– For joystick/gamepad configuration under linux/win32, see below as it differs from xbox       –>
<!– gamepads.                                                                                     –>

<!– The format is:                      –>
<!–    <device>                         –>
<!–      <button>action</button>        –>
<!–    </device>                        –>

<!– To map keys from other remotes using the RCA protocol, you may add <universalremote> blocks –>
<!– In this case, the tags used are <obc#> where # is the original button code (OBC) of the key –>
<!– You set it up by adding a <universalremote> block to the window or <global> section:       –>
<!–    <universalremote>             –>
<!–       <obc45>Stop</obc45>         –>
<!–    </universalremote>            –>

<!– Note that the action can be a built-in function.                 –>
<!–  eg <B>ActivateWindow(MyMusic)</B>                         –>
<!– would automatically go to My Music on the press of the B button. –>

<!– Joysticks / Gamepads:                                                                    –>
<!–   See the sample PS3 controller configuration below for the format.                      –>
<!–                                                                                          –>
<!–  Joystick Name:                                                                          –>
<!–   Do ‘cat /proc/bus/input/devices’ or see your xbmc log file  to find the names of       –>
<!–   detected joysticks. The name used in the configuration should match the detected name. –>
<!–                                                                                          –>
<!–  Button Ids:                                                                             –>
<!–   ‘id’ is the button ID used by SDL. Joystick button ids of connected joysticks appear   –>
<!–   in xbmc.log when they are pressed. Use your log to map custom buttons to actions.      –>
<!–                                                                                          –>
<!–  Axis Ids / Analog Controls                                                              –>
<!–   Coming soon.                                                                           –>
<keymap>
    <Videos>
        <keyboard>
            <key id="VK_SPACE">ContextMenu</key>
            <space>ContextMenu</space>
        </keyboard>
    </Videos>
    <VideoPlaylist>
        <keyboard>
            <key id="VK_SPACE">ContextMenu</key>
            <space>ContextMenu</space>
        </keyboard>
    </VideoPlaylist>
</keymap>

VK_space is the keyboard command that kodi receives. See List of keynames that can be used in keymap for more information

  • upload the remote.xml file to your Raspberry Pi/Kodi – path: /storage/.kodi/userdata/keymaps/
  • Put flirc usb device in usb port on Raspberry Pi
  • Reboot kodi

That’s it.

 

References:

Posted in Books and reading stuff | Tagged: , , , | Leave a Comment »

AIF–post processing of incomming record

Posted by Torben M. Philippsen on October 7, 2014

In a recent task for a customer I created a document service based on customized datamodel (build by myself). The datamodel consisted of two related tables. In these two tables I would collect incomming records from whicj I had to create CirParty entities, HRM applicants and HRM applications. This means that my datamodel would only serve the purpose of collecting the data. Then I would create some business logic to process the incoming logic. In Dynamics AX 2012 I searched for the right hookin and found that the UpdateNow method on the Axd class to fully fulfill my requirements.

I ended up with this peace of code…

ClassDeclaration:

class Axdegf_HRMWebRecruitment extends AxdBase

{

    #define.WebRecruitment_DataSourceName(‘WebRecruitment’)

    #define.Attachments_DataSourceName(‘Attachments’)

   

 

      //EG/2014.10.07/TOMPH, 00328407_3 HRMWebRecruitment—>

    AxEGF_HRMWebRecruitment            axbc_WebRecruitment;

    AxEGF_HRMWebRecruitmentAttachments axbc_Attachments;

    //EG/2014.10.07/TOMPH, 00328407_3 HRMWebRecruitment <–

}

PrepareForSaveExtended method (where the reference for the current record is created – marked in red):

public boolean prepareForSaveExtended(

    AxdStack                    _axBcStack,

    str                         _dataSourceName,

    AxdRecordProcessingContext  _recordProcessingContext,

    AxInternalBase              _childRecord)

{

    //TODO: Add code here to ensure that required fields specified in the initMandatoryFieldsMap method are sent in by the service caller.

    switch (_dataSourceName)

    {

        // ———————————————————————-

        // Process WebRecruitment records

        // ———————————————————————-

        case #WebRecruitment_DataSourceName:

 

            axbc_WebRecruitment = _axBcStack.top();

            switch (_recordProcessingContext)

            {

                //EG/2014.10.01/TOMPH, 00328407_3 HRMWebRecruitment –>

                case AxdRecordProcessingContext::BeforeChildRecordProcessed:

                    switch(_childRecord.dataSourceName())

                    {

                        case #Attachments_DataSourceName:

                            if(!axbc_WebRecruitment.isProcessed())

                            {

                                return true;

                            }

                            break;

                    }

                    return false;

                    //EG/2014.10.01/TOMPH, 00328407_3 HRMWebRecruitment <–

                // Ensure WebRecruitment record is saved

                case AxdRecordProcessingContext::AfterAllChildRecordsProcessed:

                    if (!axbc_WebRecruitment.isProcessed())

                    {

                        return true;

                    }

                    return false;

            }

—-code left out—

UpdateNow method:

//EG/2014.09.21/TOMPH, 00328407_3 HRMWebRecruitment

//Meethod used to run busines logig before AIF ends its lifecycle

//Here we process the incoming record

public void updateNow()

{

    EGF_HRMWebRecruitment           egf_HRMWebRecruitment;   

    ;

    super();

    //get the current incoming record

    //egf_HRMWebRecruitment = axegf_HRMWebRecruitment.eGF_HRMWebRecruitment();

    egf_HRMWebRecruitment = axbc_WebRecruitment.eGF_HRMWebRecruitment();

    //having he incoming record – process it

    egf_HRMWebRecruitment.ProcessIncomingRecord();

}

Posted in Books and reading stuff | Comments Off on AIF–post processing of incomming record

UAC troubles

Posted by Torben M. Philippsen on June 12, 2012

Working with UAC (User Access control) in relation to win vista, win7 and win server 2008 can be quite troublesome.
Yesterday we found that one our helper apps, which has a feature to start and stop services both local and remotely, didn’t work as expected. When running the application in elevated mode, everything worked fine.
Since we can’t expect all users to remember to run the application in elevated mode, we needed to find a more permanent solution.
I have previously been working with UAC problems relating to processes not running in elevated mode, but i didn’t know how to force the entire application ro run in elevated mode. Google turned out to be my friend again and I found tons of articles telling me “just” to add a manifest file changing the existing:
<requestedExecutionLevellevel=asInvokeruiAccess=false />

to:

<requestedExecutionLevellevel=requireAdministratoruiAccess=false />

Simple one would think – and it was, so You might figure my level of frustration, when this turned out not  to be enough.

Actually there was nothing wrong with the suggested solution, but all post that I read, failed to explain how to tell Visual Studio to use the added manifest file – I had to figure that out myself. A complete solution on how to force Your application to always run in elevated mode wil be listed here:

  • In Visual Studio 2010 (I guess the same applies to VS2008, but I haven’t tested it) right click Your project and select “add new item”
  • Add a application manifest file – the default name will be app.manifest.
  • Inside the manifest file, change the existing configuration from
    <requestedExecutionLevellevel=”asInvoker”uiAccess=”false” />
    To
    <requestedExecutionLevellevel=”requireAdministrator”uiAccess=”false” />
  • Save and close the manifest file.
  • Please note that Your manifest file won’t show up anywhere in your solution. In order to fix that, in solution explorer, click the “show all files” button.
  • Important: Right click the manifest file and add it to the project – we need that in order to tell VS to use the manifest file when compiling our application.
  • Right click Your project and select “properties”.
  • On the application tab, the bottom section, select the manifest file:

    manifest file selection

    manifest file selection

  • Compile and run the application. If Your UAC settings are enabled, You will be prompted to allow the application to start in elevated mode.

Sometimes it can come in handy to check whether Your application is actually running in elevated mode or not. Maybe You will find this codesnippet usefull:

 WindowsPrincipal myPrincipal = new WindowsPrincipal (WindowsIdentity .GetCurrent());

 if (myPrincipal.IsInRole(WindowsBuiltInRole .Administrator) == false )
 {
  //show messagebox - displaying a messange to the user that rights are missing
  MessageBox .Show("You need to run the application using the \\"run as administrator\\" option" , "administrator right required" , MessageBoxButtons .OK, MessageBoxIcon .Exclamation); 
 }
 else
 {
  MessageBox .Show("You are good to go - application running in elevated mode" , "Good job" , MessageBoxButtons .OK, MessageBoxIcon .Information);
 }

You may also find these references helpfull:

http://stackoverflow.com/questions/2818179/how-to-force-c-sharp-app-to-run-as-administrator-on-windows-7

http://msdn.microsoft.com/en-us/library/bb756929.aspx

http://victorhurdugaci.com/using-uac-with-c-part-1/

Posted in Books and reading stuff, Microsoft .net, Visual Studio | Tagged: , , , , , | Comments Off on UAC troubles

Very helpful blogpost on debuggig AIF services on a server 2008

Posted by Torben M. Philippsen on December 7, 2011

http://www.ksaelen.be/wordpress/2010/07/debugging-aif-on-windows-2008-2/

Posted in Books and reading stuff | Comments Off on Very helpful blogpost on debuggig AIF services on a server 2008

Interesting whitepaper on sharepoint load testing using The Visual Studio Test Capabilities

Posted by Torben M. Philippsen on June 16, 2011

Check out this whitepaper – How to Configure a Stress Test Project for Microsoft Office SharePoint Server 2007 using Visual Studio Team Suite 2008.

I have experienced some availabilty problems with the link, and because of that, You will also be able to get a local copy of the whitepaper from here:

HowToConfigStressTestProjectForMOSS07usingVS2008TS

 

If you want more information on VS and testing, You should check out the blog of Ed Glas

Posted in Books and reading stuff | Tagged: , , , | Comments Off on Interesting whitepaper on sharepoint load testing using The Visual Studio Test Capabilities

Free e-books

Posted by Torben M. Philippsen on October 12, 2010

Som free e-books that I stumbled accross in the latest edition of the MSDN Flash:

Foundations Of Programming

The Foundation Of Programming Series Free e-book By Karl Seguin. It is simple, short and sweet. Especially for ‘casual’ programmers, this will give a better thought process – that’ll definitely enable them to code better and think better. This book covers the ALT.NET Philosophy, Domain Driven Development concepts, DI, TDD etc in a nice way.

Microsoft Application Architecture Guide, 2nd Edition

Published by Microsoft, this is an essential read for any Microsoft.NET developer or Architect to understand the underlying architecture and design principles and patterns for developing successful solutions on the Microsoft platform and the .NET Framework. This guide neatly covers popular architecture patterns, best practices and common challenges you need to understand for developing .NET applications. Get a good grip on developing enterprise applications in .NET.

Rob Miles C# Yellow Book 2010

A nice action packed book that takes you through C# and .NET concepts. This book explains C# language and .NET library in general – with a clear focus on implementation thought process and best practices.

Threading in C#

A short, neatly written book from Joe Albahari about Threading in C#. This is a must read for any .NET programmer to understand more about threading in general, thread pooling, synchronization, Non blocking synchronization, etc. In this book, Joe even covers the Parallel Framework Extensions and Parallel programming in .NET

Improving .NET Application Performance and Scalability

This guide is again from Microsoft, and focuses on designing your applications with Performance and scalability in mind. It has sections relevant to architects, developers, testers, and administrators. Following the checklists and guidance in this book will ensure that there won’t be any unpleasant surprises in the end. Read this guide if you develop Enterprise applications in .NET

Applying Design Patterns

This is a quick introduction towards the thought process of applying design patterns. The objective of the book is to introduce design patterns in a simple way, so that developers can understand some common patterns and how to apply them.

RefCardz from DZone

DZone has a number of awesome Ref Cardz (Quick reference sheets) on multiple technologies. You can go to DZone –> RefCardz to browse and download them (after getting a free DZone Id). Here are some of my favorites:

Posted in Books and reading stuff | Tagged: | Comments Off on Free e-books

 
%d bloggers like this: