Fortsätt till huvudinnehåll

Inlägg

Visar inlägg från augusti, 2016

Taking a struct from the unmanaged to the managed world

In .NET the Common Language Runtime (CLR) virtual machine manages the program execution. Code that is written in a .NET language is hence called Managed Code, while code like C and C++ that compiles to native programs that doesn't require CLR is referred to as Unmanaged Code. It turns out that many types can not be shared straight up between managed code and unmanaged code. To do this the types needs to be converted. This conversion process is called  marshaling . I got some real hands on experience with marshaling the last week when I worked on moving and re-writing C++ code to C#. One of the structs (that included an array of another type of struct, that in turn included another struct...) in the C++ code is written to disk with exact requirements on the number of bytes the data is allowed to occupy. My first naive approach was to simply replicate the structs in C# and, using a BinaryFormatter and a MemoryStream, convert them to a byte array. This approach worked very well

Wish that it was this easy to interact with serial ports when serial ports were actually used

I won't go into that much background story but I spent some time today reading and writing to COM ports using C#. This is extremely simple. Just create a new SerialPort (some parameters, like the name of it is good to set), open() it, and start writing stuff to it. Unfortunately most modern computers come without any actual serial ports. But for testing purposes you can download a virtual port driver, like  com0com , that works perfectly fine. Set it up and you are soon ready to start testing your serial port application against a mock.

First day at the new job

Had a great first day at the new job. Spent most of the time setting up the computer and verifying that I have all accesses I need. After some minor setbacks I was able to clone the git repository I will be working in and do a first successful build. I must say it feels very nice to have a local, powerful, machine to develop on as an alternative to remote development on a NX server as I have been doing for the last years.

Vacation is coming to an end

It has been great having a month off work. I have spent most of the time with my family and not much time coding. However, I did get a Raspberry Pi 3 from my previous co-workers when I quit (thanks a lot guys!) and I have been loading it with Windows 10 IoT and currently I am setting up Visual Studio to be able to program and debug it. See how to set up your Raspberry Pi here:  https://developer.microsoft.com/en-us/windows/iot