# LibNodave 64bit write error on Linux



## 3electrons (23 April 2010)

Hi everybody

Sorry to post it in english but I don't know german. I was using google translator to read threads visit this forum. 

I found few people here has compiled libnodave on 64bit linux so I have done it the same way. 


I have following problem. 
Writing single byte into plc results in error: "desired address is beyond limit for this PLC" - error number 5

area = 132
DB = 99 
start = 0 
len = 1 
*buffer = 0x01 0x00 
res = daveWriteBytes(m_dc, area, DB, start, len, buffer); 

res = 5 

Does any of you encounter that problem? Or I have to figure it out on my own. At the same time reading works perfectly. There is no such problem on windows and linux in 32bit mode. 

My environment:
libnodave 0.8.4.5
g++ (Gentoo 4.3.4 p1.1, pie-10.1.5) 4.3.4
Architecture : Intel Core 2 
binutils - 2.18-r3
PLC: VIPA CPU315SB 
Comunnication is realised via ethernet cable. 
Makefile: 
CFLAGS = -m64 -Wall -Winline -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 
CTFLAGS = -m64 -Wall -Winline -fPID -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 
CPPFLAGS = -m64 -Wall -Winline -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 


I was trying to debug libnodave ... but I have not much time to understand its internal architecture. I will be also glad for any hints how to fix the bug on my own. 

BTW. To the author of libnodave  .... good work very usefull library


----------



## Verpolt (23 April 2010)

Hello,

I found this in the forum.


CFLAGS=-m64 -Wall -Winline -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 
CTFLAGS=-m64 -Wall -Winline -fPID -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 
CPPFLAGS=-m64 -Wall -Winline -DLINUX -DDAVE_LITTLE_ENDIAN -fPIC 
....... 
install: libnodave.so 
    cp libnodave.so /usr/lib64


----------



## 3electrons (23 April 2010)

Thank you for your response. 
Actually, you suggested me something what I already did . Maybe it is not obvious from my previous post (I am not native English) but I managed libnodave to work. The problem is when trying to write data (after successful connection to PLC/SPS) there is an error. 

I can read data on 64 bit linux so libnodave is correctly compiled, installed and linked into my program but I cant write to PLC/SPS. 

I have used make flags you suggested, to compile libnodave.
By "My environment:"  I mean flags and tools used to compile library.


----------



## Earny (23 April 2010)

Hello,

my code ist VB.Net, without wrapper (libnodave.net.dll).

First you should control the declaration of your function:
my declaration is:

```
[FONT=Courier New][COLOR=#0000ff][COLOR=#0000ff]Public[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Declare[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Function[/COLOR][/COLOR] daveWriteBytes [COLOR=#0000ff][COLOR=#0000ff]Lib[/COLOR][/COLOR] [COLOR=#800000][COLOR=#800000]"libnodave.dll"[/COLOR][/COLOR] ([COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] dc [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] area [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] areaNumber [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] start [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] numBytes [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByRef[/COLOR][/COLOR] buffer [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR]) [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR][/FONT]
```
Integer means 32-Bit-Integer.

Then:

```
[FONT=Courier New]Dim Buffer(0) as Byte[/FONT]
[FONT=Courier New][SIZE=2]res = daveWriteBytes(dc, daveDB, 99, 0, 1, Buffer(0))[/SIZE][/FONT]
```
In this example you can write only one Byte.

Earny


----------

