Na letošním InstallFestu jsem měl přednášku o použití Linuxu v robotech. Snažil jsem se ukázat, jak lze z Linuxu běžícím na nějaké “embedded” desce ovládat hardware k ní připojený. Všechny praktické ukázky, které jsem měl připravené, se povedly, až na tu poslední – robot v akci. Ale tu jsem nahradil videem z finále Eurobotu 2010.

Strana: /

Update: Video záznam z přednášky je k dispozici na stránkách InstallFestu.

Posted Mon Mar 4 12:25:29 2013 Tags:

I have an ikiwiki-based website that is used for a university course. Every student has a page where she is supposed to provide information about a project being worked on. For this I want to authenticate students so that they can only edit their page. So far the authentication was implemented with unixauth plugin and the server used PAM modules to authenticate against LDAP server. This worked sufficiently well, however, this method was deprecated by our university IT. Instead, they want all web applications to use Shibboleth technology. I was surprised how easy it is to make ikiwiki work with Shibboleth.

Shibboleth project distributes Apache module modshib2 (libapache2-mod-shib2 package under Debian) that, when properly configured, does the whole authentication for you. Its configuration is not particularly easy but, with the documentation from our IT department, it was possible to do it. When everything is configured, the identity of the authenticated user is passed to the web application in REMOTE_USER environment variable (and a few other variables may contain additional attributes). The use of REMOTE_USER means that one can use the httpauth plugin and Shibboleth authentication works out of the box.

<Directory /var/www/osp/auth>
Options +ExecCGI -Indexes

AuthType shibboleth
ShibRequestSetting requireSession 1
Require valid-user

<Files ikiwiki.cgi>
SetHandler cgi-script
</Files>
</Directory>


That’s all.

Posted Thu Jan 31 13:59:19 2013 Tags:

Last week I presented a paper at 14th Real-Time Linux Workshop. The topic was the comparison of operating system noise between Linux and NOVA microkernel. It was a joint work of myself and Stefan Wächtler from TU Dresden. If you are interested I published the paper as well as all source data here.

Posted Tue Oct 30 10:54:34 2012

This is mostly a bugfix release. The last version was released almost four years ago so it is definitely time for a new release. One big change since the last release is that ORTE is no longer distributed as a part of OCERA project. We created a new project at sourceforge specifically for ORTE. With this change we also moved the source repository from CVS to Git and created a new homepage.

This release does not contain Windows binaries. If you have trouble compiling them from sources, let us know.

ORTE is an open source implementation of Real-Time Publish-Subscribe (RTPS) communication protocol. RTPS is new application layer protocol targeted to real-time communication area, which is build on the top of standard UDP stack. Since there are many TCP/IP stack implementations under many operating systems and RTPS protocol does not have any other special HW/SW requirements, it should be easily ported to many HW/SW target platforms. Because it uses only UDP protocol, it retains control of timing and reliability.

ORTE homepage: http://orte.sf.net/

Posted Thu Aug 16 11:42:41 2012 Tags:

At our university, we bought a PC that was intended for testing during development of low-level components in operating systems (drivers, kernels, etc.). In such tests it is common that the machine gets stuck because of various bugs and it is necessary to perform hard reset to recover from such situations. To our surprise the machine we ordered had neither a reset button on the case nor any connector on the motherboard where the button could be connected. It was a Dell machine.

Moreover, we want to share this PC between multiple people and be able to run some tests automatically. Therefore we wanted to use a remotely controllable relay and serial port to reset the box remotely. I thought that we were lost without the reset button until a colleague of mine brought my attention to PWR_OK signal of ATX motherboards. Using this signal, it is possible to initiate the reset of the motherboard, but things were not so simple as they initially seemed to be.

Power supply uses PWR_OK signal to inform the motherboard that the voltage it generates is stable. When the signal goes low, the motherboard should go to the reset state and remain there until PWR_OK goes up again. So the plan was simple. Use the relay to control the PWR_OK signal and it allows us to reset the motherboard. The problem with this approach was that the motherboard was reset but it also caused the power supply to switch off for about one second and we wanted to avoid frequent switching off and on. The reason for this switching off was that upon detecting low level on PWR_OK, the motherboard responds with deasserting PS_ON signal which causes the power supply to switch off. Therefore, to reset only the motherboard, we had to keep the PS_ON asserted, while playing with PWR_ON. Finally, we ended up with this schematics:

