Monday, February 2, 2015

Problem with I2C on Raspberry Pi after Raspbian update

Problem with I2C on Raspberry Pi after Raspbian update 

 Problem

My DS3231 does not work on Raspberry Pi after update for Linux 3.18.5+ :(

Solution

The latest firmware implements device tree support. That will have broken things like I2C, SPI, and 1-wire bus.

Wednesday, December 24, 2014

Одиночный поход в Остёр

Одиночный поход в Остёр


Преамбула.

Одним из моих увлечений является каякинг. Когда-то давно я только смотрел на байдарки, на суровых людей, куда-то увлечённо гребущих. На лодки, самых разных форм, размеров и с самым необычным окрасом. В то же самое время, мне всегда нравилась вода и время от времени я арендовал вёсельную лодку на которой катался. Потом мне представился шанс попробовать непосредственно то, что так любопытно смотрелось со стороны - пластиковые каяки. 



Tuesday, December 23, 2014

Installing hardware RTC (DS3231) to Raspberry Pi



Installing hardware RTC (DS3231) to Raspberry Pi

 Problem

As we know, Raspberry Pi does not have RTC. We can use w: ntpd for date and time synchronizing with NTP servers. But what we can do if we do not want to use NTP? What we can do if we want to use our RPi standalone?
Also, Raspbian OS (which based on Debian) uses "fake hwclock" module:

Some machines don't have a working realtime clock (RTC) unit, or no driver for the hardware that does exist. fake-hwclock is a simple set of scripts to save the kernel's current clock periodically (including at shutdown) and restore it at boot so that the system clock keeps at least close to realtime. This will stop some of the problems that may be caused by a system believing it has travelled in time back to 1970, such as needing to perform filesystem checks at every boot.

But we need to have real hwdclock and abilities for standalone work! :) Let's do it!

Solution

Looking for hardware

First, we need find and buy hardware. We can use many solutions (based on DS1307, DS3231, NXP PCF2127AT, NXP PCF2127T, NXP PCF2129AT, NXP PCF2129T) but in this case we will use DS3231.


Then, we need buy this RTC. If we will try to search by "Raspberry Pi RTC module buy" request we will found very expensive solutions - 10-15 USD or more. It's very expensive and we can make bargain deal. What we need to do - look for DIY DS3231 modules. We can use modules for Arduino. They have much lower cost. For example, we can buy DS3231 from aliexpress.com only for 1-2 USD. The main difference - connectors. We must connect all pins from DS3231 to the our Raspberry Pi.

DS3231 DIY module

Thursday, December 11, 2014

9 bit UART (8M1, 8S1 modes) in Linux (hack)

Problem

As we know 9 bit UART (8M1, 8S1) mode in Linux (like in any POSIX systems) is not supported. So we can't communicate with devices which uses 9 bit.

Now we can fix it!

Sunday, November 24, 2013

CGI Python: serving binary file from web server to client

CGI Python: serving binary file from web server to client

1. Problem.

I want to send binary data (image or packed zip file) to the client from our CGI Python script. If you will work under *nix system it will not be complicated.

Wednesday, November 13, 2013

Qt 5.1 zlib compression compatible with Python zlib.decompress. Uploading files to the server.

Qt 5.1 zlib compression compatible with Python zlib.decompress. Uploading files to the server.


Task

I want transfer file from Qt 5.1 application to the server. File must be packed before transmission (in Qt application), then must be unpacked in server's (in Python script). We will use zlib compression in both sides.

Sunday, November 3, 2013

Перцы

Мои перцы

1. История


Кто-то знает, а для кого-то это будет новостью, но я люблю острые блюда и мне нравится выращивать перец. Многие из вас замечали, что некоторые перцы кажутся острее чем другие, но как это измерить? Оказывается есть такая замечательная штука как Scoville scale (аналогичную статью можно найти в Википедии под названием острый вкус). Проанализировав предлагаемую информацию мы можем увидеть, что острота перцев может отличаться в десятки раз. Когда я был маленьким, меня пугали что есть де такой перец как кайенский и что он такой острый, что уж дальше некуда. Как оказалось, всё же бывает и поострее... :)

Если кому интересно - добро пожаловать под кат.

Monday, October 28, 2013

Bug in QIBASE (Qt 5.1.1) always returns 00:00:00.000 as time part of TIMESTAMP


Bug in QIBASE (Qt 5.1.1) always returns 00:00:00.000 as time part of TIMESTAMP

Description


Unfortunately QIBASE driver have bug in Qt versions 5.1.0 and 5.1.1. When you trying to retrieve any TIMESTAMP value you'll have 00:00:00.000 as time part of TIMESTAMP.

To test this you can execute something like this:

select current_timestamp as dts from rdb$database

This query will return current time stamp on server which have Firebird/Interbase installed.

You will get 00:00:00.000 as time part of result :(

Thursday, October 17, 2013

Fun with QSerialPort

Fun with QSerialPort


As we know, we can use QSeialPort to communicate with devices via RS232/RS485 or via virtual COM ports (I recommend to use devices based on MCP2200 not on FT232, because they are cheaper :) )

Many years ago I used a PComm.dll (as I know, it developed by MOXA) to work with COM ports from my applications written in C++/Delphi (in Windows). Later I found QSerialDevice library for Qt. But now, as I told before, we can use QSerialPort directly from Qt version 5.1 and higher.

Wednesday, October 16, 2013

Parsing big log file

Parsing big log file

1. Task

Task: I have big text file (which have size approx 2 GiB) and want to parse it. I want to find each entry of word "exception" and then print this line and next 9 lines. Also, this 10 lines can contain string:
 "stuff at begin of line At procedure '%PROCEDURE_NAME%' many many symbols in end of line" where words "At procedure" exists in the text constantly and %PROCEDURE_NAME% is text which I also want to find (without quotes if possible :) ).

So, let's try to solve this task :)