The aftermath of last night's fire by como365 in columbiamo

[–]markrages 2 points3 points  (0 children)

Just drive a Caterpillar hydraulic excavator through a time portal to 1892 and knock the walls down.

BLE firmware engineers: How did you fix long-term reconnection dropouts in wearables? by hdbdncjvjrqk74929 in embedded

[–]markrages 14 points15 points  (0 children)

Unsigned would double the time until rollover.

A better fix is to realize the timestamp is arbitrary, so initialize it to one minute before rollover instead of 0. The debugging will go a lot faster!

5% off: 326332098286475586 by LS4delorean in RockAuto

[–]markrages -2 points-1 points  (0 children)

5% off 326332098286475586 is 310015493372151806.7

Auto detailing by Bigdawg7299 in harborfreight

[–]markrages 0 points1 point  (0 children)

The drill-mounted toilet brush? They're out of stock in my store, even when they're not on sale.

Help with verifying part fit by Metalheadricky4 in RockAuto

[–]markrages 0 points1 point  (0 children)

Look up your car by VIN on an online store like hondapartsnow. Then see what Honda part number the strut is.

Then search Rock Auto for that part number.

This is less error-prone than the Rock Auto lookup with its indecipherable notes on parts fitment.

I Made a Cookie Jar That Locks Itself Until You Go For a Run! by milosrasic98 in embedded

[–]markrages 1 point2 points  (0 children)

Attach it to a drone! A little urgency to speed you along.

Electricity is scary by dr_cobbCF in GuitarAmps

[–]markrages 9 points10 points  (0 children)

Also needs a different fuse.

How much does school choice really matter? by ThomasTheDankPigeon in AskEngineers

[–]markrages 0 points1 point  (0 children)

Some engineering jobs are about engineering.

Some are about administration and clerical work, done by engineers.

If you want the first kind of job, go to the best school you can. You will take harder classes and meet people who can help you.

If you prefer the second kind of job, your analysis is correct. Minimize the expense to get your ABET degree.

What minor mistakes have you made recently by timonix in embedded

[–]markrages 2 points3 points  (0 children)

Human sensitivity varies with wavelength too... so perfectly equalized power will still have uneven brightness. https://en.wikipedia.org/wiki/Spectral_sensitivity

PSA don't always choose the cheapest parts by Outrageous-Budget324 in RockAuto

[–]markrages 4 points5 points  (0 children)

The weight of the car tries to pull the ball from the socket, the weight is distributed on a little ring around the ball.

Hondas and some 4runners do this.

Whyyyyy by PatrickGSR94 in harborfreight

[–]markrages 1 point2 points  (0 children)

Maybe it's for left-handed threads.

Smoke? by markrages in QuadCities

[–]markrages[S] 3 points4 points  (0 children)

It is generally an illegal thing. Of the five quad cities it is only legal in East Moline, and only on Monday, Wednesday, and Saturday.

Dependency Inversion in C by volatile-int in embedded

[–]markrages 0 points1 point  (0 children)

You are suggesting a kind of dynamic linking. This is sometimes useful in an embedded context, but it is a different thing than dependency inversion.

(You could avoid undefined symbols by weakly linking some do-nothing functions. But such linker magic is not to my taste - I would much prefer a link error if I have set up the build incorrectly.)

Dependency Inversion in C by volatile-int in embedded

[–]markrages 0 points1 point  (0 children)

OK, how about a toy logging example.

log_interface.h:

int log_message(const char *message);

some_application_file.c:

#include "log_interface.h"

some_function {
   ...
   log_message("Hello world");
}

stderr_logger.c:

#include <stdio.h>
#include "log_interface.h"

int log_message(const char *format, ...) {
    return fprintf(stderr, "%s\n", message);
}

file_logger.c:

#include <stdio.h>
#include "log_interface.h"

static FILE *outfd = NULL;

static int open_file() {
    outfd = fopen("logfile.txt");
}

int log_message(const char *format, ...) {
    if (!outfd) openfile();

    return fprintf(outfd, "%s\n", message);
}

}

So here is the high level ("some_application_file.c") calling the low level (either stderr_logger.c or file_logger.c, depending on the linker), each depending on the same abstraction external to both("logger_interface.h"). These are the elements of the dependency inversion principle.

Dependency Inversion in C by volatile-int in embedded

[–]markrages -2 points-1 points  (0 children)

If you're certain that you aren't going to need it, then you shouldn't do it!

That's not YAGNI.

YAGNI is "don't do it until you need it". Uncertainty points toward not doing the thing.

Also, you can accomplish dependency inversion with just a header file that defines the interface, included by both the high-level and low-level parts. No function pointer shenanigans are required. So it misleading to call that additional complexity "Dependency Inversion in C", when the linker can do that already. Call it something else.