Difference between revisions of "Beremiz"

From ArmadeusWiki
Jump to: navigation, search
(Target connection)
(Target connection)
Line 118: Line 118:
 
  YOUR_ARMADEUS_PATH/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc
 
  YOUR_ARMADEUS_PATH/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc
 
for linker and compiler.
 
for linker and compiler.
 +
 +
* You can then compile and transfert the program to target...
 +
* ... but there still an error :
 +
<pre class="apf">
 +
PLCobject : OFF LOG :NewPLC (d8ad51386680f2337309dc55eddb4383)
 +
python: '/mnt/nfs/beremiz/d8ad51386680f2337309dc55eddb4383.so' is not an ELF executable for ARM
 +
PLCobject : Traceback (most recent call last):
 +
  File "/mnt/nfs/beremiz/runtime/PLCObject.py", line 135, in LoadPLC
 +
    self._PLClibraryHandle = dlopen(self._GetLibFileName())
 +
OSError: File not found
 +
</pre>
 +
 +
* This can be tricky fixed by changing code in beremiz beremiz/targets/Linux/plc_Linux_main.c :
 +
<source lang="C">
 +
/*
 +
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
 +
{
 +
    return __sync_val_compare_and_swap(atomicvar, compared, exchange);
 +
}
 +
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange)
 +
{
 +
    return __sync_val_compare_and_swap(atomicvar, compared, exchange);
 +
}
 +
*/
 +
//XXX
 +
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
 +
{
 +
    long res;
 +
 +
    res=*atomicvar;
 +
    if(*atomicvar == compared){
 +
        *atomicvar = exchange;
 +
    }
 +
 +
    return res;
 +
}
 +
//XXX
 +
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange)
 +
{
 +
    long long res;
 +
 +
    res=*atomicvar;
 +
    if(*atomicvar == compared){
 +
        *atomicvar = exchange;
 +
    }
 +
 +
    return res;
 +
}
 +
</source>
  
 
== Links ==
 
== Links ==
  
 
* [http://www.beremiz.org/ Home page of project].
 
* [http://www.beremiz.org/ Home page of project].

Revision as of 17:59, 11 July 2013

Page under construction... Construction.png Informations on this page are not guaranteed !!

Introduction

Beremiz is free software toolkit for automation. It's conform with IEC61131 languages and can drive graphicaly your system.

Beremiz is divided in two softwares:

  • Beremiz.py: The Graphical toolkit that run on the Host to drive the target.
  • Beremiz_service.py: The target runtime that execute the code compiled by Beremiz.py and sent by network to its.

Then there are two triky things to do to use beremiz on APF* platforms :

  • Configure Beremiz.py to cross-compile binary for ARM
  • Run python program Beremiz_service.py on apf.

Installation

Host

To see how to install Beremiz on your host, please see the official website (How to build with Linux).

Target

APF28

Python 2.7 and Pyro are required to run Beremiz_service.py.

install python 2.7

run

make menuconfig

On up to date armadeus trunk view, then select :

Package Selection for the target  --->
    Interpreter languages and scripting  --->
        [*] python
            python module format to install (.py sources only)  --->
                          (X) .py sources only
         core python modules  --->
                    [*] bzip2 module
                    [*] bsddb module       
                    [*] codecscjk module   
                    [*] curses module      
                    [*] pyexpat            
                    [*] readline           
                    [*] ssl                
                    [*] unicodedata module 
                    [*] sqlite module      
                    [*] zlib module        
                    [*] hashlib module     

then make :

$ make
Install Pyro3.14

The tricky method is:

  • download Pyro3.14 tarball here and decompress it in your nfs directory.
cd /local/export
wget https://pypi.python.org/packages/source/P/Pyro/Pyro-3.14.tar.gz#md5=2101230425e6c76f5aa2e9d5167cbd3b
tar -zxvf Pyro-3.14.tar.gz
  • Then once on your target (APF28) with python 2.7 installed go to your nfs directory and install it :
cd /mnt/nfs/Pyro3.14
python setup.py install
Install Beremiz_service.py

The tricky method is nearly the same than Pyro.

  • copy your beremiz directory under your nfs directory.
  • launch it with python on your target:
# cd /mnt/nfs
# python Beremiz_service.py 
Wx unavailable !
Twisted unavailable !
Pyro port : 3000
Pyro object's uri : PYRO://127.0.1.1:3000/7f00010102d100069fec101918092f7c
Current working directory : /mnt/nfs/beremiz

Simple usage

Target connection

  • When Beremiz.py is launched on your Host, create or open a project then save it.
  • With your favorite editor edit the file beremiz.xml then change the URI line:
<BeremizRoot URI_location="PYRO://192.168.0.33:3000">

Replace 192.168.0.33 by the IP of your APF28.

  • Re-open your project then clic on «connect» icon.
  • You can compile your project and try to send it...
  • ... but you will have this error :
PLCobject : OFF LOG :NewPLC (d8ad51386680f2337309dc55eddb4383)
python: '/mnt/nfs/beremiz/d8ad51386680f2337309dc55eddb4383.so' is not an ELF executable for ARM
PLCobject : Traceback (most recent call last):
  File "/mnt/nfs/beremiz/runtime/PLCObject.py", line 135, in LoadPLC
    self._PLClibraryHandle = dlopen(self._GetLibFileName())
OSError: File not found
  • Because the defaut compliler for Beremiz.py is not for arm ...
  • To configure your compiler, go to project configuration (double clic on head of hierarchy) and adding the path of your compiled armgcc :
YOUR_ARMADEUS_PATH/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc

for linker and compiler.

  • You can then compile and transfert the program to target...
  • ... but there still an error :
PLCobject : OFF LOG :NewPLC (d8ad51386680f2337309dc55eddb4383)
python: '/mnt/nfs/beremiz/d8ad51386680f2337309dc55eddb4383.so' is not an ELF executable for ARM
PLCobject : Traceback (most recent call last):
  File "/mnt/nfs/beremiz/runtime/PLCObject.py", line 135, in LoadPLC
    self._PLClibraryHandle = dlopen(self._GetLibFileName())
OSError: File not found
  • This can be tricky fixed by changing code in beremiz beremiz/targets/Linux/plc_Linux_main.c :
/*
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
{
    return __sync_val_compare_and_swap(atomicvar, compared, exchange);
}
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange)
{
    return __sync_val_compare_and_swap(atomicvar, compared, exchange);
}
*/
//XXX
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
{
    long res;

    res=*atomicvar;
    if(*atomicvar == compared){
        *atomicvar = exchange;
    }

    return res;
}
//XXX
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange)
{
    long long res;

    res=*atomicvar;
    if(*atomicvar == compared){
        *atomicvar = exchange;
    }

    return res;
}

Links