<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dave</title>
    <description>The latest articles on Forem by Dave (@tardisgallifrey).</description>
    <link>https://forem.com/tardisgallifrey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F253309%2F617dda00-e5f6-4f41-a410-e5e6f38b31b8.jpeg</url>
      <title>Forem: Dave</title>
      <link>https://forem.com/tardisgallifrey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tardisgallifrey"/>
    <language>en</language>
    <item>
      <title>Nevertheless, Jan Coded</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Fri, 12 Mar 2021 15:07:21 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/nevertheless-dave-coded-in-2021-3hjc</link>
      <guid>https://forem.com/tardisgallifrey/nevertheless-dave-coded-in-2021-3hjc</guid>
      <description>&lt;p&gt;I apologize for this being late.  I have kept up with and read through some of the #shecoded stories.  I also apologize that this may not fit the regular definition of the tag.  However, I would like to tell you a story from history about someone very close to me that coded.&lt;/p&gt;

&lt;p&gt;I married my high school sweetheart, Jan.  She became a book keeper in banking and by the mid-1980's rose to the manager of the bond operations division of a major Texas bank.  She was in charge of making sure that what the bond traders bought and sold was properly accounted for and that bond owners received their dividends and payments.&lt;/p&gt;

&lt;p&gt;No, she was not a software developer or a programmer per se.  She had learned BASIC because we bought an Atari 600.  She and I would stay up late at night and write programs on the Atari to do things we needed.  She wrote as much as I did.  I am still proud of the application we made to make mailing labels for a dot matrix printer we owned.&lt;/p&gt;

&lt;p&gt;Her bank purchased a Wang minicomputer for the bond operations department.  The software was in BASIC.  It helped modernize and make efficient their ability to maintain the bond operations.&lt;/p&gt;

&lt;p&gt;As manager, one of her duties, because she knew and could code in BASIC was to handle the software updates.  Back then, most minicomputers received updates in the form of tapes that had to be loaded.  However, her Wang did not receive them this way, or they were not complete.  &lt;/p&gt;

