Tuesday, August 29, 2017

How the I2C protocol works

I found this interesting video explaining how the I2C or two-wire interface works.
Since this is a very popular protocol, you will meet soon or later in the embedded systems, so it's extremely worth to learn it!



Tuesday, June 20, 2017

Appunti di Informatica Libera [pdf]

Ecco qui il link al PDF di Appunti di Informatica Libera (precedentemente noti come Appunti Linux). L'ultimo aggiornamento รจ del 11.11.2013.
Opera monumentale!



Altri formati:



Sunday, May 28, 2017

tic and toc functions in C++ (millisecond resolution)

This is a newer version of my original post about Matlab-like tic/toc functions in C++

These new versions of the TIC/TOC functions have millisecond resolution while the old ones rounded the time difference to the seconds.

Here is the the new  tic_toc.h header:

#ifndef TIC_TOC_H
#define TIC_TOC_H

#include <iostream>
#include <chrono>

typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds milliseconds;

static Clock::time_point t0 = Clock::now();

void tic()
t0 = Clock::now();

void toc()
    Clock::time_point t1 = Clock::now();
    milliseconds ms = std::chrono::duration_cast<milliseconds>(t1 - t0);
    std::cout <<"Elapsed time is "<< ms.count() << " milliseconds\n";


// happy coding and performance testing :)

Thursday, April 13, 2017

Undefined functions while using struct and optim packages in Octave

If you have encountered errors like these in octave:

error: 'cell2fields' undefined near line 939 column 11
error: called from
    __nonlin_residmin__> at line -1 column -1
    __lm_svd__ at line 191 column 9
    __nonlin_residmin__ at line 1128 column 21
    nonlin_curvefit at line 83 column 18
    nlinfit at line 169 column 18

OR these

error: '__collect_constraints__' undefined near line 152 column 7
error: called from
    __nonlin_residmin__ at line 151 column 48
    nonlin_curvefit at line 83 column 18
    nlinfit at line 169 column 18

mean that NOT all the functions in the packages struct or optim have been correctly imported into Octave.

istread of importing the single folders in the Octave's path:

addpath('/home/eddie/octave/struct-1.0.14') % NOT ENOUGH!!!
addpath('/home/eddie/octave/optim-1.5.2')   % NOT ENOUGH!!!

just use the pkg command:

pkg load struct ;
pkg load optim ;

That's it. Happy scientific programming :)

Friday, October 21, 2016

Windows Update Error 8024402C

1. Go to Administrative Tools/Services and find the Windows Update service. Stop it.
2. Go to C:\Windows\ and rename the SoftwareDistribution folder to something like SoftwareDistribution.old
3. Restart the Windows Update service.
4. Click the Check for Updates button on the Windows Update screen.
5. Windows will perform the check - it may take some time, so leave it running. Eventually it will successfully complete.
6. You can then delete the SoftwareSistribution.old folder.


Saturday, October 15, 2016

bash history with timestamps

This is definitely something useful!
How to attach timestamps to the history of the bash commands?
Simple:  just set (in the way you like to have your time format) the bash variable HISTTIMEFORMAT

For example to have the format: day/month/year - hours:minutes:seconds" type this:

export HISTTIMEFORMAT="%d/%m/%y - %H:%M:%S: "

and then just run history

That's it!