Linux and QuadNA

Using Dyalog under 'nixes

Linux and QuadNA

Postby ray on Tue Aug 27, 2013 8:03 am

Hi,
I am new to Dyalog under Linux (Raspberry Pi) but have long experience in using ⎕NA under Windows (back tow Win 3.11).

Are there any examples of or documentation on using ⎕NA calls under Linux around, or is ⎕NA only for use with Windows Dynamic Link Libraries?

I was expecting to be able to call standard C library function via ⎕NA.

I was also hoping that I might be able to access TKL directly from Dyalog on the Raspberry PI to provide a GUI interface.

Thanks

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 151
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Linux and QuadNA

Postby Jay|Dyalog on Tue Aug 27, 2013 9:38 am

Ray,

You can certainly use ⎕NA to call C library functions on Linux. One slight complication is that you have to know the name of your C library, which isn't always obvious. One way of finding it is to run the Linux command ldd on just about any binary program:

Code: Select all
$ ldd $(which ls) | grep libc
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f933fad9000)

This tells me that I can refer to the C library as "libc.so.6". (I think this is fairly standard on most modern Linux systems, but you should double check!)

Now I can use ⎕NA to call standard functions like getpid():

Code: Select all
      ⎕NA'I4 libc.so.6|getpid'
      getpid
22451

Jay.
Jay|Dyalog
 

Re: Linux and QuadNA

Postby ray on Tue Aug 27, 2013 1:11 pm

Thanks Jay this is exactly what I needed.

Geoff has already posted in this forum a function to return the C library that Dyalog is actually using. I have tried it on my Raspberry, but I have never seen (or cant remember seeing) ⎕NA used in anger under Linux.

I was unsure how much of the ⎕NA syntax I needed. The old syntax (under Windows 3.11) included information to select Pascal or C naming convention (?), which I assume is now redundant (unless calling a program actually written in Pascal).

I assume the ANSI vs Unicode versions of Library calls that Windows requires ("A", "W", or "*") does not apply under Linux.

Thanks again for your help.

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 151
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Linux and QuadNA

Postby Jay|Dyalog on Tue Aug 27, 2013 1:25 pm

Ray,

Geoff is the expert but I think you are correct: on Linux, there is no need to use ".C32" or ".P32" to indicate the calling convention, and no need to use "*" to select the ANSI/Unicode version of a function.

Jay.
Jay|Dyalog
 

Re: Linux and QuadNA

Postby ray on Sun Jan 05, 2014 7:56 pm

I am now happily using ⎕NA calls to the BCM2835-GPIO library.
(C library by Mike McCauley, for accessing GPIO pins for Broadcom BCM 2835 as used in Raspberry Pi.
http://www.airspayce.com/mikem/bcm2835/index.html)

After linking it as a ".so" (Shared Object), the ⎕NA calls to the many moduals are working nicely.

I am using the "DLL" to access the GPIO pins to control an Initio robot, without resorting to any Python or Scratch code.

I hope to do a write up in Vector to share the code for APL-Pie lovers.

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 151
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK


Return to UNIX and Linux

Who is online

Users browsing this forum: No registered users and 1 guest