❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

Building a runtime system for arm-eabi

AdaCore provide a compiler (running on Windows and Linux) targeted to ARM (target arm-eabi) and a runtime system (RTS) supporting the Ravenscarprofile.

The public version of the AdaCore Ravenscar RTS is released under the full GPL. It seemed as if it would be a good idea (and fun!) to produce an independent RTS with the GCC Runtime Library Exception(FAQ).

Read more Β»

Invensense MPU9250 via SPI

This is a note on building support for the MPU92509-axis chip in the AdaPilotproject (the AdaRacerhardware; the prototype board I have is subtly different from the one shown).
9-axis means it can measure each of acceleration, gyro and magnetic field values in 3 axes, which is very useful if your drone needs to know about its own motion.
Read more Β»

Starting Gnat Studio with Alire fails

I have had a try at using Gnat Studio with the Alire package manager. Launching Gnat Studio using the 'alr edit' command is causing Gnat Studio to crash. I have had a look at the log file and there are several .dll files causing exceptions. The file entries are like this:

[PROJECTS.EXCEPTIONS] Unexpected exception: raised CONSTRAINT_ERROR : gnatcoll-projects.adb:5729 index check failed _PROJECTS.EXCEPTIONS_ [C:\GNATSTUDIO\bin\gps.libgnatcoll\libgnatcoll.dll] _PROJECTS.EXCEPTIONS_ 0x7ffc78dcecb8 ??? at ???

Gnat Studio opens in an 'inconsistent state' and crashes.

Regards Mike

gnatcoll-db includes dborm.py, need to understand routines in python

I was using gnatcoll-db, but the limitations made me to rewrite dborm.py in Ada. There are two routines in dborm.py (in python) that I don't understand, specifically compute_table_aliases and fields_count_array.

Any help will be welcome. Of course, the modifications can be shared between all of us.

Edited to complete information:

My project fork is here. I don't want to copy here the complete routines from dborm.py as I don't know exactly the license terms of ACS. dborm.py can be downloaded from https://github.com/AdaCore/gnatcoll-db/tree/master/gnatcoll_db2ada.

The routines that I want to translate to Ada are:

  • compute_table_aliases, lines 2407 to 2448. Really I don't understand the algorithm.
  • fields_count_array and fields_count, lines 2372 to 2397. For these routines I have a translation to Ada but when testing, the result is OK except in a few cases.

Here is my translation to Ada:

