The new version of Linux kernel and lazarus could sometimes do not work with some types of serial ports, for that you must change synaser.pas

Attention: you need to edit and then recompile the components that makes uses of synaser.pas.

In the line 917, you need something like this,


FHandle := THandle(, O_RDWR or O_SYNC));

{$ELSE}  FHandle := THandle(fpOpen(FDevice, O_RDWR or O_NONBLOCK or O_NOCTTY)); <—– the problem

{$ENDIF}  SerialCheck(integer(FHandle));  {$IFDEF LINUX}  if FLastError <> sOK then



Sometimes for debug purposes, we need to create a virtual serial port, for that I have found a good document in the site

For this you need to install socat

sudo apt-get install socat
sf Then do
socat -d -d PTY: PTY:
this will create to virtual ports /dev/pts/1  and /dev/pts/0 connected.

1st install libraries dependencies:

sudo apt-get install libtool gtk-doc-tools libgstreamermm-0.10* libgconf2-dev libglade2-dev

2nd compile and install unicap and extra libraries:

  • bzr branch lp:unicap
  • bzr branch lp:ucview
  • cd libunicap; ./; ./configure; make; sudo make install
  • cd ../libucil/; ./; ./configure; make; sudo make install
  • cd ../libunicapgtk; ./; ./configure; make; sudo make install
  • cd ../python-unicap; ./; ./configure; make; sudo make install
  • sudo ldconfig;
  • cd ../ucview/trunk; ; ./; ./configure; make; sudo make install
  • Test it with: sudo ucview

First image with maximum resolution :

All people that uses  computer to work, need’s to make some type of backup with the last updates. This is a hard task if you don’t have the right tool. On the web you may find great solutions, like dropbox, but this last one will backup your files on the cloud with some risk of security and with some level of service limitations.

I found one good solution, that is called Unison. You can learn more here. Brief  description of the tool: Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.


