Må ha support for C# utvikling installert i VSCODE. Hvis det er et eldre prosjekt som man henter opp som er laget i Visual Studio så må man ha C# Dev kit installert siden det støtter MSBUILD projects osv.
https://code.visualstudio.com/docs/languages/csharp
###
Må sjekke at ikke det er feil versjon av dotnet som kjøres med kommando dotnet --info
Installering i et CMD vindu kan skje med winget: https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net70
###
X86 path kan være fær X64 path. Rekkefølgen på path prioriteres
Sjekk PATH ! IKke bare PATH for ALLE brukere, men sjekk path for DIN bruker
https://github.com/dotnet/core/issues/5962#issuecomment-780084535 MRK denne tutorialen fokuserer på SYSTEM PATH men det var YOUR ACCOUNT PATH som var feil
Hvis path peker til x86 versjonen av dotnet mens du har installert dev packs osv for X64 versjonen av dotnet så får du feilmeldinger i VSCODE
Må ha core dev installert
List hva som er installert med "dotnet --list-sdks"
###
Må modde .csproj fila i det opprinnelige prosjektet for å få kopmpilert med VSCODE
https://github.com/dotnet/msbuild/issues/5787
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net48</TargetFramework>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
</ItemGroup>
</Project>
###
Måtte konvertere .csprj fila til nytt format som VSCODE ville godta (fikk build feilmelding)
Brukte dette toolet på kommandolinje: https://treit.github.io/c%23,/programming/2019/02/18/ConvertingCsProjectsToNewSdkFormat.html
dotnet tool install --global Project2015To2017.Migrate2017.Tool
conv HelloWorld.csproj
Litt mer info om konvertering til nytt CSPROJ format: https://www.hanselman.com/blog/upgrading-an-existing-net-project-files-to-the-lean-new-csproj-format-from-net-core
Category: Software development
How to convert binary fractions to decimal ( fixed point arithmetics )
Example for n = 110.101 Step 1: Conversion of 110 to decimal => 1102 = (1*22) + (1*21) + (0*20) => 1102 = 4 + 2 + 0 => 1102 = 6 So equivalent decimal of binary integral is 6. Step 2: Conversion of .101 to decimal => 0.1012 = (1*1/2) + (0*1/22) + (1*1/23) => 0.1012 = 1*0.5 + 0*0.25 + 1*0.125 => 0.1012 = 0.625 So equivalent decimal of binary fractional is 0.625 Step 3: Add result of step 1 and 2. => 6 + 0.625 = 6.625
Example for n = 4.47 k = 3 Step 1: Conversion of 4 to binary 1. 4/2 : Remainder = 0 : Quotient = 2 2. 2/2 : Remainder = 0 : Quotient = 1 3. 1/2 : Remainder = 1 : Quotient = 0 So equivalent binary of integral part of decimal is 100. Step 2: Conversion of .47 to binary 1. 0.47 * 2 = 0.94, Integral part: 0 2. 0.94 * 2 = 1.88, Integral part: 1 3. 0.88 * 2 = 1.76, Integral part: 1 So equivalent binary of fractional part of decimal is .011 Step 3: Combined the result of step 1 and 2. Final answer can be written as: 100 + .011 = 100.011
RTOS on Arduino
Professional software developers of time critical code often use a real time operating system (RTOS) in their work. The reason is that the OS is taking care of timing and scheduling tasks with higher priority. Now you can easily use an RTOS on your Arduino as well! Read Jain Risbah’s article over at circuitdigest: https://circuitdigest.com/microcontroller-projects/arduino-freertos-tutorial1-creating-freertos-task-to-blink-led-in-arduino-uno
How to remote login to your raspberry pi via Windows native Remote Desktop Connection
How to remote login to your raspberry pi via Windows native Remote Desktop Connection:
https://www.maketecheasier.com/enabling-remote-desktop-access-on-raspberry-pi/
Logon to Raspberry PI via windows builtin remote desktop connection (XRDP) with Norwegian keymap
You can now logon to Raspberry PI via the windows builtin remote desktop connection! WIth XRDP there is no need for other software to be installed. However the Norwegian keymap is not there by default so your _ / @ keys etc may be messed up.
You need to edit your /etc/xrdp/xrdp_keyboard.ini file with
sudo nano /etc/xrdp/xrdp_keyboard.ini
Then add the lines marked in bold below. As far as there is a km-00000414.ini file in the /etc/xrdp/ folder you are good to go. The windows remote desktop client will send info that you use a norwegian keyboard when you log on and the XRDP service on Raspberry will use the correct keyboard mapping to X
Edited: xrdp_keyboard.ini file
;
; RDP Keyboard <-> X11 Keyboard layout map
;
; How this file works:
; 1. load the file and scan each section to find matching “keyboard_type”
; and “keyboard_subtype” based on the values received from the client.
; If not found, then jump to default section.
; 2. in the selected section, look for “rdp_layouts” and “layouts_map”.
; Based on the “keylayout” value from the client, find the right x11
; layout value.
; 3. model/variant are inferred based on the “keyboard_type” and
; “keyboard_subtype”, but they can be overridden.
;
;
; RDP Keyboard Type (http://msdn.microsoft.com/en-us/library/cc240563.aspx)
;
; 0 is not a valid value
;
; 1 – IBM PC/XT or compatible (83-key) keyboard
; 2 – Olivetti “ICO” (102-key) keyboard
; 3 – IBM PC/AT (84-key) or similar keyboard
; 4 – IBM enhanced (101- or 102-key) keyboard
; 5 – Nokia 1050 and similar keyboards
; 6 – Nokia 9140 and similar keyboards
; 7 – Japanese keyboard
;
; RDP Keyboard Subtype is vendor dependent. XRDP defines as follows:
;
; 0 is not a valid value
;
; 1 – Standard
; 2 – FreeRDP JP keyboard
; 3 – Macintosh
; … – < any vendor dependent subtype >
;
; The list can be augmented.
;
; default
[default]
; keyboard_type and keyboard_subtype is not read for default section. It
; is only a placeholder to keep consistency. Default model/variant are
; platform dependent, and could be overridden if needed.
keyboard_type=0
keyboard_subtype=0
; user could override variant and model, but generally they should be inferred
; automatically based on keyboard type and subtype
;variant=
;model=
; A list of supported RDP keyboard layouts
rdp_layouts=default_rdp_layouts
; The map from RDP keyboard layout to X11 keyboard layout
layouts_map=default_layouts_map
[default_rdp_layouts]
rdp_layout_us=0x00000409
rdp_layout_de=0x00000407
rdp_layout_fr=0x0000040C
rdp_layout_it=0x00000410
rdp_layout_jp=0x00000411
rdp_layout_jp=0xe0010411
rdp_layout_jp=0xe0200411
rdp_layout_jp=0xe0210411
rdp_layout_kr=0x00000412
rdp_layout_ru=0x00000419
rdp_layout_se=0x0000041D
rdp_layout_ch=0x00000807
rdp_layout_pt=0x00000816
rdp_layout_br=0x00000416
rdp_layout_pl=0x00000415
rdp_layout_no=0x00000414
; <rdp layout name> = <X11 keyboard layout value>
[default_layouts_map]
rdp_layout_us=us
rdp_layout_de=de
rdp_layout_fr=fr
rdp_layout_it=it
rdp_layout_jp=jp
rdp_layout_kr=kr
rdp_layout_ru=ru
rdp_layout_se=se
rdp_layout_ch=ch
rdp_layout_pt=pt
rdp_layout_br=br(abnt2)
rdp_layout_pl=pl
rdp_layout_no=no
; if two sections have the same keyboard_type and keyboard_subtype, then
; the latter could override the former.
[rdp_keyboard_mac]
keyboard_type=4
keyboard_subtype=3
rdp_layouts=default_rdp_layouts
layouts_map=rdp_layouts_map_mac
[rdp_keyboard_jp]
keyboard_type=7
keyboard_subtype=2
model=pc105
rdp_layouts=default_rdp_layouts
layouts_map=default_layouts_map
[rdp_layouts_map_mac]
rdp_layout_us=us
rdp_layout_de=de
rdp_layout_fr=fr
rdp_layout_jp=jp
rdp_layout_kr=kr
rdp_layout_it=it
rdp_layout_ru=ru
rdp_layout_se=se
rdp_layout_ch=ch
rdp_layout_pt=pt
rdp_layout_br=br(abnt2)
rdp_layout_pl=pl
Credit to this post where I found the info that solved it for me: https://www.raspberrypi.org/forums/viewtopic.php?t=181873
How to check for a NAN (Not A Number) in C++ in embedded systems without exception handlers
Sometimes there are bugs or special corner conditions that makes a NAN (Not A Number) occur in code compiled from a C++ source and executed on an embedded systems without memory to run exception handlers.
Here is what @Jalf writes over at StackExchange:
According to the IEEE standard, NaN values have the odd property that comparisons involving them are always false. That is, for a float f, f != f
will be true only if f is NaN.
Note that, as some comments below have pointed out, not all compilers respect this when optimizing code.
For any compiler which claims to use IEEE floating point, this trick should work.
If you inplement a function in a separate .cpp file , how do you access objects instantiated in main from functions implemented that file?
Sometimes there is a need to spread code into several .cpp files to avoid clutter (for example main.cpp, other1.cpp, other 2.cpp) . So if you implement a function in a separate .cpp file, how do you access objects instantiated in main?
Solution: use extern
other1.cpp: extern ObjectType objectname void doSomething (void) { objectname.method(); }
Of course this is very basic stuff, but many new programmers ask about this so I included a short post about this here.
How to develop and debug C++ code for Arduino in Visual Studio if you are tired of the Arduino IDE
The Arduino platform has gained a fantastic popularity over the past ten years. For small quick and dirty projects, the .ino files and the standard IDE is OK. However, for professional development projects and for developers that want control over the .hpp and .cpp files the standard Arduino IDE is somewhat regarded like a toy. Furthermore there is no proper debugger in the Arduino IDE (whaaat?, you gotta be kidding?)
Well, this has changed as Visual Micro has developed a plugin to Microsoft Visual Studio. You can write code the normal way you do it with .cpp and .hpp files. You can also run the GDB debugger. The IDE has support for the regular .INO files and Arduino libraries. Here is how both .cpp and .ino files are handled: http://www.visualmicro.com/page/User-Guide.aspx?doc=INOs-and-CPPs.html
There is a free version of Visual Micro and it works against the free versions of Microsoft Visual Studio 2017 Community Edition. All you need is a Microsoft account to be able to download and install Visual Studio 2017 Community edition. Then in MSVC 2017, go to tools, Extensions and Updates and enter a search for Arduino in the search bar. It will will offer to automatically install the Arduino tools and the GDB debugger. Click install and you are on the right path.
If you find this tip useful, please share on facebook and share the link. Also, feel free to report your experiences in the comment field.