Philippsen's Blog

Everyday findings in my world of .net and related stuff

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 »

Insufficient memory to run script

Posted by Torben M. Philippsen on January 24, 2017

Today I met a boundary when creeating a routine that produces a pricelist in AX 4.0 for a webshop. When creating the required xml I was receiving the error:

Error executing code: Insufficient memory to run script.

It turns out that AX4.0 per default has a 4mb buffersize. And as the resulting xml would contain about 16 mb of data I kept getting the exception. I found good help to increase the buffersize in this post from Martin Dráb.

Posted in Microsoft Dynamics AX | Tagged: , , | Comments Off on Insufficient memory to run script

How to diagnose .net memory issues

Posted by Torben M. Philippsen on November 7, 2016

Recently I had the quite interesting task to debug some memory issues in a windows service.

I was quite surprised how good the various tools have become and after some reading I was quite quickly able to pinpoint where the probmelm, in this case a memory leak, was to be found.

I found to articles to be very helpful:

In my case I had to upgrade to VS 2015 enterprise to being able to debug the managed memory.

 

In combination the two articles describe how to get started and I recommend reading especially the first one. But if You are in a hurry this list of things to do might be helpful.

  1. First of all we need to create the actual memory dump
  2. Download ProcDump from https://technet.microsoft.com/en-us/sysinternals/dd996900.aspx and save/unzip it to a folder on the machine where your application is installed.
  3. Open a command prompt and switch to the folder where you saved/unzipped ProcDump.exe
  4. Run the command “ProcDump.exe –ma NameOfYourService.exe NameOfDumpFile
    ProcDumpCommandExample
  5. This will create a memorydump in the same folder as where ProcDump is located.
  6. As described in the article on msdn, it could be a good idea to create a baseline/initial dump and afterwards create another dump to see how memory consumption evolves.
  7. Having created the dump file, we need to switch to Visual studio – in my case VS 2015 Enterprise
  8. From the files menu select “open file” and browse to select your dump file. You will see something like this
    VSMemDumpDebugging 
  9. If you do not see the “Debug Managed Memory” action, then your version of VS doesn’t support this and You will need to upgrade to a “bigger” version.
  10. In my scenario it was quite obvious in which area the problem were to be found – please note the “Size (Bytes)” column.
    MemDumpAnalyzed
  11. Having the information above I could go back to my code at analyze where the objects were used and ensure proper release of the memory used by these objects.
    If you know what to look for, things get a hole lot easier:-)

Posted in Microsoft .net | Tagged: , , , , , | Comments Off on How to diagnose .net memory issues

How to export configuration settings for AIF inbound/outbound ports

Posted by Torben M. Philippsen on July 14, 2016

A very tedious task of mine has often been to deploy AIF services accross environments. I am used to do this the old school way = manually.

Today I had something that might be compared to as an epiphany – I stumbled upon this great technet artichle descripting how to export the configuration settings using the data import/export framework. Tried it out for the first time today and it’s working just great. The only downside so far, is that I haven’t been aware of this feature before…:-)

Posted in AIF, Microsoft Dynamics AX | Tagged: , , , , | Comments Off on How to export configuration settings for AIF inbound/outbound ports

Unable to render content due to an error. Please contact your system administrator.

Posted by Torben M. Philippsen on May 23, 2016

Recently I experienced a strange error in an usercontrol. The error would cause the classic “Unable to render content due to an error. Please contact your system administrator.” message on EP and in the eventviewer I saw this:

EV1

EV2

EV3

The strange thjing turned out to be that the code for the usercontrol was an exact match with the one from a reference environment where everything worked just fine.

Trying to narrow things down I ended up finding that it was the AllowPaging property on the grid that was set to false that caused the error. Setting this property to true, would make the control work just fine. However my customer didn’t want paging – and it woked just fine in the reference environment. Giving this thought I concluded that the error was related to data. In my environment the dataset would return 55 records and in the reference environment I would have just 12 records. I started to play around with the PageSize property of the grid and found the the magic limit was 45 records. A limit of 44 in the PageSize property would make the control work just fine, whereas a limit of 45 would make the control crash with the above eventlog entries to follow.

I don’t think that the error is related to 45 records but more likely the size of the entire dataset. In my case the dataset contains information about expences and in that context some image/binary bitmap data. I therefore expect the data to be quite big.

 

Conclusion:

If you begin to experience strange errors like the ones above – maybe it would be a good idea to look into the size of data.

Posted in Enterprise Portal Development, Microsoft Dynamics AX | Tagged: , | Comments Off on Unable to render content due to an error. Please contact your system administrator.

Assembly containing type xxx.xxx is not referenced

Posted by Torben M. Philippsen on April 29, 2016