You can see that the PS_ON signal is always tied to ground. This makes the power supply always switched on. We can afford this because we use RELAY1 to switch on/off the computer. The second relay controls PWR_OK signal. In the default position, PWR_OK signal connects the power supply with the motherboard as it normally do. When the relay switches, PWR_OK on motherboard side is tied to GND and motherboard gets reset.

The final solution now looks like this:

After doing all of this, I’ve found that you can buy a simple adapter, which allows you to do the same without cutting the wires of the power supply.

Posted Fri Aug 3 18:36:59 2012

When one writes programs or TeX documents, it is quite useful to compile the program/document quite often to be sure that there are no syntactical or other errors. I use Emacs and have the F9 key set to invoke the compile command which, by default, calls make and allows easy navigation through the detected errors, if there are some. One disadvantage of this command is that when there is unsaved buffer, it asks whether to save the modified file. This means that one have to either save the file by C-x C-s and then press F9 or press directly F9 and confirm the saving of the file by y. Neither variant is ideal because I do not like pressing unnecessary keys. (Yes, I know that I should switch to vim, but that’s another story.)

For this reason, I was looking for a solution to automatically run compile whenever a file is saved but surprisingly I could not find anything suitable for me. For example, Fredrik Hubinette’s auto-recompile seems unnecessary complicated to me. So I put together the following piece of Elisp which does exactly what I need for many years. Recently I cleaned up the code a bit, so it is good opportunity to publish it.

(defun compile-on-save-start ()
(let ((buffer (compilation-find-buffer)))
(unless (get-buffer-process buffer)
(recompile))))