Max_Depth : constant := 3; type Counts_Array is array (0 .. Max_Depth) of Integer;

  function Fields_Count_Array (T         : Table_Description;
                               Follow_LJ : Boolean;
                               DepthMax  : Integer;
                               FKStop    : Field := No_Field)
                            return Counts_Array is
     FK_Stop : Boolean; -- to be reset before each call to fields_count_
     Depth   : Integer := 0;
     Temp    : Counts_Array;

     function Fields_Count (T         : Table_Description;
                            Depth     : Integer;
                            Follow_LJ : Boolean;
                            FKStop    : Field := No_Field) return Integer;
     function Fields_Count (T         : Table_Description;
                            Depth     : Integer;
                            Follow_LJ : Boolean;
                            FKStop    : Field := No_Field)
                         return Integer is
        Result : Integer;
        procedure Process_FK (FK : in out Field);
        procedure Process_FK (FK : in out Field) is
        begin
           if FK = FKStop then
              FK_Stop := True;
              return;
           end if;
           if FK_Stop then
              return;
           end if;
           if Follow_LJ or (not FK.Can_Be_Null) then
              Result := Result +
                Fields_Count (Pointed_Table (FK), Depth - 1, Follow_LJ);
           end if;
        end Process_FK;
     begin
        Result := Num_Fields (T);
        if Depth > 0 then
           For_Each_FK (T, Process_FK'Access);
        end if;
        return Result;
     end Fields_Count;

  begin
     while Depth <= DepthMax loop
        FK_Stop := False;
        Temp (Depth) := Fields_Count (T, Depth, Follow_LJ, FKStop);
        Depth := Depth + 1;
     end loop;
     return Temp;
  end Fields_Count_Array;

Note that all type definitions come from gnatcoll-sql.

I understand that this is difficult to follow, perphaps may be better if I send a report on the modifications and the complete new Ada package replacing dborm.py. How?

How can I install the ZFP (Zero Foot Print) RTS (Run Time System) for AVR with the Alire package manager for Ada?

How can I install the ZFP (Zero Foot Print) RTS (Run Time System) for AVR with the Alire package manager for Ada?

My project file, I think correctly, contains:

project Avr is
   for Runtime("Ada") use "zfp";
   for Target use "avr-elf";
end Avr;

alire.toml hopefully correction contains:

[[depends-on]]
gnat_avr_elf = ">=11.2.4"

Unfortunately, when running alr build, I get:

gprconfig: can't find a toolchain for the following configuration:
gprconfig: language 'ada', target 'avr-elf', runtime 'zfp'

I found documentation for programming AVR with Ada, but this assumes that I build the tool-chain myself and not have a package manager at least providing the GNU tool-chain.

The same applies to Programming Arduino with Ada.

Cannot Run GNATStudio - WSL

I've checked the other questions and this case doesn't seem to be covered. I'm running Ubuntu in WSL on my windows machine and I'm trying to run GNATStudio, any time I attempt to run the program either via Alire or by calling it I receive the following error.

 error while loading shared libraries: libxcb-shm.so.0: cannot open shared object file: No such file or directory

I've already done the basics, and verified I have the correct file installed. Calling apt-file find produces the following.

root@DESKTOP-F319G5G:/opt# apt-file find libxcb-shm.so.0
libxcb-shm0: /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0
libxcb-shm0: /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0.0.0

I've confirmed the location is in my path, as well and have restarted a few times. I'm really not too sure what my next steps should be. Any help is much appreciated!

Gnatcheck custom rules

I'm trying to obtain a list of global variables declared in a large Ada project. gnatcheck has a rule for that: Global_Variables, but that rule is not exhaustive:

"Flag any variable declaration that appears immediately within the specification of a library package or library generic package. Variable declarations in nested packages and inside package instantiations are not flagged"

I'd like to be able to obtain the list of variables declared in package instantiations as well. I would try to implement my own gnatcheck custom rule, but cannot seem to find where the rules are implemented. This doc says it's supposed to be in share/lkql, but there is no such directory in my GNAT Studio installations (I've looked at GNAT Pro 19.2, GNAT Pro 22.1 and Gnat Community 2021). Windows cannot find any .lkql file.

Is it possible to make such a rule? If so, how/where? Are there alternatives to gnatcheck to obtain the list of global variables?

Ada GNAT.SOCKETS.SOCKET_ERROR:[11] Resource temporarily unavailable

I'm using the following socket server on windows, which works fine. When I try to execute this code on linux I get the following error message:

GNAT.SOCKETS.SOCKET_ERROR:[11] Resource temporarily unavailable

Does anybody has a hint whats going wrong?

Thanks a lot in advance.

with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Server is
   Channel : Stream_Access;
   Server : Socket_Type;
   Address : Sock_Addr_Type;
   Socket : Socket_Type;
   receive_str : Unbounded_String;
   Receive_Character : Character;
begin
   Put_Line("Server Config Started...");
   Create_Socket(Socket => Server);
   Set_Socket_Option(Socket => Server, Level => Socket_Level, Option => (Name => Reuse_Address, Enabled => True));
   Set_Socket_Option(Server, Socket_Level, (Receive_Timeout, Timeout => 1.0));
   Bind_Socket(Server, Address => (Family => Family_Inet, Addr => Inet_Addr("127.0.0.2"), Port => 65432));
   Listen_Socket(Server);

   loop
      Accept_Socket(Server, Socket, Address);
      receive_str := To_Unbounded_String("");
      Channel := Stream(Socket);
      loop
         Character'Read(Channel, Receive_Character);
         exit when Receive_Character = '@';
         Append(receive_str, Receive_Character);
      end loop;
      Put_Line("ReceiveStr" & To_String(receive_str));
      String'Write(Channel, "OK123");
   end loop;
end Server;

Self dependency in Spark 2014

I'm trying to write the flow dependency of a procedure in Ada and Spark 2014 and the compiler give me a medium warning that

medium: missing dependency "null => MyBool"
medium: incorrect dependency "MyBool => MyBool"

Here is my .ads file:

SPARK_Mode (On);
package TestDep is

  pragma Elaborate_Body;

  MyBool: Boolean := False;

  procedure ToFalse with
    Global => (In_Out => MyBool),
    Depends => (MyBool =>+ null),
    Pre => (MyBool = True),
    Post => (MyBool = False);

end TestDep;

and in the .adb:

pragma SPARK_Mode (On);
package body TestDep is

  procedure ToFalse is
  begin
    MyBool := False;
  end ToFalse;

end TestDep;

I'm new to Ada and Spark and I'm still learning it, but from the AdaCore documentation I've saw that Depends => (X =>+ null) should indicate that the value of X at the end of the procedure only depends on the value of X and nothing else.

Why does the compiler give me those warning ? Am I doing something wrong ?

Trying to use GPS for Ada and keep having problems trying to compile and run the code

I am currently trying to run a program in GPS and this is my first time trying to use Ada and don't quite understand some things to it. I have some code that was told was supposed to run but can't seem to get it running. When I try to compile it or run the code, I keep getting an error message: "end of file expected. file can only be one compilation unit." I also included a photo to help show the problem. I'd appreciate any tips or hints on how to solve this please!

enter image description here

❌
❌