background preloader

C Programming

Facebook Twitter

CRC Series, Part 2: CRC Mathematics and Theory. Checksum algorithms based solely on addition are easy to implement and can be executed efficiently on any microcontroller.

CRC Series, Part 2: CRC Mathematics and Theory

However, many common types of transmission errors cannot be detected when such simple checksums are used. This article describes a stronger type of checksum, commonly known as a CRC. A cyclic redundancy check (CRC) is based on division instead of addition. The error detection capabilities of a CRC make it a much stronger checksum and, therefore, often worth the price of additional computational complexity. Blog - Automatisiertes Testing von C++ Code mit Frameworks – Teil 2. Google Mock Wie der Name bereits vermuten lässt, ist Google Mock ein Mock-Framework.

Blog - Automatisiertes Testing von C++ Code mit Frameworks – Teil 2

Mit Hilfe des Frameworks kann leicht überprüft werden, ob Funktionen wie erwartet aufgerufen und definiert werden, was eine noch zu implementierende Funktion zurückgeben soll. Integration und Build funktionieren analog zu dem bereits vorgestellten Framework Google Test. Hierbei sind verschiedene Arten von Tests zu unterscheiden. Als Beispiele seien Unit-Tests zum Testen einer Komponente oder Integration-Tests, die das Zusammenspiel mehrerer Komponenten prüfen, genannt.

Allgemeines. Eranpeer/FakeIt: C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking. How to generate JSON in C++ Boost ASIO Simple UDP Send Packet Example. Boost.ASIO is great but if you don’t use it everyday it can be hard to remember how to use it to do even the simplest of things.

Boost ASIO Simple UDP Send Packet Example

I have included below a sample of simply sending a packet via UDP (ipv4), see the function called send_message(), this example code aims to be as minimal as it can be: Those spouting software engineering dogma will often tell you to steer well clear of UDP for the usual, well understood reasons, but for a certain type of application where very low latency is important, it just can’t be beat!! This is the bare-bones code, no error reporting etc. Also it won’t broadcast, to allow for broadcast you need to include the following two lines and supply a broadcast ip address when calling the function. Be careful if broadcasting a lot of data as it can really overload & mess-up network equipment!

Socket_base::broadcast option(true); socket.set_option(option); Starting Unit Testing in C++ guide - Guriy Samarin - Medium. What if you have the Visual Studio C++ project and you want to add some unit tests in it?

Starting Unit Testing in C++ guide - Guriy Samarin - Medium

Visual Studio (starting from 2017) includes C++ unit test frameworks with no additional downloads. But I ran into some problems trying to make use of these frameworks. Rapidjson/simplewriter.cpp at master · Tencent/rapidjson. Event Handling in Native C++ Butcherg/DatagramSocket: C++ class for simply doing UDP from Windows or Unix. A Simple Timer in C++ Some languages, such as JavaScript or Visual Basic, offer the feature of a timer, that is to say an object that calls some code at defined intervals.

A Simple Timer in C++

At the time of this writing (C++17) and to my knowledge, C++ doesn’t offer such a feature. A library called timercpp, that replicates in C++ this handy functionality of other languages, was on the front page of HN. It has a nice interface that allows for expressive code, however I don’t think it is quite ready for being used in production. If it is not production-ready, why talk about it then? For two reasons: its implementation is instructive to learn about C++ standard library’s basic usages of threads,the reasons why it should maybe not be used in production are also instructive. I learned several things when looking at this library and the discussion around it, so I figured maybe other people could find this instructive too. timercpp uses an interface inspired from JavaScript, by implementing a setTimeout and a setInterval functions. Marc If you are new to using Visual Studio for C++ development a great starting point is our quick guide to Getting Started with Visual Studio.

In this blog post we will dive into the Linux Development with C++ workload. You will learn. Using Libraries in C++ (Static Linking) Visual Studio & Linux Development with C++ - Onur Dündar - Medium. I want to utilize Visual Studio more and more, because there is no CLion community edition yet.

Visual Studio & Linux Development with C++ - Onur Dündar - Medium

I have collected some good hardware and made a desktop PC, but I don’t like dual boot so I stick on Windows 10 only environment but I need to use Linux build tools time to time so I wanted to create a tutorial which I can use later on to setup my development environment easily with Visual Studio and Linux Build server when needed. First, I have downloaded Visual Studio Community edition from below URL: Then, I installed required tools as well as Linux C++ development toolset for Visual Studio. Linux Development with C++ module should be downloaded and installed. If you already have Visual Studio on your machine, just run Visual Studio Installer and click on modify button: Ok, let’s proceed creating a build server in next part.

In order to use Linux machine for build and debug, we need to install compilers, libraries and GDB server. Using WiringPi library with Raspberry PI cross-compiler – VisualGDB Tutorials. This tutorial shows how to develop a blinking LED project for Raspberry Pi in Visual Studio using the WiringPi library and our cross-toolchain.

Using WiringPi library with Raspberry PI cross-compiler – VisualGDB Tutorials

Before we begin, ensure that VisualGDB 4.0 or later is installed. If you do not have a LED prepared to connect to the expansion connector on the Raspberry Pi, please follow the steps 1-8 of our other blinking LED tutorial to prepare and connect a LED.Now create a basic Raspberry Pi cross-compilation project with VisualGDB by following this tutorial. Use the root account as the user account, as only root has direct access to hardware resources.

If you don’t know the root password, login as the normal user, run ‘sudo su’ and then ‘passwd’ from the su shell to set it. Packages Search - Reference. Adding dependencies to visual studio program. RapidJSON: Tutorial. This tutorial introduces the basics of the Document Object Model(DOM) API.

RapidJSON: Tutorial

As shown in Usage at a glance, JSON can be parsed into a DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. Each JSON value is stored in a type called Value. A Document, representing the DOM, contains the root Value of the DOM tree. All public types and functions of RapidJSON are defined in the rapidjson namespace. In this section, we will use excerpt of example/tutorial/tutorial.cpp. ESJ: Extremely Simple JSON for C++ Download - 377.4 KB Introduction ESJ is a JSON mapper for C++ with modest compiler requirements (No C++11) and zero reliance on 3rd party libraries.

ESJ: Extremely Simple JSON for C++

It is a very light-weight, easy to use system for inter-operating with web and database services. ESJ can be quickly added to existing code thus generating robust and well-formed JSON data. JSON (Javascript Object Notation) has become the format of choice for Web based data exchange. Less obviously perhaps, JSON is also very useful for persistent storage in suitably enabled databases.

Possibly more unusually, the code has been deployed in embedded environments (via mbed on Freescale ARM Cortex-M4 K64F parts), greatly simplifying Web-socket data exchange for 'Internet of Things' devices. The attached ZIP file includes projects for Visual Studio (2012) and XCode (Clang). Practical C++ Sockets. This library was developed for pedagogical use and is not suitable for production applications.

This library is currently in development and is subject to fundamental change at any time. Use at your own risk. This project is very much a work in progress so if you have any comments or suggestions on the current code, please send email to Map - Simple dictionary in C++ Map - Simple dictionary in C++ Learn C++ Multi-Threading in 5 Minutes - By Ari Saif. Technology breaks sometimes. We apologize for the inconvenience, and hope to improve whatever path led you here.

You can visit the homepage to find some interesting tech stories about cryptocurrency, software, blockchain, startups, futurism and more. If you’re looking to communicate with people beyond this 404 ether, you can also start writing or meet the community. Hacker Noon is reachable via for any feedback, concerns or ideas. C++11 Multithreading – Part 1 : Three Different ways to Create Threads – Basics of multithreading in C. C is a language that runs on one thread by default, which means that the code will only run one instruction at a time. In some cases you'll need to do multiple instructions at a time, a graphical interface for instance, will not stop when it performs an action related to a button's click. That's what we call multithreading, not to be confused with asynchronous operations that can be performed in only one thread that does multiple tasks.

How to Implement Periodic Timer in Linux? - QnA Plus. As a programmer we often need to do some task repeatedly after some time interval. We can think of a simple loop containing a function call to do the task followed by a sleep() call to wait for some time. This seems to be very simple solution but what if we don’t want to sit ideal while waiting.

We want to do other tasks while someone else keeps track of the timeout and wakes me up when timeout occurs and continue to track time for the next timeout. We can do the required timeout task after getting the timeout signal.