(define-minor-mode compile-on-save-mode
"Minor mode to automatically call recompile' whenever the
current buffer is saved. When there is ongoing compilation,
nothing happens."
:lighter " CoS"
(if compile-on-save-mode
(progn  (make-local-variable 'after-save-hook)
(kill-local-variable 'after-save-hook)))


I put this code into my .emacs. Whenever I need to recompile the file, I activate the compile-on-save-mode by M-x compile-on-save-mode and then the file is automatically recompiled whenever I save it (which I do almost automatically and very often). The code uses the recompile command which does nothing if the buffer was not compiled manually at least once. This is fine because for certain projects it is necessary to setup compile command manually and simply calling make (the default compile command) would do a wrong thing.

Posted Tue Dec 28 22:39:55 2010 Tags:

Recently I installed Gitolite on our server and wanted it to manage the repositories for Ikiwiki-based wikis. It turned out that this is not as trivial task as one might expect so here is how I did it.

First, let’s look at how ikiwiki uses the git repositories. Every wiki needs two git repositories at the server. One of them is a bare repository and pushing changes to this repository updates the wiki. The other repository has a work tree and is used to “compile” the wiki to HTML and by Ikiwiki’s CGI wrapper to edit the wiki via web interface. Whenever somebody pushes to the bare repository, git invokes post-update hook, whose goal is to update the second repository and to compile the wiki to HTML.

On our server, gitolite runs under git user and no other user (besides root) has direct access to repositories. All ikiwiki wrappers (git post-update hook and CGI binary), which are setuid binaries, run as ikiwiki user and cannot access the bare repositories.

So the first problem to solve is where should ikiwiki generate the git hook. This is an easy problem. In the ikiwiki’s configuration file (*.setup) I have the following line:

git_wrapper => '/home/ikiwiki/hooks/<wiki-name>',


The second problem is how to invoke this hook from the bare repository managed by gitolite. If you do not use custom hooks, the answer is straightforward – simply create symbolic link from git to the wrapper:

ln -s ../../../../ikiwiki/hooks/<wiki-name> /home/git/repositories/<wiki-name>.git/hooks/post-update


However, this simple approach does not work if you restricted umask in your .gitolite.rc:

$REPO_UMASK = 0027; # gives you 'rwxr-x---'  In this case, as I wrote above, the repositories cannot be accessed (even for reading) by any user and therefore the git hook (ikiwiki-generated setuid binary) fails, because it cannot access its current directory, which happens to be the bare git repository. The solution is to introduce another wrapper script which will execute the ikiwiki wrapper in another directory: #!/bin/sh wrapper=$(git config --get hook.ikiwiki-wrapper)

# The cd below is why we must use this script. The user running the
# ikiwiki may not have permission to accessible the current directory
# (git repo). In this case, the execution of the ikiwiki wrapper will
# fail with "E: Failed to change to directory '...': Permission denied"
cd /

exec "$wrapper"  This script can be put to /home/git/.gitolite/hooks/common/post-update. Then you must run gl-setup to propagate this hook to all repositories. And finally, you need to configure hook.ikiwiki-wrapper for git repositories that contain ikiwiki content: repo <wiki-name> R = @all RW+ = admin RW = ikiwiki <other users> config hook.ikiwiki-wrapper = /home/ikiwiki/hook/<wiki-name>  Now, you must create public/private key pair for ikiwiki user. The public key must be commited into gitolite-admin repository as ikiwiki.pub. The private key (not passphrase protected) has to be stored in /home/ikiwiki/.ssh/id_rsa. The non-bare ikiwiki repository has to be configured to access the ikiwiki bare repository via gitolite by running this command: git config remote.origin.url git@localhost:<wiki-name>  And we are done. Now, pushing to the gitolite managed repo updates the wiki on the web and simultaneously, editing the wiki through CGI wrapper updates the gitolite managed bare repo. In fact I have the setup on the server a bit more complex. To allow having more post-update hooks, the post-update hook looks like the following: #!/bin/sh for hook in$(git config --get-all hook.post-update-chain)
do
if test -x "hooks/post-update.d/$hook"; then hooks/post-update.d/$hook "$@" else if test -x "$hook"; then
$hook "$@"
fi
fi
done


and the wrapper script containing cd is located in /home/git/.gitolite/hooks/common/post-update.d/ikiwiki-wrapper. The configuration of the repo contains one additional line to run the ikiwiki wrapper:

config hook.post-update-chain = ikiwiki-wrapper

Posted Thu Nov 25 18:12:26 2010 Tags:

Recently I needed to put a list of acronyms to a LaTeX document. There is great acronym package for this purpose. With this package one can define the acronyms and refer to them from the text. The package ensures that the meaning of an acronym appears together with its first use. The package can also generate the list of acronyms however the list is not automatically sorted. When the list becomes long, a big amount of mental capacity is needed find the position where to add a new acronym.

Since I use Emacs to edit LaTeX documents, I’ve written a simple elisp macro (see below) to sort the acronyms. The macro is placed in LaTeX comment so it is not necessary to modify your .emacs.

With this macro adding an acronym is a lot easier:

1. I add the acronym definition anywhere in the list.
2. I press C-up to go to \begin{ and then left. This moves me at the end of the elisp expression.
3. I press C-x C-e (eval-last-sexp) and the list is sorted!

You can try it with this example:

    % Sort acronyms: (let ((sort-fold-case t)) (sort-regexp-fields nil "^[[:space:]]*\\\\acro\{\$$[^}]*\$$\}.*\$" "\\1" (point-min) (point-max)))
\begin{acronym}[XXXXX]
\acro{AC}{Access Category}
\acro{ACK}{Acknowledge}
\acro{AIFS}{Arbitration Interframe Space}
\acro{AIFSN}{Arbitration Interframe Space Number}
\acro{AP}{Access Point}
\acro{CSMA/CA}{Carrier Sense Multiple Access/Collision Avoidance}
\acro{CTS}{Clear to Send}
\acro{CW}{Contention Window}
\acro{DIFS}{Distributed (Coordination Function) Interframe Space}
\acro{EDCA}{Enhanced Distributed Channel Access}
\acro{ERP}{Extended Rate PHYs}
\acro{IP}{Internet Protocol}
\acro{LAN}{Local Area Network}
`