&lt;p&gt;Jan would spend long hours after work sitting at a terminal typing in software updates and changes received in paper form or through a long distance phone call to Wang in California (at least that's where I remember Wang being located). Then she had to test those updated lines of code to be certain they worked.  &lt;/p&gt;

&lt;p&gt;Without her skill at BASIC, that would have been quite difficult and possibly costly if the bank had to hire someone else or have Wang send technicians to do updates.&lt;/p&gt;

&lt;p&gt;In 1986 or so, a bubble in the Texas real estate market burst and many banks were sold out to other banks.  Jan's was one of those banks.  The new owners sent in their management team that was very, shall we say, misogynistic?  Jan's new vice president made it very clear, in a manner where he couldn't be caught, that a woman should not hold her position.  After taking a long weekend, she resigned and pretty much never returned to banking.&lt;/p&gt;

&lt;p&gt;I did not find out about her experiences coding in BASIC to keep her minicomputer up to date until several years later when PC's became a thing.  I have many reasons to be proud of her after all these years; yet, for that time in the middle of a bad situation, nevertheless, Jan coded.&lt;/p&gt;

</description>
      <category>wecoded</category>
    </item>
    <item>
      <title>Now What Do I Do?</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 06 Dec 2020 16:16:55 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/now-what-do-i-do-meb</link>
      <guid>https://forem.com/tardisgallifrey/now-what-do-i-do-meb</guid>
      <description>&lt;p&gt;Earlier this year, when the pandemic started, our county was put on lockdown for a good while.  As I worked in a hospital, I worked every day, but we couldn't do anything else.  So, I started earnest work on one of my goals to get my programming skills in order and learn a few new things.&lt;/p&gt;

&lt;p&gt;I've spent most of this year sharpening my C/C++ skills (C mostly.  C++ not so much), and learning C# with .NET Core. Recently, I've also added in learning some GTK#, GTK+, and OpenGL.  I've also spent the year learning how to work with Raspberry Pi computers.&lt;/p&gt;

&lt;p&gt;I am now at that point that I can comfortably sit down and write a good part of what I want without going to Stackoverflow every five minutes.  I consider that a decent accomplishment.  I've also worked on some projects of my own.&lt;/p&gt;

&lt;p&gt;But, I've discovered a problem.  While I may know what to code, I don't know what I SHOULD code.  Even in the projects I've undertaken, once I get the basic function down, I get bored.  I know where the end game is in my head and can't seem to get enough 'umph' to trudge through and finish it out.&lt;/p&gt;

&lt;p&gt;I don't want to develop just another web app, web site, or application.  Just about all of that I can find within easy reach of the Internet or Linux's repositories.&lt;/p&gt;

&lt;p&gt;I'm not a professional programmer, so I'm not pushed to find a job.  I have one of those and it's decent.  I would like to develop things that aid my job, but bosses in my profession don't like to have someone create something that everyone else can't work on.  I'm the only one at my job that can code and there aren't any coming behind me.&lt;/p&gt;

&lt;p&gt;So, in this thing I'm doing for myself, I've got to figure out where to next.  Nothing new.  That seems a part of life. &lt;/p&gt;

&lt;p&gt;So, what do I do now? &lt;/p&gt;

</description>
      <category>programming</category>
      <category>dotnet</category>
      <category>codenewbie</category>
      <category>discuss</category>
    </item>
    <item>
      <title>If you wondered why OpenTK didn't work right on your Linux box, it isn't you.</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Mon, 30 Nov 2020 22:48:02 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/if-you-wondered-why-opentk-didn-t-work-right-on-your-linux-box-it-isn-t-you-3di</link>
      <guid>https://forem.com/tardisgallifrey/if-you-wondered-why-opentk-didn-t-work-right-on-your-linux-box-it-isn-t-you-3di</guid>
      <description>&lt;p&gt;Four days.  Four days I worked on trying to get my Linux Mint machine to do OpenGL windows/graphics using the OpenTK package on Nuget.  I could open a window, but I couldn't seem to write anything to it.&lt;/p&gt;

&lt;p&gt;Then, I got creative.&lt;/p&gt;

&lt;p&gt;This was where I was earlier this week, just before Thanksgiving.  I am starting a C# project with a math focus.  Yes, I've already been told there is an easier way.  That's not the point.  I'm in the middle of learning more programming skills, especially C#. My project needed a way to display the output of math functions (like y=x^2).  I needed a simple window graphic system to display a plot of the function. &lt;/p&gt;

&lt;p&gt;I had worked a little with OpenGL in C and it seemed my best choice for the graphing.  Gtk does have a C# library, but the drawing (using Cairo) just seemed that it wasn't straightforward.  However, if I used OpenGL, I needed it in C#.  That left me with the four days of searching how to get this done.  I kept returning to OpenTK (The OpenGL Toolkit).  But, it wasn't working out.&lt;/p&gt;

&lt;p&gt;Here is my set up:&lt;br&gt;
A Linux Mint 19 OS.&lt;br&gt;
Visual Studio Code for editing/building/etc.&lt;br&gt;
.NET Core 3.1.&lt;/p&gt;

&lt;p&gt;I could install the OpenTK Nuget package.  It didn't say it wouldn't work, just that it didn't exactly target .NET Core 3.1.  It was targeting .NET Frameworks and I should have realized that this has been problematic before.&lt;/p&gt;

&lt;p&gt;To a small degree, the library did work.  I could open the basic window class (GameWindow they call it).  I learned how to navigate the namespaces (There are several and they aren't exactly common to each other).  When I called "dotnet run" on my test projects, I could usually open a window.  I could even set the background colors of the window.&lt;/p&gt;

&lt;p&gt;Yet, try as I might, I couldn't get anything to draw ON the windows.  The programs built.  VS Code's Intellisense said I was using correct library syntax; yet, no glory.&lt;/p&gt;

&lt;p&gt;I was just about to give up when I went looking for any other kind of library package that would work.  Many of them are undocumented and ancient (OpenGL is kind of old, too, but still in use).  Finally, in one of my searches on Nuget.org, I stumbled across the package OpenTK.NetStandard.&lt;/p&gt;

&lt;p&gt;After erasing my test project and starting over with OpenTK.NetStandard, I was quite surprised when I could walk through a simple tutorial and the triangle finally appeared on the screen in my OpenTK project (It seems all OpenGL tutorials start with a triangle).  No fuss.  No muss. No pulling hair out (which I don't have).&lt;/p&gt;

&lt;p&gt;I've been busy for the last two days trying to make everything work that I need for my project.  I still have some practice to go before I'm ready to use it, but it is finally promising.&lt;/p&gt;

&lt;p&gt;I have the basics of a small tutorial project that I've just uploaded to github.com.  I'll put a link below along with the two final tutorials I followed and a link to at least one other that worked.  Many of the tutorials leave out that they are using OpenTK on .NET Frameworks and running on a Windows machine.  What I'm posting here is just the differences between what I've discovered and the OpenTK/OpenGL lessons I've run across.&lt;/p&gt;

&lt;p&gt;Once you have a working model on your development system, then you can often read anyone's tutorials, lessons, or StackOverflow and you'll have a better chance of it working, in my observed opinion (narrow that may be).&lt;/p&gt;

&lt;p&gt;The repository should build on most Debian/Ubuntu flavors, I think.  However, depending on what you're using, you might need to start a new project and copy in the code to get it to work on your machine.  You can search Nuget.org for OpenTK.NetStandard and they have good instructions for a command line install of the package.&lt;/p&gt;

&lt;p&gt;The repository has a small console menu that opens at first run.  It will give you a choice of three windows:&lt;br&gt;
An old style OpenGL window.&lt;br&gt;
A modern style OpenGL window.&lt;br&gt;
An old style 2D OpenGl window.&lt;/p&gt;

&lt;p&gt;Old style, in my parlance refers to the method of drawing by using GL.Begin to GL.End methods in your window class.  The modern style makes use of externally defined and added shaders along with Vertex Buffer Objects to draw with.  At this point, I'm too new to know the real difference. But, what I learned in programming OpenGL in C is termed 'old style' in C#.  I do think it is easier to use, especially for my simple 2D drawing/plotting.&lt;/p&gt;

&lt;p&gt;The one 2D window does have an added keyboard handler to move a square left or right on the screen. If I keep working on it, I'll add up and down.  &lt;/p&gt;

&lt;p&gt;There are probably many things I could have done to make things easier. However, one of my rules, especially in coding, is NO BLACK BOXES.  I want to know most of what goes on 'under the hood'.  By coding all of my needs and not turning any of it over to fancier 'bells and whistles' apps, I learn more.  And, in the end, for me at least, that's what it's really about&lt;/p&gt;

&lt;p&gt;The github repository is here:&lt;br&gt;
&lt;a href="https://github.com/tardisgallifrey/OpenTKNetCoreTutorial"&gt;OpenTK NEtCore Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The two tutorials I used for the 'old style' and modern is here:&lt;br&gt;
&lt;a href="http://neokabuto.blogspot.com/2013/02/opentk-tutorial-1-opening-windows-and.html"&gt;Neo Kabuto Tutorial 1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://neokabuto.blogspot.com/2013/03/opentk-tutorial-2-drawing-triangle.html"&gt;Neo Kabuto Tutorial 2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dreamstatecoding.blogspot.com/2017/01/opengl-4-with-opentk-in-c-part-1.html"&gt;This OpenTK/OpenGL tutorial is also good.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>opentk</category>
      <category>graphics</category>
      <category>opengl</category>
    </item>
    <item>
      <title>Visual Studio Code C++ with Makefile Cheat</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Tue, 21 Jul 2020 23:44:11 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/visual-studio-code-c-with-makefile-cheat-1hb4</link>
      <guid>https://forem.com/tardisgallifrey/visual-studio-code-c-with-makefile-cheat-1hb4</guid>
      <description>&lt;p&gt;This will be real quick, but I found out something, mostly on my own and I want to share it if anyone else needs it.&lt;/p&gt;

&lt;p&gt;I've been studying and using Visual Studio Code on Linux for about a month now. Some technologies (like .NET core, C#) seem to work easily.  Need a build task?  No problem, voila! You have a build task.&lt;/p&gt;

&lt;p&gt;Some technologies (like C), you're sort of on your own.  Need a build task?  Googling...fumbling...got it.  Not too many problems.&lt;/p&gt;

&lt;p&gt;But, one, I've had a great deal of difficulty with.  Some of it my fault.  Some of it...I just want to do it differently.&lt;/p&gt;

&lt;p&gt;I'm talking about building C++ files on vscode.  &lt;/p&gt;

&lt;p&gt;Vscode (for short), with the proper extension, does have a built in task for the "build my files" command.  However, I was having problems making it work.  In addition, I had decided I wanted to use Makefiles instead as I'm familiar with those.  I was using a task template for building C files with Makefiles and just wanted the two (C and C++) to be consistent.&lt;/p&gt;

&lt;p&gt;However, it wasn't that easy.  The "My fault" part got worked out with a question posted on Twitter.  I was trying to build while my active file was the tasks.json file.  Bang head on desk moment.&lt;/p&gt;

&lt;p&gt;But, when I wanted to find the same generic task template I used for building C files, vscode just wouldn't give me the option.  I discovered today that if I simply select 'Configure a Task' instead of 'Configure a Build Task', it will give me the generic template option (Other).&lt;/p&gt;

&lt;p&gt;It's taken a little bit of work and googling, but I now have a template tasks.json file that I can paste over the generic template that will run the Makefile in the same folder as my *.cpp files.  I've even added a 'make clean' task for when needed.&lt;/p&gt;

&lt;p&gt;Vscode uses the name you give your task ( the "label" line) along with a build identifier ("group":"build") to place each task in the appropriate menu.  So, if you use the following template in place of a generic tasks.json file (in your folder where you're working on *.cpp files), it will show up in a request to build and as an item when you request to run a task. Remember that there are two tasks in the file, separated by commas. The first is the build with make.  The second is the make clean task, and it doesn't get the "group":"build" portion.&lt;/p&gt;

&lt;p&gt;Feel free to kibitz (nicely) my work.  I'm still pretty new to this and there is probably an easier way.  However, for me, this way works to build my C++ projects in Visual Studio Code.&lt;/p&gt;

&lt;p&gt;Completely paste this over the generic tasks.json file, or you can insert it as a file named the same in your .vscode folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file: tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build dbc from Makefile",
            "type": "shell",
            "command": "make",
            "group": "build",
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        },
        {
            "label": "Run make clean on folder",
            "type": "shell",
            "command": "make clean",
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>vscode</category>
      <category>codenewbie</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Raspberry Pi and .NET Core, my way.</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sat, 04 Jul 2020 22:39:45 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/raspberry-pi-and-net-core-my-way-kc2</link>
      <guid>https://forem.com/tardisgallifrey/raspberry-pi-and-net-core-my-way-kc2</guid>
      <description>&lt;p&gt;I've just finished up writing a C function to read the ADS1115 ADC board on the Pi.  I'll write on that later, but right now, I need to log in something new I've done.  As I finished the C function, I knew it needed to be done in another language.  I don't like to pigeonhole my code. As I've also been working on learning to use Visual Studio Code and .NET Core on my Linux box (Shhh! &lt;em&gt;whisper&lt;/em&gt; Don't tell anyone I'm using Microsoft), I thought I'd see how to do the same C function, but with .NET on the Pi.  It took a bit, but it finally worked...at least the beginning parts.  &lt;/p&gt;

&lt;p&gt;I've just got the basics going. There is still a lot to do before I can work on the ADS1115 code.  It was fairly complicated (to me) to get dotnet (or .NET) and all the bits and pieces for coding I/O on the Pi.  I write these in order to not forget. I'm old, you know. It's important to note that I had a lot to do since the allegedly easy route didn't please me.&lt;/p&gt;

&lt;p&gt;I used parts of the following websites as references to meet my needs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://darenmay.com/blog/net-core-and-gpio-on-the-raspberry-pi---leds-and-gpio/"&gt;Daren May's .NET Core and GPIO on the Raspberry PI - LEDs and GPIO&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dotnet/iot"&gt;The dotnet/iot github (mainly the bug posts)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://edi.wang/post/2019/9/29/setup-net-core-30-runtime-and-sdk-on-raspberry-pi-4"&gt;Edi Wang's Setup for .NET Core on Raspberry Pi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, what it means for my way:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;No Docker--Not against Docker.  I just don't see it's utility most of the time. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No ASP.NET -- C'mon, one Microsoft product is enough!  Besides, I'm using Visual Studio Code on my main Linux box.  The ASP.NET bit isn't necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual Studio Code via SSH for native development on the board.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What took extra time was that some things (very important things) were not documented in these three web sites.  Though at least one of the problems I encountered was on Edi Wang's site, but way down in the comments.  I had almost solved it before I found the comment.&lt;/p&gt;

&lt;p&gt;Let's begin, after you've logged into your Pi:&lt;/p&gt;

&lt;p&gt;Installing .NET SDK and runtime on a Pi 4B using raspbian buster can be tricky.  It's not in the repository.  You'll have to install it manually.  That's where Edi Wang's web site works great.  However, you need to make two changes to his instructions.  At the point he gives you these instructions:&lt;/p&gt;

&lt;p&gt;mkdir dotnet-arm32&lt;br&gt;
tar zxf dotnet-sdk-3.1.102-linux-arm.tar.gz -C $HOME/dotnet-arm32&lt;br&gt;
tar zxf aspnetcore-runtime-3.1.2-linux-arm.tar.gz -C $HOME/dotnet-arm32&lt;/p&gt;

&lt;p&gt;Don't use them.  Use these instead:&lt;/p&gt;

&lt;p&gt;sudo mkdir /usr/share/dotnet&lt;br&gt;
sudo tar zxf dotnet-sdk-3.1.102-linux-arm.tar.gz -C /usr/share/dotnet&lt;/p&gt;

&lt;p&gt;These differences allow you to place the dotnet SDK in a shared location because you and root will be needing to know where things are located.&lt;/p&gt;

&lt;p&gt;Yep, don't download and install the ASP.NET unless you wish to use it.  If you're using Visual Studio Code, this step is not necessary.  &lt;/p&gt;

&lt;p&gt;Next change is at this point in Edi's instructions:&lt;/p&gt;

&lt;p&gt;export DOTNET_ROOT=$HOME/dotnet-arm32&lt;br&gt;
export PATH=$PATH:$HOME/dotnet-arm32&lt;/p&gt;

&lt;p&gt;Instead of those, do this:&lt;/p&gt;

&lt;p&gt;sudo ln -s /usr/share/dotnet/dotnet /usr/local/bin&lt;/p&gt;

&lt;p&gt;In most cases, /usr/local/bin is already in your PATH, so the export instructions would also not be necessary.  Test your installation with:&lt;/p&gt;

&lt;p&gt;dotnet --info&lt;/p&gt;

&lt;p&gt;It should give the same results as in Edi's web site.  If not, check through what you did and see if anything went wrong.  Is there a dotnet executable under /usr/share/dotnet?  Did the symlink appear in /usr/local/bin?  Is that in your PATH?&lt;/p&gt;

&lt;p&gt;If it did work, then you should be able to follow his instructions to build a basic dotnet console app.  From here on, it gets a little more tricky.&lt;/p&gt;

&lt;p&gt;Next, we need to get VS Code to work on our Linux box and connect to a folder on your Pi.  I'll not give instructions for installing Visual Studio Code here as you can also do this on Windows as well.  Go look it up and get it ready, if you aren't already using VS Code.&lt;/p&gt;

&lt;p&gt;To set up VS Code for remote development, I followed the Daren May article (link above) to set up my VS Code.  While I used his instructions without change, I'll offer one tip.  When you've gotten your first connection to your Pi from VS Code, go back and configure an SSH connection in VS Code. After doing this, you can just use the configured connection and give it your Pi login password.  That may be especially important if you're working on more than one Pi.&lt;/p&gt;

&lt;p&gt;Follow the Daren May article to install the SSH extension and restarting your VS Code.  On Code, You should see in the lower left corner a green-ish little block. It's your remote connection block.  Click it and a window opens at the top.  The drop down has "Remote SSH - Open Configuration File".&lt;/p&gt;

&lt;p&gt;Click that and choose the configuration file on your PC.  It will look something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Host alias&lt;/code&gt;&lt;br&gt;
&lt;code&gt;HostName host&lt;/code&gt;&lt;br&gt;
&lt;code&gt;User username&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change alias to a name for the connection.&lt;br&gt;
Change host to the IP address or hostname of your Pi.&lt;br&gt;
Change username to your login username.&lt;/p&gt;

&lt;p&gt;From now on, this alias will appear in the connection list when you choose to connect to a configured connection.&lt;/p&gt;

&lt;p&gt;Another side tip: If you're running Linux (and I think it can be done on Windows, too), you can connect to your many raspberry pi's with names.  Simply add a name in your /etc/hosts file pointing to (hopefully?) the static IP you gave your pi.  It has to be a fully-qualified-domain-name to work,though. I just put '.lan' after mine and they work.&lt;/p&gt;

&lt;p&gt;After, you have connected, click the folder icon in the top of the left side menu.  It should have a blue box to open a folder.  Click it and it will give you a menu at the top of the screen where you can walk down your folder tree to the one you want to open. Choose a folder to open and VS Code will set it up and remember it for later as well.&lt;/p&gt;

&lt;p&gt;There is only one other thing to note in the Daren May article that isn't documented.  While you're beginning the Simple Flasher project, the article says to get the GPIO and IoT packages installed.  He gives these two install instructions:&lt;/p&gt;

&lt;p&gt;dotnet add package System.Device.Gpio --source &lt;a href="https://dotnetfeed.blob.core.windows.net/dotnet-iot/index.json"&gt;https://dotnetfeed.blob.core.windows.net/dotnet-iot/index.json&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;dotnet add package Iot.Device.Bindings --source &lt;a href="https://dotnetfeed.blob.core.windows.net/dotnet-iot/index.json"&gt;https://dotnetfeed.blob.core.windows.net/dotnet-iot/index.json&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each of these will install the correct package, but ONLY TO YOUR WORKING PROJECT!  &lt;/p&gt;

&lt;p&gt;Type these instructions in a terminal (probably in VS Code) while you are INSIDE the Simple Flasher project folder (later, you'll do this step in any folder that you wish to add these two packages).  &lt;/p&gt;

&lt;p&gt;These packages are added to your project, not installed permanently on the raspberry pi.  I guess it's just my noob-ness in dotnet, but I didnt' get that at first.&lt;/p&gt;

&lt;p&gt;Doing the install and set up this way, you should now be able to type 'sudo dotnet run' in a terminal and the Simple Flasher project should build and run.  Remember, this is a Pi and we often need to run GPIO apps at sudo. In addition, the 'error 13' I kept getting was referred to in the github bug discussions as, "Oh, you forgot to run as root.  We set it up that way." That's the purpose for the changes to the Edi Wang article that I gave above, so you can call dotnet to build your project with 'sudo'.&lt;/p&gt;

&lt;p&gt;Just for a bit of explanation. One, you have to run as root when doing GPIO because the folders in Linux for raspbian that handle I/O are all root'ed. Whether its /dev/gpiomem or /sys/ folders, they have to accessed by 'root'. Two, since our install is just un-tar-ing a tarball into a folder, root is very limited on where he (she?) looks for apps to run.  Root has no idea that your folders know where everything is, that's why we placed it in a folder area, set up to be accessible by root (and you too, of course).&lt;/p&gt;

&lt;p&gt;Finally, after figuring all this out, I was able to watch a blue flashing LED on my Pi.  Try it out for yourself.  I'll help if I can on problems.  Now, back to figuring out what the other useful instructions are in these two packages.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3amb-iii--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1279498288832577537/pu/img/uQ-w62GT1pkHDNiu.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--yay3RhvH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/2935782796/81dda064a20872f893fcc9bdc65c16b8_normal.jpeg" alt="dave (does not do pretty) profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        dave (does not do pretty)
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @abigmanrunning
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Got it! .NET Core using System.Device.Gpio and Iot.Device.Bindings running on a &lt;a href="https://twitter.com/Raspberry_Pi"&gt;@Raspberry_Pi&lt;/a&gt; 4B native. With &lt;a href="https://twitter.com/code"&gt;@code&lt;/a&gt; running remote. May have to write this down in order to save all the steps. 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      19:32 PM - 04 Jul 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1279498373687586816" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1279498373687586816" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      0
      &lt;a href="https://twitter.com/intent/like?tweet_id=1279498373687586816" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      0
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


</description>
      <category>raspberrypi</category>
      <category>dotnet</category>
      <category>visualstudiocode</category>
      <category>iot</category>
    </item>
    <item>
      <title>Raspberry Pi I/O with optocoupler and pigpio</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 24 May 2020 18:58:39 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/raspberry-pi-i-o-with-optocoupler-and-pigpio-3o6</link>
      <guid>https://forem.com/tardisgallifrey/raspberry-pi-i-o-with-optocoupler-and-pigpio-3o6</guid>
      <description>&lt;p&gt;Haven't written in a while.  Thought I'd jot this down quickly.  &lt;/p&gt;

&lt;p&gt;I've been working on input/output (I/O) projects for a few weekends now.  Nothing useful.  Just, "Can I do this....?"&lt;/p&gt;

&lt;p&gt;I've been practicing with the &lt;a href="http://abyz.me.uk/rpi/pigpio/index.html"&gt;pigpio library&lt;/a&gt; library from joan2937 at Github.com.&lt;/p&gt;

&lt;p&gt;I like pigpio (I always say pig-pi-o; sure that's wrong) because it will work in both C and Python, out of the box.  Python is a little more complicated as it needs a daemon running and that interferes with using pigpio in C.  However, still good.  Not difficult syntax, though I'm still working to memorize some of the basics.&lt;/p&gt;

&lt;p&gt;It is also helping me formulate my idea of using discrete C programs that talk directly to the hardware, then I can use Perl or Python or whatever to build up scripts of commands.  &lt;/p&gt;

&lt;p&gt;I'll give an example of my ON program that fires a single gpio pin:&lt;/p&gt;

&lt;p&gt;File: ON.c&lt;br&gt;
&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;#include &amp;lt;string.h&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;#include &amp;lt;pigpio.h&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int main( int argc, char* argv[] ){&lt;/code&gt;&lt;br&gt;
&lt;code&gt;if( argc != 2){&lt;/code&gt;&lt;br&gt;
&lt;code&gt;printf("\tUsage: sudo ON 'num'\n");&lt;/code&gt;&lt;br&gt;
&lt;code&gt;printf("\t\tWhere: num = GPIO pin number.\n");&lt;/code&gt;&lt;br&gt;
&lt;code&gt;exit(-1);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int point = atoi(argv[1]);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;int result = 0;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if( gpioInitialise() &amp;lt; 0 ){&lt;/code&gt;&lt;br&gt;
&lt;code&gt;printf("%d", 1);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;exit(-1);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;result = gpioSetMode( point, PI_OUTPUT );&lt;/code&gt;&lt;br&gt;
&lt;code&gt;printf("%d", result);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;result = gpioWrite( point, 1 );&lt;/code&gt;&lt;br&gt;
&lt;code&gt;printf("%d", result);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gpioTerminate();&lt;/code&gt;&lt;br&gt;
&lt;code&gt;return 0;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As you can tell from the usage statement, you use sudo ON and a gpio pin number.  The program sets up gpio, checks if everything is OK, then writes the value to the pin. OFF is the identical program with a 0 instead of a 1 written.  The program prints a two character result code to  that can be used in another program.&lt;/p&gt;

&lt;p&gt;So far, I've written ON, OFF, IN, and PWMOUT for turning on, turning off, reading input, and pulse width modulation, respectively.  Only PWMOUT requires additional arguments so far (pin, on time, off time).&lt;/p&gt;

&lt;p&gt;I've also been working with 4N35 optocouplers that are easily available just about all over the Internet.  These simple devices allow the developer to get inputs and outputs into the Raspberry PI (or arduino) safely with little risk to the main board.  Today, I finished testing the use of the 4N35 as an input isolator.  &lt;/p&gt;

&lt;p&gt;Here is a little video from Twitter with today's work (hint: go to the Twitter entry as the player on DEV is truncating the bottom portion; the actual good stuff):&lt;br&gt;
&lt;/p&gt;
&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper"&gt;
        &lt;div class="ltag__twitter-tweet__media--video-preview"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8GYOk3rB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/ext_tw_video_thumb/1264628332081135617/pu/img/yk4xkCJWVLVZ68bk.jpg" alt="unknown tweet media content"&gt;
          &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/play-butt.svg" class="ltag__twitter-tweet__play-butt" alt="Play butt"&gt;
        &lt;/div&gt;
        &lt;div class="ltag__twitter-tweet__video"&gt;
          
            
          
        &lt;/div&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--yay3RhvH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/2935782796/81dda064a20872f893fcc9bdc65c16b8_normal.jpeg" alt="dave (does not do pretty) profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        dave (does not do pretty)
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @abigmanrunning
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      More testing/learning with &lt;a href="https://twitter.com/Raspberry_Pi"&gt;@Raspberry_Pi&lt;/a&gt; and 4N35 optos, with pigpio library and &lt;a href="https://twitter.com/hashtag/perl"&gt;#perl&lt;/a&gt;. 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      18:45 PM - 24 May 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1264628678727733249" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1264628678727733249" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      0
      &lt;a href="https://twitter.com/intent/like?tweet_id=1264628678727733249" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      0
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;And, here is the Perl script using IN, ON, and OFF as described above:&lt;/p&gt;

&lt;p&gt;File: iogpio.pl&lt;br&gt;
(addendum: forgot to add Usage instructions. &lt;br&gt;
  to run this use: ./ipgpio.pl pin1 pin2 time&lt;br&gt;
  where pin1 is the input pin&lt;br&gt;
        pin2 is the output pin&lt;br&gt;
        time is the loop time in milliseconds.  Apologies)&lt;br&gt;
&lt;code&gt;#!/usr/bin/perl -w&lt;/code&gt;&lt;br&gt;
&lt;code&gt;use strict;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;use Time::HiRes qw(usleep nanosleep);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;my $out = 0;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;my ( $input, $output, $number ) = @ARGV;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;while(1){&lt;/code&gt;&lt;br&gt;
&lt;code&gt;if(&lt;/code&gt;IN $input&lt;code&gt;+ 0){&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$out =&lt;/code&gt;ON $output&lt;code&gt;;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}else{&lt;/code&gt;&lt;br&gt;
&lt;code&gt;$out =&lt;/code&gt;OFF $output&lt;code&gt;;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print $out . "\n";&lt;/code&gt;&lt;br&gt;
 &lt;code&gt;usleep($number);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I've still got lots more to learn and test, though I am prepping for my first complete Raspbery Pi project.  My wife bought me a 7" hdmi screen for my birthday and I'm ordering parts to build a Raspberry Pi case with battery backup, power, and access to the gpio pins, etc.  I'd like to be able to carry and use the Pi just about anywhere and start to see it as just another tool in the toolbox.&lt;/p&gt;

&lt;p&gt;Enjoy your weekend.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>c</category>
      <category>perl</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Further Thoughts on Raspberry Pi GPIO as Controller</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 19 Apr 2020 16:40:39 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/further-thoughts-on-raspberry-pi-gpio-as-controller-41nk</link>
      <guid>https://forem.com/tardisgallifrey/further-thoughts-on-raspberry-pi-gpio-as-controller-41nk</guid>
      <description>&lt;p&gt;I wrote a &lt;a href="https://dev.to/tardisgallifrey/thoughts-on-raspberry-pi-gpio-program-organization-4kpf"&gt;post&lt;/a&gt; on a method to organize Raspberry Pi GPIO so that it acts more like a controller than just a single board computer with I/O. To summarize that post, my thoughts were to establish a way to configure I/O pins, run a line-by-line control program using those pins, and repeat the control program ad infinutum.  This is more closely related to how I use industrial controllers in the electrical and HVAC field.&lt;/p&gt;

&lt;p&gt;Today, I'll flesh that idea out just a bit more (as it came to me on my morning run). It consists of creating discrete, small utility programs that handle interaction with an individual pin then we use those small programs to build larger control programs.&lt;/p&gt;

&lt;p&gt;In the first step, my idea is to create two basic programs called something similar to OUTPUT and INPUT.  I would build these in C, but you're welcome to use what you have facility using.  Calling one of these will either read or write to a single named GPIO pin thus:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;INPUT 6&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;should respond with to &lt;code&gt;STDOUT&lt;/code&gt; with 1 or 0, dependent upon the pin's condition.  Also:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OUTPUT 4 ON&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;would set pin 4 high (&lt;code&gt;OFF&lt;/code&gt; would set it low).  Using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OUTPUT 4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;would respond to &lt;code&gt;STDOUT&lt;/code&gt; with the pin's current value.&lt;/p&gt;

&lt;p&gt;In addition, we could add other small programs to allow for logic conditions between two pins.  Such as:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;AND 1 3&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;OR 1 3&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;XOR 1 3&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;NOT 3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The results for these would be a TRUE (1) or FALSE (0) to STDOUT.&lt;/p&gt;

&lt;p&gt;The pin number and condition (ON or OFF) would be command line arguments to the program.  That would make the programs useful for all the digital GPIO pins.&lt;/p&gt;

&lt;p&gt;Once these small programs are built and tested, which would be fairly simple to accomplish, then we could use C or Perl (or another program with the same ability) to run these programs from a file.  What I'm thinking about specifically is the backtick feature of Perl (&lt;code&gt;ls -l&lt;/code&gt;) that runs a system command (like our small programs) and then captures the output of the command in a variable.  It would be something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;my $value =&lt;/code&gt;&lt;code&gt;INPUT 6&lt;/code&gt;&lt;code&gt;;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and should result in a 1 or 0 being saved in $value for use elsewhere in the Perl script. The idea then, is to build a Perl script that would read from a file like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;AND 1 3&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;OUTPUT 6 ON&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;OR 6 2&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;SLEEP 10&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;OUTPUT 3 OFF&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The output lines would take effect if the condition line before them resolved to TRUE, else they would be skipped. There is also room for utility programs such as SLEEP, WATCHDOG, and possibly others I can't think of at the moment. The Perl script would run these inside some type of &lt;code&gt;while()&lt;/code&gt; loop so that they are continually repeated.  A loop timer could be a command line argument into the script as well.&lt;/p&gt;

&lt;p&gt;Since I just thought of this today, I haven't had time yet to start the project. I will have to see if this is a reasonable method or not.  There are also other conditional programs that could be added such as those for analog sensors (temperature, humidity, pressure, etc.).  While this may seem like it removes a lot of capability, but I don't think so.  A Perl script that runs a control program can be built as a &lt;code&gt;systemd&lt;/code&gt; service so that it continues to run in the background while other tasks are run such as trending logs of the I/O pins and values and running displays.&lt;/p&gt;

&lt;p&gt;Let me know what you think.  I'll be coming back to update this as I get time to work on the project.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>c</category>
      <category>perl</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I use git and gitHub to store folders in the cloud</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sat, 11 Apr 2020 20:29:34 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/how-i-use-git-and-github-to-store-folders-in-the-cloud-3bgc</link>
      <guid>https://forem.com/tardisgallifrey/how-i-use-git-and-github-to-store-folders-in-the-cloud-3bgc</guid>
      <description>&lt;p&gt;I've been using &lt;code&gt;git&lt;/code&gt; and &lt;code&gt;gitHub&lt;/code&gt; on my Linux laptop for some time now.  Though I like what each technology does, the process I've hunted for is difficult to find.  There is much information about &lt;code&gt;git&lt;/code&gt;'s use for version control with and without &lt;code&gt;gitHub&lt;/code&gt;.  However, I'm not trying to do version control.  I just want to keep individual folders synced with a repository of the same (similar) name on &lt;code&gt;gitHub&lt;/code&gt;.  Trying to understand the complexity and quantity of commands has been really daunting.  After working with both tools and researching on my own, I've come up with a minimal set of &lt;code&gt;git&lt;/code&gt; commands that work well with &lt;code&gt;gitHub&lt;/code&gt;.  These commands allow me to keep one folder synchronized to one &lt;code&gt;gitHub&lt;/code&gt; repository as a backup location. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;git&lt;/code&gt; is in most of the major Linux distribution repositories. I'm only used to &lt;code&gt;apt-get&lt;/code&gt; (&lt;code&gt;aptitude&lt;/code&gt;) on Ubuntu/Debian.  If your distribution is different from that, look up how to add programs/apps/utilities in your version of Linux.&lt;/p&gt;

&lt;p&gt;For Ubuntu/Debian users it would be: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;$&amp;gt;sudo apt-get install git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After install is complete, navigate to a folder that you wish to sync with &lt;code&gt;gitHub&lt;/code&gt;.  Don't worry yet if you haven't set up a &lt;code&gt;gitHub&lt;/code&gt; account.  We'll get to that part in a bit.  I'm going to do this as I just did today from my &lt;code&gt;ncurses&lt;/code&gt; folder.  &lt;/p&gt;

&lt;p&gt;Before we begin with the steps to synchronize a folder with itself and with &lt;code&gt;gitHub&lt;/code&gt;, there are two configuration commands you need to run.  These are important and only have to be done once.  They can be done from any folder since they are global to your &lt;code&gt;git&lt;/code&gt; system.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$&amp;gt;git config --global user.email youremailaddress.com&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;$&amp;gt;git config --global user.name "Type your name here"&lt;/code&gt;                                            &lt;/p&gt;

&lt;p&gt;Now, &lt;code&gt;cd&lt;/code&gt; (change directory) to the folder that you wish to synchronize with &lt;code&gt;gitHub&lt;/code&gt;.  Our first task is to build the local repository.  I created an &lt;code&gt;ncurses&lt;/code&gt; folder to house all the &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;Perl&lt;/code&gt; files I'm writing to help me learn to use the &lt;code&gt;NCurses&lt;/code&gt; library/module for &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;Perl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That first task is to &lt;code&gt;init&lt;/code&gt; your &lt;code&gt;git&lt;/code&gt; (create the repository system):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create a new git repository in your folder. To check that it did, do an &lt;code&gt;ls -a&lt;/code&gt;. In each folder that you &lt;code&gt;init&lt;/code&gt; your &lt;code&gt;git&lt;/code&gt;, you'll find a &lt;code&gt;.git&lt;/code&gt; sub-folder.&lt;/p&gt;

&lt;p&gt;The next step is to add all the files in your folder. There are probably hundreds of ways to do this to pick 'just the ones' you want, but it's easiest if  you maintain only files in the folder that you want synchronized; nothing extraneous.  That way, all you'll really need is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git add *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This adds all files (and sub-folders) to your branch.  Branches are important in &lt;code&gt;git&lt;/code&gt;, but for us, each folder has one &lt;code&gt;master&lt;/code&gt; branch and we are going to keep it that way. To see that they've been added, run the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Learn this one well. It is the most used &lt;code&gt;git&lt;/code&gt; command, in my experience. &lt;code&gt;git status&lt;/code&gt; will tell you if your folder is up to date with your &lt;code&gt;git&lt;/code&gt; repo. It will show you (in red, possibly) when you've made changes, and (in green, possibly) when you've done a &lt;code&gt;git add *&lt;/code&gt; and are ready to &lt;code&gt;commit&lt;/code&gt; your &lt;code&gt;git&lt;/code&gt; with the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git commit -m "My first commit with date, etc."&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If at all possible, do your commits like the above as it is simplest. You can and should change the message to describe the &lt;code&gt;commit&lt;/code&gt;. &lt;code&gt;git&lt;/code&gt; can call up your favorite editor and fill out a message, but that seems more complicated, in my view.&lt;/p&gt;

&lt;p&gt;Up until now, we've only worked on the local repository inside your folder.  If you run &lt;code&gt;git status&lt;/code&gt; again, you should see an "up to date" message from &lt;code&gt;git&lt;/code&gt;. Now, it's time to turn our attention to &lt;code&gt;gitHub&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Go to &lt;code&gt;gitHub&lt;/code&gt;.com and sign up for an account if you haven't already. After you're logged in, you'll want to create a &lt;code&gt;gitHub&lt;/code&gt; repository.  The instructions for this can be googled.  Set up a new repo, add the README.md file, set a LICENSE file, and do whatever else seems appropriate to your use.  When you click that NEW button, &lt;code&gt;gitHub&lt;/code&gt; will require a reasonably unique name for your repository and it is the most important item. It won't let you get further without it.  I would also add, make it memorable and link-able to your local folder. Mine all generally match the folder name or project I'm working on.  Also, choose whether you want your &lt;code&gt;gitHub&lt;/code&gt; repo private or public. It makes no difference on use, so the choice is yours.&lt;/p&gt;

&lt;p&gt;Once your &lt;code&gt;gitHub&lt;/code&gt; repo is created and you're ready to continue, look at the middle of the repo page, just before you see your file list.  It'll look something like this:                                                    &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o1ApA0XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://tardis1.files.wordpress.com/2020/04/github_clone_button.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o1ApA0XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://tardis1.files.wordpress.com/2020/04/github_clone_button.png" alt="Github Clone Button Location"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That green button on the right is the one we want.  When you click that button (don't worry, we won't be making clones), it drops down a pop-up that gives you the direct URL for your &lt;code&gt;gitHub&lt;/code&gt; repo. This button is in the same place on every repo you create.&lt;/p&gt;

&lt;p&gt;The next steps will be done in our chosen folder. I'm still in my ncurses folder.  First, we'll add a &lt;code&gt;remote&lt;/code&gt; branch for our local &lt;code&gt;git&lt;/code&gt; repo.  Go to your &lt;code&gt;gitHub&lt;/code&gt; repo, click the 'Clone' button and copy all of the URL it shows you.  Then type the following command and paste your URL on the end:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git remote add ncurses https://github.com/githubusr/yurrepo.git&lt;/code&gt;             &lt;/p&gt;

&lt;p&gt;I put &lt;code&gt;ncurses&lt;/code&gt; as it is the folder name I'm working with, but this could be anything you wished to call it.  The default is either &lt;code&gt;origin&lt;/code&gt; or &lt;code&gt;master&lt;/code&gt;, I can't remember (exactly why I don't use the defaults).  By always using the folder name, you'll easily remember some of the commands you need below.&lt;/p&gt;

&lt;p&gt;There won't be any response other than a new prompt when you do this. If &lt;code&gt;git&lt;/code&gt; replies with anything, it will likely be an error.  By the way, you need to be connected to the Internet when doing these &lt;code&gt;gitHub&lt;/code&gt; related commands.&lt;/p&gt;

&lt;p&gt;To check to be sure it worked, type the following to see the URL you pasted into git:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git remote get-url --all ncurses&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Replace &lt;code&gt;ncurses&lt;/code&gt; with your folder's name used in the &lt;code&gt;git remote&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Because we added a &lt;code&gt;README.md&lt;/code&gt; file when we created our &lt;code&gt;gitHub&lt;/code&gt; repo, &lt;code&gt;git&lt;/code&gt; is going to have problems syncing up with our files in our folder.  In addition, if you are trying to sync up the &lt;code&gt;gitHub&lt;/code&gt; repo with a new &lt;code&gt;git repo&lt;/code&gt; (you got a new laptop, PC, drive, whatever), &lt;code&gt;git&lt;/code&gt; will also have a problem.  Before we sync our local repo with &lt;code&gt;gitHub&lt;/code&gt;, we &lt;code&gt;pull&lt;/code&gt; down everything in the remote (gitHub) repo and merge it with our local repo with the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git pull ncurses master --allow-unrelated-histories&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We set up the &lt;code&gt;ncurses&lt;/code&gt; remote name above with &lt;code&gt;git remote&lt;/code&gt;.  The &lt;code&gt;master&lt;/code&gt; branch is the default branch name on all of our &lt;code&gt;gitHub&lt;/code&gt; repos, but as long we we are in the appropriately set up folder/repo, &lt;code&gt;git&lt;/code&gt; will know what to do (mostly because we put &lt;code&gt;ncurses&lt;/code&gt; as the remote name).  The &lt;code&gt;--allow-unrelated-histories&lt;/code&gt; key is highly important.  It will get everything out of the remote (gitHub) repo and merge it with your local repo.  Do an &lt;code&gt;ls&lt;/code&gt; after running this command and you should see a &lt;code&gt;README.md&lt;/code&gt; file added to your folder. This command will open a new line asking for your &lt;code&gt;gitHub&lt;/code&gt; user name, followed by another new line asking for your &lt;code&gt;gitHub&lt;/code&gt; password before it completes the command.&lt;/p&gt;

&lt;p&gt;We'll only use &lt;code&gt;git pull&lt;/code&gt; at special times such as setting up a new &lt;code&gt;gitHub&lt;/code&gt; repo or getting things back down from &lt;code&gt;gitHub&lt;/code&gt; after something major happens (new folder, new drive, new PC, etc.).&lt;/p&gt;

&lt;p&gt;On a regular basis, after we've done a good &lt;code&gt;git commit&lt;/code&gt;, we'll use the following command to &lt;code&gt;push&lt;/code&gt; changes in our &lt;code&gt;commit&lt;/code&gt; up to the &lt;code&gt;gitHub&lt;/code&gt; repository:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ncurses&amp;gt;git push Cfiles master&lt;/code&gt;                                                          &lt;/p&gt;

&lt;p&gt;Again, you'll be required to enter your &lt;code&gt;gitHub&lt;/code&gt; user and password in order for the command to complete. When this step finishes, you should see all of your folder's files (in this case, my &lt;code&gt;ncurses&lt;/code&gt; folder) in the &lt;code&gt;gitHub&lt;/code&gt; repo you set up.  &lt;/p&gt;

&lt;p&gt;If you've gotten both your local &lt;code&gt;git&lt;/code&gt; repository working and &lt;code&gt;push&lt;/code&gt;-ed everything up to a &lt;code&gt;gitHub&lt;/code&gt; repository, then on a daily, weekly, whichever, basis, you need the following commands:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git status&lt;br&gt;
 git add *&lt;br&gt;
 git commit -m "with your message"&lt;br&gt;
 git push yourlocalname master&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There is one additional command you will need as time goes along:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git rm filename&lt;/code&gt;&lt;br&gt;
or:&lt;br&gt;
&lt;code&gt;git rm {file1,file2,file3,...}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you've deleted files from your folder, &lt;code&gt;git&lt;/code&gt; sees this.  It will show you the files you've deleted, but still exist in the repo with lines like &lt;code&gt;:deleted filename&lt;/code&gt; when you do a &lt;code&gt;git status&lt;/code&gt;.  &lt;code&gt;git rm&lt;/code&gt; will remove these from the repo and clean up your &lt;code&gt;commits&lt;/code&gt;. I've also found that it treats files you move to a sub-folder the same way.  It considers them deleted, yet, when you &lt;code&gt;git rm&lt;/code&gt; the deleted file, it straightens up the branch by now showing where you had moved the file (at least it did, today).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gitHub&lt;/code&gt; and &lt;code&gt;git&lt;/code&gt; are two robust tools for keeping your work backed up and well ordered.  While their use as version control tools has many facets I didn't cover today, these can be used as a minimum needed to get oneself started.  By keeping things to a single folder per &lt;code&gt;gitHub&lt;/code&gt; repo when using &lt;code&gt;git&lt;/code&gt; and &lt;code&gt;gitHub&lt;/code&gt;, it also simplifies the process, I believe. I've been using this method for about a month now and have had good success with it.  I would rate it higher than Google Drive or Dropbox because of it's orderly nature. I hope you will be successful as well. Let me know if it does, or ask questions if needed.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>SQL, strcat(), and more segmentation fault</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Thu, 02 Apr 2020 00:40:43 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/sql-strcat-and-more-segmentation-fault-2e83</link>
      <guid>https://forem.com/tardisgallifrey/sql-strcat-and-more-segmentation-fault-2e83</guid>
      <description>&lt;p&gt;Also known as: how to screw up a working program with &lt;code&gt;strcat()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I've been working on learning to use Microsoft SQL. The trending/archiving system at my job uses SQL to record machine data (HVAC) so that we can prepare reports for management and our accrediting surveyors.  Learning SQl has been helpful in helping me learn other programming languages because working toward a goal (making my SQL work without opening SQL) seems to motivate me to practice coding beyond just working on a tutorial.&lt;/p&gt;

&lt;p&gt;Most of what I've done lately is to find something to do in SQL and then work through how to do that in &lt;code&gt;Python&lt;/code&gt;, &lt;code&gt;perl&lt;/code&gt;, &lt;code&gt;nim&lt;/code&gt;, and &lt;code&gt;C&lt;/code&gt;.  Yes, I saved &lt;code&gt;C&lt;/code&gt; for last.&lt;/p&gt;

&lt;p&gt;Connecting with SQL databases and engines in the other languages was fairly straight forward, and not too difficult. However, when I got to &lt;code&gt;C&lt;/code&gt;, things changed drastically.  The only complete description of interfacing UnixODBC (what is needed to connect to SQL) with &lt;code&gt;C&lt;/code&gt; is from a website called easySoft.com. I'll put a link below if you are interested.&lt;/p&gt;

&lt;p&gt;This site, while complete with all one needs to use &lt;code&gt;C&lt;/code&gt; in order to connect to SQL, left a lot to be desired in clarity.  However, after a couple of days and an evening of frustration, I finally got their basic connection program to work.  &lt;/p&gt;

&lt;p&gt;While I was happy to get that far, there was a lot more to do.  The first thing I needed to expand upon was a way to get connection information from the command line, format it correctly, and shove all that into the SQL connection function. Shouldn't be too difficult, right?  I know &lt;code&gt;C&lt;/code&gt;, right?&lt;/p&gt;

&lt;p&gt;Wrong.&lt;/p&gt;

&lt;p&gt;I knew the tool I needed was something to concatenate argument strings into the complete connection string. In &lt;code&gt;Python&lt;/code&gt;, we just use &lt;code&gt;'+'&lt;/code&gt; as in &lt;code&gt;str1 + str2&lt;/code&gt;.  No problem.  In &lt;code&gt;perl&lt;/code&gt;, we have dot notation as in &lt;code&gt;str1 . str2&lt;/code&gt;.  No biggy.  &lt;code&gt;Nim&lt;/code&gt;?  Simple, use &lt;code&gt;str1 &amp;amp; str2&lt;/code&gt;.  &lt;code&gt;C&lt;/code&gt;? Well....&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C&lt;/code&gt; doesn't have a concatenation operator.  But, it does have a handy-dandy group of string utilities available when one puts this at the top of their program: &lt;code&gt;#include &amp;lt;string.h&amp;gt;&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;This allows the programmer to use &lt;code&gt;strcat()&lt;/code&gt;, a function that appends a source string (it is supposed to be a constant, but that seems fluid) to a destination string pointer then returns the new string to a result string pointer. And, there goes the neighborhood.&lt;/p&gt;

&lt;p&gt;Each of the items in the &lt;code&gt;strcat()&lt;/code&gt; statement have to abide by typing rules (which I am not complaining about, just pointing out it is difficult to remember them all).  C is considered strongly typed and gcc enjoys reminding the programmer at every opportunity.&lt;/p&gt;

&lt;p&gt;So the correct format to make &lt;code&gt;strcat()&lt;/code&gt; work is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*result=strcat( destination, source);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Where &lt;code&gt;result&lt;/code&gt; and &lt;code&gt;destination&lt;/code&gt; are definitely pointers; &lt;code&gt;source&lt;/code&gt; should be a &lt;code&gt;constant char&lt;/code&gt; array, but I have used a &lt;code&gt;char&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;As part of my frustration, I'm also trying to do this in the middle of a finicky SQL routine. I made progress after I got out of the SQL routine and just ran several mini-programs with just &lt;code&gt;strcat()&lt;/code&gt; working in order to remove extraneous errors from the compiler.&lt;/p&gt;

&lt;p&gt;So, to set up the final script, I had to create an exact copy of the following string that would go into my SQL connect function:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"DSN=mydsn_name;UID=sa;PWD=password"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Unless your really interested in going down the rabbit hole of SQL, just note that each of these has meaning to the connection function. A &lt;code&gt;DSN&lt;/code&gt; is a Data Source Name; a specification of how to connect to an SQL instance (engine I call them).  &lt;code&gt;UID&lt;/code&gt; is a user name; &lt;code&gt;sa&lt;/code&gt; being the system administrator (usually this isn't used, but I'm just testing).  &lt;code&gt;PWD&lt;/code&gt; is the correct password to go with the username.&lt;/p&gt;

&lt;p&gt;What I want to do is run it like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$&amp;gt;sqlconnect mydsn_name sa password&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And, hopefully, ODBC will respond with a nice little connect as my reward.  However, to get there, this is how it looks:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;char *dsn=malloc( sizeof(char) * 100 );&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;char  dsnstring[100]="DSN=";&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;char  uidstring[100]="UID=";&lt;/code&gt;&lt;br&gt;
   &lt;code&gt;char  pwdstring[100]="PWD=";&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsnstring,argv[1]);&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,";");&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,uidstring);&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,argv[2]);&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,";");&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,pwdstring);&lt;/code&gt;&lt;br&gt;
         &lt;code&gt;dsn=strcat(dsn,argv[3]);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;argv[x]&lt;/code&gt; are the command line argument strings.  You get them when you open your &lt;code&gt;main()&lt;/code&gt; function as follows (and, yes, I screw it up often):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int main(int argc, char *argv[])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;argc&lt;/code&gt; is an &lt;code&gt;int&lt;/code&gt;(eger) variable that will hold the number of command line arguments.  &lt;code&gt;*argv[]&lt;/code&gt; is a pointer to a number of arrays of &lt;code&gt;char&lt;/code&gt;(acter) type.  &lt;code&gt;argv[0]&lt;/code&gt; is the filename that you used to start the command with (in our case &lt;code&gt;argv[0]="sqlconnect"&lt;/code&gt;.  Therefore, &lt;code&gt;argv[1]&lt;/code&gt; gets the &lt;code&gt;DSN&lt;/code&gt; we entered, and you go on from there.&lt;/p&gt;

&lt;p&gt;I used &lt;code&gt;malloc()&lt;/code&gt; to initialize my main variable (&lt;code&gt;dsn&lt;/code&gt;) to a 100 character array, but empty. Technically, I reserved a memory space assigned to the pointer &lt;code&gt;dsn&lt;/code&gt;. &lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/code&gt; is needed to make it work. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;dsnstring&lt;/code&gt;, &lt;code&gt;uidstring&lt;/code&gt;, and &lt;code&gt;pwdstring&lt;/code&gt; CANNOT be pointers to strings in the usual sense. I know--a character array is theoretically the same, but &lt;code&gt;gcc&lt;/code&gt; does know the difference. So, yes, &lt;code&gt;*dsnstring&lt;/code&gt; is out. I believe it has to do with the destination and result need to have room for appending characters and be the same length, but I haven't tested it; yet. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Strcat()&lt;/code&gt; will quietly not tell you anything (except &lt;code&gt;segmentation fault&lt;/code&gt;) if your destination pointer has no room.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dsn=strcat(dsnstring,argv[1])&lt;/code&gt; works like this:&lt;/p&gt;

&lt;p&gt;Take a copy of what the &lt;code&gt;dsnstring&lt;/code&gt; is pointing to and append the contents of &lt;code&gt;argv[1]&lt;/code&gt; to that, then return the new string to the what &lt;code&gt;dsn&lt;/code&gt; is pointing at (the 100 char memory allocation).  At least, that is what I've deduced it does.  Wash, rinse, and repeat with the next string needing to be appended.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dsn=strcat(dsn,";")&lt;/code&gt; looks like it should fail, correct?  It doesn't.  Because &lt;code&gt;strcat()&lt;/code&gt; takes a copy of &lt;code&gt;dsn&lt;/code&gt;, adds the semicolon and then RETURNS that to the original location, this construct is legal (and tested, but not thoroughly).  Doing it like this, definitely provides cleaner code and a simpler method. Well, simpler for &lt;code&gt;C&lt;/code&gt; anyway.&lt;/p&gt;

&lt;p&gt;I used this method and ran the SQL connection program several times today.  Worked every time.  &lt;/p&gt;

&lt;p&gt;This method of using strcat() has many uses outside of this one instance.  This is a good way to get command line arguments processed, building result strings from collections of words, or any time that there are multitudes of things to stick together.  However, I do recommend doing this in isolation without the rest of your program along to muddy the waters. Additionally, be ready to trial and error your findings and build from one working strcat() to the next.  Code with patience, Padawan (and that means me).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.easysoft.com/developer/languages/c/odbc_tutorial.html"&gt;Link to the easySoft site with ODBC and C instructions&lt;/a&gt;&lt;/p&gt;

</description>
      <category>c</category>
      <category>sql</category>
      <category>beginners</category>
      <category>odbc</category>
    </item>
    <item>
      <title>COVID-19 increased my time for learning</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 29 Mar 2020 22:30:26 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/covid-19-increased-my-time-for-learning-193</link>
      <guid>https://forem.com/tardisgallifrey/covid-19-increased-my-time-for-learning-193</guid>
      <description>&lt;p&gt;A pandemic is certainly not a blessing, but with the extra isolation, and poor weather, I've had much more time to spend learning the things I want.&lt;/p&gt;

&lt;p&gt;While I do go to work during the week (I work for a hospital), the requirement for social distancing gives me much more weekend time to sit down with my laptop and get to work.  Believe it or not, this kind of work is therapeutic...to me at least.&lt;/p&gt;

&lt;p&gt;My job gives me plenty of time to work on technology, but it's very narrow.  I'm a stationary engineer for my hospital and I handle the bulk of the automation/controls/programming duties.  Yet, none of these are in the Open Source kind of technologies in which I would like to become fluent.&lt;/p&gt;

&lt;p&gt;Just a few years ago, I took a good look at my future life (I turn 60 in May), and decided I didn't want to sit around and wait until I "had time" for things I wanted to learn and do.  So, I made myself some goals to diligently begin working towards fluently learning C, C++, perl, and python.  Recently, I've added nim to that list as well.&lt;/p&gt;

&lt;p&gt;The past couple of weekends staying at home, but not being a couch potato, has given me time to really crank out some practice.  In the process, I've spent a good deal of time on my chosen goals as well as getting Microsoft SQL for Linux back onto my laptop.  Doing this helps because I'm the world's worst at trying to learn something in isolation.  I need a goal to work towards.  Having MSSQL to work on makes me look up the things beyond tutorials that I need to interact with databases in SQL.  In addition, this helps my work as our data archiving engine uses MSSQL for storing trends of our data points (Currently, just over 1,000 discrete values being recorded).  I REALLY need to know how SQL works and how to interact with it using scripting tools like perl and/or python.&lt;/p&gt;

&lt;p&gt;A secondary goal of mine is to work on my writing. I do write fiction, but I would rather write all day long about things that really interest me, especially if that helps another person learn something.&lt;/p&gt;

&lt;p&gt;This weekend's work has given me several ideas for posts on DEV that I intend to begin working upon, such as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;How to get Microsoft SQL for Linux installed and set up for use with perl and python (still working on how to do it with nim).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to reduce what one needs to use git and github to maintain personal repositories of code from your command line (no need to visit github.com once everything works).  I've usually found the plethora of git commands overwhelming.  I finally reduced it down to just those I need.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modules in perl and python both seem to have problems with running and retrieving output from MSSQL stored procedures (which are quite handy, I might add).  I've got a work-around using the ability to give a system command and have the output go into an array or string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Posts on using Bash to script SQLCMD tasks for things such as database backups, restores, creating those nice stored procedures, and other things.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While I would certainly enjoy seeing this bit of isolation come to an end soon, I'll just take what I'm given and adapt.  The slowdown has given me much more time to spend learning some of my favorite things and also helps me to not spend time worrying about things I can't fix anyway.  Take care.  Be back laters.&lt;/p&gt;

</description>
      <category>covid19</category>
      <category>mssql</category>
      <category>scripting</category>
      <category>writing</category>
    </item>
    <item>
      <title>Thoughts on Raspberry Pi GPIO Program Organization</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 22 Mar 2020 20:14:39 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/thoughts-on-raspberry-pi-gpio-program-organization-4kpf</link>
      <guid>https://forem.com/tardisgallifrey/thoughts-on-raspberry-pi-gpio-program-organization-4kpf</guid>
      <description>&lt;p&gt;As I sit here performing my continuing education so that I can keep my standing as a master electrician, I thought I'd write a little bit of philosophy on organizing a program to operate, read, or manipulate real world devices through the GPIO pins (General Purpose Input Output) of a Raspberry Pi.&lt;/p&gt;

&lt;p&gt;In my work, I do a lot of controls involving computer operated systems to govern air-conditioning and heating systems of large facilities, specifically hospitals.  These systems go by such names as building automation/management systems (BAS, BMS) or energy management systems (EMS).  In addition, I have also done work with computer controls often found in facilities, factories,and industrial sites.  These are usually called programmable logic controllers (PLC). Many of these systems now connect via Ethernet/TCPIP networks and communicate with webservers and application servers.&lt;/p&gt;

&lt;p&gt;Therefore, when I look at a Raspberry Pi used to control real world devices (lights, relays, etc.), I don't see a single board computer, I see a controller.  A controller is a device that accepts input, gives output, and uses a control program to perform a task or purpose.&lt;/p&gt;

&lt;p&gt;How then do industrial controllers (my term) organize their control programs in order to keep things all going correctly.  The following is a system that I've seen on many controllers.  It is a logical progression that controls activity so that no one control statement (piece of code) or I/O command can cause bad effects in the real world.&lt;/p&gt;

&lt;p&gt;However, before we look at that organization, I need for us to learn at least one definition: a point.  In the parlance of my field, a point is a discrete amount of data connected to an input or output, but can also be an intermediate value or data point.  Points can be inputs (binary or analog), outputs (binary or analog), or variables/values (place holders or references like setpoints).&lt;/p&gt;

&lt;p&gt;With that out of the way, let's look at a standard controller operational model:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Upon power up, initialize all points (names, descriptors, types, ranges, etc.) to their default state (on for some, off for others, etc.).&lt;/li&gt;
&lt;li&gt;Start a watchdog or program timer.  Running to the end of this timer will often cause the supervisory program to stop the program, put points into safe states, and issue an operator warning.&lt;/li&gt;
&lt;li&gt;Start working through the statements and functions in the control program.  In some controllers, there are multiple programs and the program counter steps from start to finish on each program until it reaches the end.&lt;/li&gt;
&lt;li&gt;Once complete with stepping through the logic of the program(s), the controller collects the final disposition for all outputs.  No output changes state while the program(s) are being scanned.  All outputs will change state at the end of the last control program.  The reason that a controller would wait until the program(s) has completed scanning rather than immediate output changes is because different programs or control statements in the programs may change the output state of a point multiple times as it passes through all the program logic.  This could cause bad effects to equipment if it is allowed to start and stop in milliseconds (sometimes) during the program.  The state of the output after the last line of program code determines the final output state.&lt;/li&gt;
&lt;li&gt;Command all outputs and read all inputs (though input scanning can take place higher in the order).&lt;/li&gt;
&lt;li&gt;Rinse, wash, repeat and do it all over again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whether you as a programmer writing code for a Raspberry Pi need this level of organization is up to your own judgment.  Very simple projects might not, but I like to consider that a computer with the computing horsepower of a Pi should be considered for larger scale functions. Any time the job is large or if we are going to drive real world devices (fans, compressors, motors, heaters) where safety is important, we should consider the organization of our programs as equally important as the individual logic for individual pins.  &lt;/p&gt;

&lt;p&gt;Since I am new to Raspberry Pi programming, I would like to hear from others in their experience of writing code for the Raspberry Pi in the real world. Do you organize your control programs similar to this method?  Are you more immediate in reads and writes of GPIO pins?  I'd like to know.  Thanks for listening.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>process</category>
      <category>methodology</category>
    </item>
    <item>
      <title>Raspberry Pi GPIO 4 Ways</title>
      <dc:creator>Dave</dc:creator>
      <pubDate>Sun, 22 Mar 2020 15:24:02 +0000</pubDate>
      <link>https://forem.com/tardisgallifrey/raspberry-pi-gpio-4-ways-45do</link>
      <guid>https://forem.com/tardisgallifrey/raspberry-pi-gpio-4-ways-45do</guid>
      <description>&lt;p&gt;I've been practicing recently with GPIO on my Raspberry Pi 4.  My journey to controller nirvana hasn't been as easy as advertised as I chose to use &lt;a href="https://ubuntu.com/download/raspberry-pi"&gt;Ubuntu server for Pi&lt;/a&gt; instead of &lt;a href="https://www.raspberrypi.org/downloads/"&gt;Raspbian&lt;/a&gt;.  I've found it very difficult to add the python GPIO module.  Yet, I haven't given up.  With some interwebbing, I've discovered that that little module isn't needed and one doesn't have to use python to control GPIO pins.&lt;/p&gt;

&lt;p&gt;Automatically set up upon starting the Pi, even with Ubuntu is the &lt;code&gt;sysfs&lt;/code&gt; system.  This is similar to the &lt;code&gt;procfs&lt;/code&gt; system that some are familiar with using.  There is a &lt;code&gt;/cpuinfo&lt;/code&gt; file in the &lt;code&gt;procfs&lt;/code&gt; system one can read to determine machine specific data. Most of the &lt;code&gt;sysfs&lt;/code&gt; system can be identified because they are the &lt;code&gt;/sys/class/&lt;/code&gt; folders in the file system.&lt;/p&gt;

&lt;p&gt;This collection of folders and files, when properly set up, can be used to programmatically control GPIO pins on the Raspberry Pi with any programming language that supports file I/O.  In this example (this is not a tutorial, folks), I am going to show the simple flow of what one does to control GPIO pins in &lt;code&gt;C&lt;/code&gt;, &lt;code&gt;C++&lt;/code&gt;, &lt;code&gt;nim&lt;/code&gt;, and even &lt;code&gt;python&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are two articles I used to help figure all this out.  I'll put links to each at the end of the article.  My &lt;code&gt;C&lt;/code&gt; code is the same as the Auctoris link.&lt;/p&gt;

&lt;p&gt;First, we'll step through the things that have to be done to set up GPIO for use, set the direction of a pin, and either turn on or turn off a pin.  I'll be using pin 4 in my examples, but any of the general purpose pins will work.  For the SPI, one-wire, and other analog or bus type pins, you'll need to do some research on how these work through &lt;code&gt;sysfs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The steps are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up GPIO pin for use. Write &lt;code&gt;"4"&lt;/code&gt; into the export file at &lt;code&gt;/sys/class/gpio/export&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Establish pin as input or output. Write &lt;code&gt;"out"&lt;/code&gt; or &lt;code&gt;"in"&lt;/code&gt; at &lt;code&gt;/sys/class/gpio/gpio4/direction&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Finally, turn pin on or off.  Write &lt;code&gt;"1"&lt;/code&gt; or &lt;code&gt;"0"&lt;/code&gt; at &lt;code&gt;/sys/class/gpio/gpio4/value&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before we get to the code section, a few caveats. All of what you write to the &lt;code&gt;sysfs&lt;/code&gt; files are strings. Don't confuse &lt;code&gt;"4"&lt;/code&gt; with &lt;code&gt;4&lt;/code&gt;.  If you alternate writing the &lt;code&gt;"4"&lt;/code&gt; to both the &lt;code&gt;export&lt;/code&gt; and &lt;code&gt;unexport&lt;/code&gt; files, you will see the &lt;code&gt;gpio4&lt;/code&gt; folder appear and disappear when &lt;code&gt;ls&lt;/code&gt;-ing the folder list.  That is what is meant by setting up the pin. Without doing so, you won't have files where you can write 1's or 0's. Also, all of these files are owned by &lt;code&gt;root&lt;/code&gt;.  You must be &lt;code&gt;root&lt;/code&gt; or use &lt;code&gt;sudo&lt;/code&gt; when running your executable file or you will get errors.&lt;/p&gt;

&lt;p&gt;A little side note. According to what I've read, it is correct procedure to &lt;code&gt;unexport&lt;/code&gt; your pin set ups after you are through with them.  This is probably good information; yet, I figure most real world applications will be in continuous use. Use your judgment as to whether this step is necessary or not.  From my observation, when I power down the Pi, &lt;code&gt;export&lt;/code&gt; settings are lost anyway.  GPIO pin set up must be done again upon start up.&lt;/p&gt;

&lt;p&gt;Without any more delay, let's get to our code.  First up is the &lt;code&gt;C&lt;/code&gt; code from the Auctoris post.  He was very worried about buffer overwrites in the &lt;code&gt;sysfs&lt;/code&gt; files.  That is why he is using write methods that specify how many characters write to the files.  While I believe that is good practice, I don't have enough facility in the other languages to mimic that operation.&lt;/p&gt;

&lt;p&gt;File: &lt;code&gt;gpio.c&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt; 

int main(){
FILE *sysfs_handle = NULL;           
        sysfs_handle = fopen("/sys/class/gpio/export", "w");
        if (sysfs_handle != NULL){
                fwrite("4", sizeof(char), 2, sysfs_handle);
                printf("\nGPIO 4 opened for EXPORT\n");
                fclose(sysfs_handle);       
        }
        else
        {
 printf("\nCan't open gpio/export.  Something went wrong. Are you root?\n");

        }
        sysfs_handle = fopen("/sys/class/gpio/gpio4/direction", "w" );
        if (sysfs_handle != NULL){

                fwrite("out", sizeof(char), 4, sysfs_handle);
                printf("\nGPIO 4 assigned to be an output.\n");
                fclose(sysfs_handle);
        }
        else
        {
                printf("\nCan't open gpio/direction.  Something went wrong. Are  you root?\n");
        }
sysfs_handle = fopen("/sys/class/gpio/gpio4/value", "w");
        if (sysfs_handle != NULL){
                fwrite("out", sizeof(char), 4, sysfs_handle);
                printf("\nGPIO 4 assigned to be an output.\n");
                fclose(sysfs_handle);
        }
        else
        {
 printf("\nCan't open gpio/direction.  Something went wrong. Are  you root?\n");

        }
        sysfs_handle = fopen("/sys/class/gpio/gpio4/value", "w");

        if (sysfs_handle != NULL){
                fwrite("1", sizeof(char), 2, sysfs_handle);
                printf("\nGPIO 4 given an ON command.\n");
                fclose(sysfs_handle);
        }
        else
        {

                printf("\nCan't open gpio/value. Something went wrong. Are you root?\n");

        }
return 0;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above code should compile with &lt;code&gt;gcc gpio.c&lt;/code&gt; (assuming you named your source that way, you don't have to do so).  After a successful compile, you would run the &lt;code&gt;a.out&lt;/code&gt; executable with &lt;code&gt;sudo ./a.out&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The following code is for &lt;code&gt;C++&lt;/code&gt;.  In all of these examples, I stuck with the file object (pointer, whatever) method to match up with Auctoris' example.&lt;/p&gt;

&lt;p&gt;File: &lt;code&gt;gpio.cpp&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;          
using namespace std;   

int main () {

fstream sysfs_handle;                                  

sysfs_handle.open ("/sys/class/gpio/export", ios::out);        

if( sysfs_handle.is_open()){
   sysfs_handle&amp;lt;&amp;lt;"4";   
   cout&amp;lt;&amp;lt;"\nGPIO 4 opened for EXPORT.\n";
   sysfs_handle.close();                                
   }else{
       cout&amp;lt;&amp;lt;"\nCan't open gpio/export.  Are you root?\n";
   }

sysfs_handle.open ("/sys/class/gpio4/direction", ios::out);     

if( sysfs_handle.is_open()){
   sysfs_handle&amp;lt;&amp;lt;"out";         
   cout&amp;lt;&amp;lt;"\nGPIO 4 opened as output pin.\n";
   sysfs_handle.close();                           
   }else{
       cout&amp;lt;&amp;lt;"\nCan't open gpio4/direction.  Are you root?\n";
   }

sysfs_handle.open ("/sys/class/gpio/export", ios::out);    

if( sysfs_handle.is_open()){
   sysfs_handle&amp;lt;&amp;lt;"1"; 
   cout&amp;lt;&amp;lt;"\nGPIO 4 turned ON.\n";
   sysfs_handle.close();
   }else{
       cout&amp;lt;&amp;lt;"\nCan't open gpio/export.  Are you root?\n";
   }

  return 0;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;C++&lt;/code&gt; code should compile with &lt;code&gt;g++ gpio.cpp&lt;/code&gt; and you should be able to run the resultant a.out file the same as you did with &lt;code&gt;C&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, let's get to the &lt;code&gt;nim&lt;/code&gt; version.  I've been studying &lt;code&gt;nim&lt;/code&gt; for a little while.  I've only made some headway in that regard.  I had to do a lot of searching to work the file I/O operations.  My observation of &lt;code&gt;nim&lt;/code&gt; is that there are several methods to accomplish file I/O.  I've chosen what is closest to what I've already written above in &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;C++&lt;/code&gt;.  &lt;code&gt;nim&lt;/code&gt; is available in the Ubuntu Raspberry Pi repository.  One word of warning.  Do not use tabs in nim.  It doesn't like that and will give you some error about tabulators not allowed.  Took quite a bit to figure out that meaning.&lt;/p&gt;

&lt;p&gt;File: &lt;code&gt;gpio.nim&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var sysfs_handle: File

if open( sysfs_handle, "/sys/class/gpio/export", fmWrite):

     sysfs_handle.writeLine("4")
     echo "GPIO export set."

else:
     echo "Problem opening File, are you root?"

sysfs_handle.close()

if open( sysfs_handle, "/sys/class/gpio/gpio4/direction", fmWrite):

     sysfs_handle.writeLine("out")
     echo "GPIO pin 4 assigned to be an output."

else:

     echo "Problem opening file. Are you root?"

sysfs_handle.close()


if open( sysfs_handle, "/sys/class/gpio/gpio4/value", fmWrite):

     sysfs_handle.writeLine("1")
     echo "GPIO pin 4 turned on."

else:

     echo "problem opening file, are you root?"

sysfs_handle.close()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You could compile the above code with &lt;code&gt;nim compile gpio.nim&lt;/code&gt; and if you needed debugging, that is the method to choose.  One of the weaknesses I see in &lt;code&gt;nim&lt;/code&gt; is the size of the executable.  &lt;code&gt;nim&lt;/code&gt; outputs &lt;code&gt;C&lt;/code&gt; code and then compiles that, so the resulting executables are much larger than expected.  I'd recommend &lt;code&gt;nim compile -d:release gpio.nim&lt;/code&gt; in order to remove the debugging info from your executable.  It reduces the size significantly.&lt;/p&gt;

&lt;p&gt;Just a side note before moving on: this is not a &lt;code&gt;nim&lt;/code&gt; tutorial.  If you wish for me to write one (because the ones I've found can be confusing, save one), let me know in the comments below and I'll try to do one as I go along learning &lt;code&gt;nim&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, yes, you can still program in &lt;code&gt;python&lt;/code&gt; and use the &lt;code&gt;sysfs&lt;/code&gt; system.  The following code is just that, for grins and giggles.  It is in &lt;code&gt;python3&lt;/code&gt;, which is standard on Ubuntu Raspberry.  If you wish to use &lt;code&gt;python 2.xx&lt;/code&gt;, you'll have to install it from the repository.  It is there.&lt;/p&gt;

&lt;p&gt;File: &lt;code&gt;gpio.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/python3

sysfs_handle = open("/sys/class/gpio/export", "w", 2)

if (sysfs_handle):
     sysfs_handle.write("4")
     print("GPIO 4 opened for EXPORT")

else:

     print("Can't open gpio/export.  Something went wrong. Are you root?")

sysfs_handle = open("/sys/class/gpio/gpio4/direction", "w")

if(sysfs_handle):
     sysfs_handle.write("out")
     print("GPIO pin 4 set as output")

else:

     print("Can't open gpio/direction. Are you root?")

sysfs_handle = open("/sys/class/gpio/gpio4/value", "w")

if(sysfs_handle):
     sysfs_handle.write("1")
     print("GPIO pin 4 is ON")

else:

    print("Can't open gpio4/value. Are you root?")

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All that is required to make &lt;code&gt;gpio.py&lt;/code&gt; executable is &lt;code&gt;chmod +x gpio.py&lt;/code&gt;.  Don't forget to run as root.&lt;/p&gt;

&lt;p&gt;To wrap things up, it is not necessary to use Raspbian on your Raspberry Pi if you would rather use one of the other OS's.  You are not tied to the &lt;code&gt;python&lt;/code&gt; language and it's GPIO module if you would prefer to use another language.  The &lt;code&gt;sysfs&lt;/code&gt; file system in there for your use and will do an adequate job.  These are example source files on the process of using &lt;code&gt;sysfs&lt;/code&gt; to set up and command or read GPIO pins on the Pi.  Your next steps would be to write a library of functions that make setting up pins and commanding them easier to do as a programmer.  Yes, it is more work, but we like programming right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.auctoris.co.uk/2012/07/19/gpio-with-sysfs-on-a-raspberry-pi/"&gt;Link to Auctoris article, one of two.&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.bigmessowires.com/2018/05/26/raspberry-pi-gpio-programming-in-c/"&gt;Link to sysfs use on Big Mess'O'Wires.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>c</category>
      <category>cpp</category>
      <category>nim</category>
    </item>
  </channel>
</rss>