Sometimes is useful have notes about the subject that we are presenting. For this we have one feature on that could help us on this. That feature is the presenter screen, ( more informations here). For you get this on your computer you must have installed the (>3.0), then you must:

  • Download the extension here (choose the file that is compatible to you SO and
  • Start the and go to: Tools->Extension Manager and click add
  • Select the file that you had downloaded  and accept the license and install
  • Another way is: Go to System->Administration->Synaptic and install

After this, you must start  openoffice-impress and on Slide Show-> Slide Show Settings -> Multiple displays and select the master viewer.

Important Note: For you use this feature you need two monitors connected to your PC, and then on ubuntu you must configure “Separate X Screen”, on TwinView this feature don’t will work. If you have Ubuntu+Nvidia (card video) you must do:

  • connect the two monitors (if is a laptop you need only to connect the extra monitor our projector)
  • sudo nvidia-settings
  • Then on XServer-Display-Configuration press Detect Displays, and  configure one as a master
  • Save and restart the X (on shell make: sudo service gdm restart)

1 st install wine on ubuntu

  • sudo apt-get install wine
  • run wine ( for setup the initial configurations )

2 nd download application

  • download ths720, from here

3 rd configuration of serial port

  • cd ~/.wine/dosdevices/
  • sudo ln -s /dev/ttyUSB0 com1 ( if you use serial adapter to usb)

4 th  setup application + scope

  • Connect the scope to pc through usb-serial cable
  • Turn on the scope
  • on the shell and on the directory where you downloaded the application,  run “wine ths720.exe”
  • Now use the instructions presented on the application

What you will need?

  1. avr-gcc ( the compiler from c to machine code(hex))
  2. avr-dude ( the program to send the hex file to micro)
  3. eclipse ( IDE Integrated development environment, a software development system)
  4. Programmer hardware ( could be AVRRisp mkII)

1st Let’s install avr-gcc and avr dude on ubuntu

  • $ sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude
  • on the shell command do: $ avr-gcc -v ( attention if you want build programs for atxmega, you will need the version => 4.3.0, for atxmega16a4 you will need the 4.3.5 )

2nd  setup the programmer,

  • If you use the AVRRisp mkII programmer, you will need to give some permissions for ubuntu users, for that you need to do:
  1. $ sudo gedit /etc/udev/avarice.rules
  2. add this to the file:
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avarice_end"

# Atmel Corp. JTAG ICE mkII
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTRS{idVendor}=="03eb", ATRRS{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTRS{idVendor}=="03eb", ATRRS{idProduct}=="2107", MODE="660", GROUP="dialout"

  1. save the file
  2. then on shell $ sudo cp /etc/udev/avarice.rules /etc/udev/rules.d/60-avarice.rules

3rd install Java on Ubuntu

  • you need java-virtual-machine to run Eclipse, for this go to synaptic Settings->Repositories
  • on other software activate the canonical Partners,
  • after this upgrade the list of software and install the package sun-java6-bin and sun-java6-jre on synaptic
  • or on shell run: sudo apt-get install sun-java6*

4 th install the eclipse

  • go to and download Eclipse IDE for C/C++ Developers (you must select this because you mainly will program in C/C++) (if you have 64bit processor choose the version 64bit)
  • on the shell and on the folder where you made the download, make: $ tar zxvf   eclipse-cpp-helios-SR1-linux-gtk-x86_64.tar.gz
  • Then make on shell $sudo mv eclipse /opt/eclipse
  • Then make on shell $sudo ln -s /opt/eclipse/eclipse /usr/bin
  • To start the eclipse just make on the shell $ eclipse  (you can also create an icon for eclipse)

5 th install the plugin for AVR

  • On eclipse go to Help menu
  • the go to eclipse marketplace
  • and find for “avr”
  • install AVR eclipse plugin

Now lets configure the programmer:

  • go Window->preferences
  • Then select AVR->AvrDude
  • Here you will add a new programmer, for our case press ADD, choose a name for the configuration (ex: HardProg),
  • Select the programmer “Atmel AVR ISP mkII”
  • on the override default port, write usb
  • choose the baudrate 38400 (you can select another one)
  • press ok and save

7 th  Save automatically files before build

  • On eclipse there are some default configurations that are not the best ones for our work, one of the is when you build the project this will not save the file before the compilation. To correct this:
  • go Window->preferences
  • Then go General->Workspace and select save automatically before build
  • press ok and save

8 th make test program

  • goto to File->”new project”
  • select C/C++ , C++ project and next
  • choose a project name (Testar_avr)
  • on project type select AVR Cross Target Project , Empty project, AVR-GCC Toolchain
  • press next, and on advanced settings, go AVR, AVRDude , programmer configuration, select HardProg, or you programmer name (named before), the press apply.
  • Here you can also configure the fuses, and other stuffs during the programing
  • Then on AVR, go to Target Hardware
  • Select you AVR, or simply press load MCU, and you will get the AVR type.
  • Press apply
  • Then go to: C/C++ Build -> Settings,  on Additional tools in toolchain, and select Generate HEX file for Flash memory, and select AVRDUDE
  • On: C/C++ Build -> Settings,  on AVR Compiler, on Optimization, select Moderate optimize (-o2)
  • Save and close

Now, if you are programing one atxmega, you can add main.c file an put this code (based on

[code lang="C"]
*              XMEGA test FlashBus clock 32M
#include <avr/io.h>
#include <stdint.h>
#include "clksys_driver.h"
#include "flashbus.h"

#define memmory_size 255
volatile uint8_t memmory[memmory_size];

bool FbSwrite_memory(uint8_t addr, uint8_t data){
if (addr<memmory_size){
       return true;
       return false;

bool FbSread_memory(uint8_t addr, volatile uint8_t* data){
    if (addr<memmory_size){
             return true;
         return false;

int main(void){

//clock configuration, 32 MHz Internal RC Oscillator
      CLKSYS_Enable( OSC_RC32MEN_bm );
      do {} while ( CLKSYS_IsReady( OSC_RC32MRDY_bm ) == 0 );
      CLKSYS_Main_ClockSource_Select( CLK_SCLKSEL_RC32M_gc );
      CLKSYS_Disable( OSC_RC2MEN_bm | OSC_RC32KEN_bm );
      // I/Os


     /* Enable global interrupts. */

  • Now, save the file. and on the project, press right button mouse, and make build project. You will get the firmware on the atxmega. (Attention to setup to build release code not debug)

9th install a terminal for debug communication (RS232)

Before install the terminal for debug, you will need to install a driver java to get access to serial port. For this: ( This is based on this document )

  • In Eclipse, go Help->Install New Software
  • add a new remote site, name=RXTX  and URL =
  • Finish and select the last version of RXTX an install It

Now let install serial terminal (console-DSDP Target Management Plugin):

  • In Eclipse, go Help->Install New Software
  • add a new remote site:
  • name=DSDP TM 2.0 Update Site
  • and URL =
  • Finish and select the last version of DSDP an install it
  • restart the eclipse
  • go to window->show view->other then select terminal

Now you will get a new window, on bottom that you could use for communication SSH, Telnet or serial console.

10th Configuration for AVRDude work with arduino


(Special thanks to: Heber, Miguel, Prof. Paulo Costa)

Good luck and programing


1st- Download and documentation

Read official documents:

Installing the Lejo on Ubuntu:

Work with kalman filter:

2st – Compile the view example

  • cd /opt/lejos_nxj/projects/samples/View
  • Compile the program with the nxjc command:
  • nxjc
  • Then link, upload and run it with the nxj command:
  • nxj -r View

You should see the menu of the View sample on your NXT.

3st The bridge UDP-Bluetooth application how works? (in java)

Note: This is a framework to start the development of your bridge UDP-Application.

The  bridge UDP-Bluetooth application (can be download here) is composed by two process:

  • one that runs on the pc (LejoPCHIL), and
  • another (LejoNXTHIL) running on the robot (NXT).

The LejoNXTHIL will receive data from LejoPCHIL and then will convert that data in actions or in replies.

Some important functions and class on LejoNXTHIL:

  • BTConnection btc = Bluetooth.waitForConnection();  Waits and start the connection by Bluetooth.
  • DataInputStream dis = btc.openDataInputStream();       Stream for inputs and outputs data.
    DataOutputStream dos = btc.openDataOutputStream();
  • while( !Button.ESCAPE.isPressed() )                                This is the cycle that reads bytes from Bluetooth and  take actions.
  • read_bytes =;                                                         Return the buffer with data (b) and the dimension of the data (read_bytes)
  • dos.writeInt(read_bytes); dos.flush();                                Write Integer data to Bluetooth ( you can also write bytes buffer, doubles and floats. )

The LejoPCHIL will convert the data from NXT and UDP ports, for this the process will use two threads:

  • one (main) that convert the data from UDP port 1 to Bluetooth and
  • another that convert  data from  Bluetooth to UDP port 2.

Some important functions and class on LejoPCHIL:

  • nxtInfo[0]=new NXTInfo();
  • and  nxtInfo[0].deviceAddress=”00:16:53:07:D5:A8″;
  • nxtInfo[0].name=”NXT”;                    They are used to configure to configure your NXT brick  (You can get the device address from nxjbrowse )
  • NXTConnector conn = new NXTConnector();
  • opened = conn.connectTo(nxtInfo[0].name, nxtInfo[0].deviceAddress, NXTCommFactory.BLUETOOTH);  To Make the connection to your brick NXT
  • DataOutputStream dos = conn.getDataOut();                             Stream for inputs and outputs data.
  • DataInputStream dis = conn.getDataIn();
  • ds = new DatagramSocket(clientPort);                                           Open Port for Server UDP Client
  • DatagramPacket p = new DatagramPacket(buffer, buffer.length);
  • ds.receive(p);                                                                                          Reads data from UDP port
  • dos.write(p.getData(), 0, p.getLength() );
  • dos.flush();                                                                                            Write Integer data to Bluetooth ( you can also write bytes buffer, doubles and floats. )

4st Compile the bridge application and test

Download the example from  here and:

  1. unpack with:   tar zxvf Lejo_udp_bluetooth_start.tar.gz
  2. cd LegoNXTHIL/src/
  3. compile:  nxjc
  4. send it to robot:  nxj -r nxtrobot  (connect the robot with Bluetooth on)
  5. Now you will see on the robot the message “Waiting…”, is waiting to connect to PC
  6. cd ../../LegoPCHIL/src/
  7. compile: javac *.java
  8. execute the application on your computer: java serverpc
  9. Now you will see on the PC the message “Starting reading the UDP”, is waiting to data UDP Port.
  10. you can use another application to connect to this port and test the bridge, download it from here, compile javac, and run with sudo privileges: sudo java  UDP_comunication
  11. If you have motors connected to NXT you will see the motors increasing the velocity

Good Luck and Work.


1st read documentation:

Go to: ( Read the manual )

2st install and compile the cricket_log aplication

Download it from here.

On shell:

  1. tar zxvf Cricket_Log_v1.0.tar.gz
  2. cd Cricket/source/
  3. make
  4. ./cricket_log

3st start using the application

  1. Connect the cricket oem to serial-usb-cable
  2. Confirm the configuration pressing the key [e]
  3. if the cricket is listener you will see on line 2 to 6, the distance to beacon in cm
1st – Ubuntu Desktop Setup (first install tools like gcc and avr dude )
  1. sudo apt-get install gcc g++ libx11-dev binutils-dev indent libreadline5 libreadline5-dev
  2. sudo apt-get install emacs cvs libgsl0-dev libcv1 libcv-dev imagemagick
  3. sudo apt-get install avrdude gcc-avr avr-libc binutils-avr
2st – Download the documents of this board

AVR Butterfly – Quick Start User Guide(User Guide, 1 pages, updated 5/03)
AVR Butterfly Evaluation Kit – User Guide(User Guide, 42 pages, revision C, updated 04/05)

3st – Install the rs232 and power connector  to AVR – Butterfly
  • This is presented on page 23, of AVR Butterfly Evaluation Kit – User Guide.
  • I also suggest that you install an external power ( presented page 20 and figure 3.10) ( you can use the USB power from your computer, use one diode to make tension compatible to AVR Butterfly ( power in max 3.0 -4.5 Volts)  )
4st- Program the software demo from AVR.
  • Download from here.
  • Then use avrdude to program, like this (on shell command line):
  • avrdude -c butterfly -P /dev/ttyUSB0 -p atmega169 -U flash:w:../Downloads/butterfly_app_rev07_and_boot_rev04.hex
  • If is installed the software demo, you need to go menu “options”, then “bootloader”, then “Jump to bootloader”, press enter on joystick.
  • If you have anyother program running on the AVR, you need to make reset (tow ways: disconnect power or make on pcb the reset)
5st- Starting programing for AVR-Butterfly

Download the source code base, from here or here.

unzip the pack:

On that folder you will find source code to use the interfaces of AVR-Butterfly.

( This board runs at 8.00MHz)

To compile, just type “make” on the console where is the source code. 😉

The program the AVR using  step 4.

Good Luck.

PS. On Makefile you must use:

DEVICE = atmega169
CLOCK = 8000000
PROGRAMMER = -c butterfly -P /dev/tty.usbserial
OBJECTS = main.o
FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m