When developing VS studio components in AX2012 You might experience the following error trying to run the code:

dll_could_not_be_referenced

When You build your vs project You will have to decide whether to publish to either client or server or maybe even both. This is where You need to keep in mind, that the server is quite certain to run as a 64 bit application where the client runs in 32 bit mode. So when building your dll for either server or client, You need specifically target the right cpu architecture. If You are deploying to both client and server You need to build using the “AnyCPU” option.

Using the AnyCPU option will cause a warning when compilling – just ignore it…

If You need to test your component on both server and client an easy way could be to:

  1. create a class with a new method and instantiate your dll in that method.
  2. Set the class to run on client
  3. Create a job and run the method.
  4. Switch the class properties to run on server and perform the same test again.
  5. If no errors occur You are good to go…

Posted in Microsoft Dynamics AX | Tagged: , , , , , | Comments Off on Assembly containing type xxx.xxx is not referenced

The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm="some_name"’.

Posted by Torben M. Philippsen on April 20, 2016

Today I spent quite some time struggling how to figure out was wrong with my client implementation of an AIF webservice. I kept getting the error “The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm="some_domain_name"’.”

It was the realm part I didn’t understand. I had configured the service in AX to use basic authentication. From a reference environment, I knew the configuration had been working.

It turned out that my focus on the realm part was wrong because the reason to the error was invalid login credentials. How invalid login credentials can trigger the above error message is not for me to say. I would have expected a message like “Failed to log in to Microsoft Dynamics AX” instead. Just thought I would share my experience…

Posted in AIF, Microsoft Dynamics AX | Tagged: | Comments Off on The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm="some_name"’.

Troubleshooting Enterprise Portal error messages

Posted by Torben M. Philippsen on April 4, 2016

If you have been working with enterprise portal development, you will probably have gone through the same levels of frustration as I because error messages are not good in adding usable information into these messages. Over time I have collected some sites with suggestions on how to troubleshoot these more or less cryptric messages.

Error: Enterprise Portal Web Parts show "Unable to render content" error
https://blogs.msdn.microsoft.com/emeadaxsupport/2010/09/23/enterprise-portal-web-parts-show-unable-to-render-content-error/

Error: Unable to render content due to an error. Please contact your system administrator.
https://blogs.msdn.microsoft.com/emeadaxsupport/2010/11/17/how-to-troubleshoot-enterprise-portal-error-unable-to-render-content-due-to-an-error-please-contact-your-system-administrator/

Generel troubleshooting: https://msdn.microsoft.com/en-us/library/cc554278.aspx

Posted in Enterprise Portal Development, Microsoft Dynamics AX | Tagged: , , , , | Comments Off on Troubleshooting Enterprise Portal error messages

AIF – getting offline WSDL files

Posted by Torben M. Philippsen on March 2, 2016

Quite often when dealing with AIF service I am asked to send a WSDL for a service to a 3rd party partner. Typically the partner dowsn’t have access to the service in that phase of the project. This means that I would have to send physical wsdl files (and not just an URL). In my experience the “singleWSDL” feature introduced with .net framework 4.5 doesn’t work for AIF services. In these cases AIF can be quite thedius to work with because the wsdl references other wsdl files as well as xsd’s. So in order to being able to send an offline wsdl file to a partner, you have to do a little bit of manual work. Ofcourse there are many ways to achieve the same, but here’s a guide of way, that I have found quite easy to work with.

  • Make sure the service has been published.
  • Open visual studio and create a console application. Add a new service reference pointing to the your service. Visuial studio now creates proxy classes as well as downloads referenced wsdl’s and xsd’s. You should see something similar to this in your project:
    wsdls
    Please note the 3 WSDL files and 6 XSD files.
  • Locate the physical location of the files (right click in VS and look at the file properties)
  • Copy all of the WSDL and XSD to a new folder of your choice (outside the project). This folder now contains the files that we want to send to our partner. But before sending them, we need to do some minor modifications.
  • Open the RoutingService.wsdl in your editor (VS will do just fine). Find and edit all import statements:
    import
    You will se that the Locations attribute references a http address. Edit the location to point to the local file residing in the current folder.
    You will want to do the same for the service location:
    Service
    Make sure to point to the local file instead of the url.
  • Do the same for the other 2 WSDL files. It’s quickly done.
  • When finished You can test your work by going back into visual studio. Just simulate adding a new service reference pointing to the local wsdl files instead. Remember it is the RoutingService.wsdl that is Your point of entry. If VS doesn’t complain You are now finished.
  • Finally zip the folder and sent it to the partner.

If You know of a better/easier way please post a comment…

Posted in AIF, Microsoft Dynamics AX | Tagged: , | Comments Off on AIF – getting offline WSDL files

 
%d bloggers like this: