marcelpetrick

Qt: clean includes

Written by  on May 20, 2019

(I’ve decided to follow a more agile workflow: instead of creation a “one post covers the whole topic”-post, to post also updates for each step. Article will be therefore edited while “doing”)

Last week I’ve cleaned Qt-includes for a larger project. Like #include to #include how it should be. With proper indirection, so that the Qt-library handles how and where the class is implemented.
A colleauge raised the question, why not use #include to be even more precise and to see the used module directly (needed for the CMakeLists or qmake).

First step: identify all used Qt-includes

Greps all includes starting with an uppercase Q; then split the result at the “:”; then sort und make it unique

Second step: create a replacement-list and a (python?) script which does this for all .h/.cpp-files
tdb

C++: proper init for double/float and the proper check

Written by  on May 9, 2019

Problem was that I initialized some doubles with 0.0 and then hoped that the imported values are assigned, which does not happen always. So a check was needed. But checking if(0.0 == x) is a really bad idea. MinGW will tell you too (as other compilers).
So I was searching for a proper way to check against 0.0. And then I found a better idea: initialize with NaN and use the standard-check against this. Much better!

(addendum: I know, a variant would be the best to fix the given task.)

I want my Wifi-repeater. Now!

Written by  on May 4, 2019

Three weeks ago, while being in the garden, I noticed that there is no network connectivity except by superslow EDGE. Of course, three walls block the Wifi-router, but what about one repeater which is closer and just shielded by one wall? Also I remembered having read about the usage of some ESP-nodes for that. I don’t like the approach of buying some closed-source-product.

Short research yielded the project from martin-ger on Github, which I wanted to use. I was surprised that nothing for the ESP32 is available (only for ESP8266). So I tracked down my single ESP8266 (LoLin, NodeMCU, not sure which revision, but with CH340G-USB-connect and as DevKit (mingling with pulldown-resitors would add another layer of complexity, which I am not sure I want to tackle).
Turns out I could not flash the given item properly with the ESP8266 Download Tool 3.65. It blinks while doing so, but follow-up seral-monitoring onyl yields “lolin ts Jan 8 2013,rst cause:2, boot mode:(3,6)”.

So I ordered a from a german shop a new ESP8266. Looks like exactly the same model.
Will do some quicktest now with the blink-app (basic functionality and flashing works?). And then do a test with the ESP Download tool.

More later ..

Advanced debugging: find call which triggers Qt-errors

Written by  on April 26, 2019

Currently the debugging version of the Qt-libraries is not available. But I receive a report "QIODevice::write (QIODevice): Called with maxSize < 0" deep within them.
Our codebase is quite large, I am more familiar with other sections and let's say it: some is 'legacy'. So, where to start looking?!?
Yesterday I remembered a trick to get via call-stack to the last-recent position where our functions trigger that mistake.

Inserted in the main.cpp after show from the MainWindow was called a

which stands for this

Add a breakpoint in the messageHandler and debug the app. Maybe disable the breakpoint until you start to trigger the critical functionality.
When it breaks, you have a nice callstack and can backtrace where it came from :)

how to resume broken downloads

Written by  on April 24, 2019

aka: fix the weird firewalling settings ..
aka: How to download the latest stable Qt SDK source code?
curl -L -O -C - http://download.qt.io/official_releases/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.zip

cmd replacement: cmder

Written by  on March 29, 2019

Sometimes you have to call some batch-files with spoecific windows-tools, so a bash is not helpful on Win.
A colleague recommended cmdr, which is quite nice and fine.
Suits my needs 🙂

ESP32: integrated the YL-69 for moisture-metering, also fried my first BME280

Written by  on March 12, 2019

Acquired a Bosch BME280 for improved humidity, air pressure and temperature-measurement (DHT22 can’t read barometric pressure) and tried to attach it via I2C.
Let’s keep it short: the sensor got very hot after several tries to find the correct wiring. Even using the i2c-scanner testprogram did not yield any results. But I learned how to use the breadboard more effectively. The burnt IC will be sold as ‘Lehrgeld’ 😉 (Oh, the days when I fried my AMD Duron, because I thought that a CPU won’t heat up so fast at boot. Boy was I wrong.)
Integrated then at least via analog reading the YL-69 moisture sensor. Worked well and on first try. Guess I just need to read much, much .. more about I2C, wiring and the sensors.
Another lesson learned: if you want to see really badly structured, basic coding: check tutorials for microcontrollers :/ (especially mine ;))
———
Code is committed and pushed to github.
Output is something like:

breadboard-setting featuring a Haworthia and WerNO!:

SmartGit can process warnings from commit-hooks!

Written by  on March 8, 2019

Another thing I was not aware of: SmartGit can present warnings reported from (pre-)commit-hooks in an alerting way.
Just add echo “warning:” as prefix to your message and it will result in a warning signpost and a modal dialog after commit.

I’ve filed a change-request to make this parsing of the messages case-insensitive.

Move some feature-implementation with Git-help from one branch to another without previous “merges”

Written by  on March 8, 2019

We ran at work into the quite tricky problem to move the “pure” implementation of a feature to some other branch (a quickfix-release) without adding those features/bugfixes from the current master-branch. The feature branch was created some while ago and meanwhile updated from time to time with origin/master.

Discussed options were:
* manually copy the changes (since it was one directory and some minor adjustments in other CMakeLists.txts and some calls) –> much work, very error prone in terms of “Oh, I missed something”
* move to HEAD@target-branch and cherry-pick one-by-one all feature-commits (without merge-commits) –> lots of work, because 15+ commits
* some Git-way –> preferred by me, but I neve did something similar before – so: totally unknown

I chose the third option and tinkered in parallel while someone else tried the other path.
0. created “fake-feature-branch” on HEAD of the feature-branch
1. merged current state master-branch to it
2. created a diff as patch-file between HEAD@master and HEAD@”fake-feature-branch” by:
git diff fromHash toHash --binary > ../binary.patch
(–binary is important; else added ressources will be missing)
4. switch to HEAD@targetBranch
5. apply the patch (and suppress whitespace-errors) by:
git apply --whitespace=fix ../binary.patch
6. eventually fix conflicts if necessary

Yay, two commands to save the day! Around 170 files were affected, so manually doing the application of the changes was out of scope for me. There had to be a feasible Git-solution.

ESP32 and DHT22: temperature and humdity

Written by  on March 5, 2019

To give my (non-existant) skills for microcontrollers and reading out sensor-values a kick-start, I decided to connect today an DHT11 to the ESP32.
So, at first I realized I have no clue how a breadboard works, then that I need a calculator to determine the resistors properly, then “how to determine the correct pin-numbering”, then … it did not work, no matter what I tried. The C++-code was the least issue. Several sources provide examples, also with webserver (looks like everyone ~stole~ got inspired from each other ..), but the read-out always failed.
Luckily I had two (a bit more ‘expensive) DHT22 at hand and it worked like a charm!

Lessons learned: 0. accept that you know nothing 1. reading and experimenting is fun 2. seeing finally a presentable result is great <3

Result:
* code
* output: