当使用Ada中断处理程序时,我到目前为止已经隔离了一些特定的东西,这些东西需要在代码中才能工作.
使用Ada.Interrupts:
protected Int_Handler is --a protected object to handle interrupts
procedure Handler_1; --A procedure which handles interrupts from your first device (with a body, of course)
pragma Interrupt_Handler (Handler_1); --To tell the compiler this is an interrupt handler
--Later in the program:
begin
Attach_Handler (Int_Handler.Handler_1'access, Serial_1);
Run Code Online (Sandbox Code Playgroud)
假设这一切都正确并且我已经在寄存器中启用了中断,那么我还需要添加其他与中断相关的代码吗?特别是,我是否需要直接与寄存器交互以某种方式"链接"我的处理程序代码,或者我可以只设置寄存器的记录表示,直接输出必要的设置,然后让rip?
谢谢!
我正在尝试创建一个函数来查找指定文件夹中的所有.dll文件,插件.
我的所有网络搜索(Ada目录)都在Ada 2005下完美运行,但我需要一个适用于Ada 95的功能.据我所知,Ada 95没有Ada.Directories扩展.
我将如何通过文件系统在Ada 95中查找.dll文件?那里有什么好的起点我可能忽略了吗?
I\xe2\x80\x99m 在裸机级别编程 micro:bit(在 Ada 中),即 I\xe2\x80\x99m 直接寻址 nrf51 寄存器。
\n\n我对按钮 A、GPIO 引脚 17 没有任何问题:it\xe2\x80\x99s 配置为
\n\ndir => input, \ninput => connect,\npull => pullup,\ndrive => s0s1, \nsense => disabled\nRun Code Online (Sandbox Code Playgroud)\n\n当按下按钮时,IN 寄存器位 17 为low,释放时为 \xe2\x80\x99s high。
然而,与按钮 B、GPIO 引脚 26 的配置完全相同,IN 寄存器的第 26 位始终为low。
出厂图像可识别按钮 A 和 B。
\n\n按钮 B 正确连接到边缘连接器引脚 11(使用 DVM 检查边缘连接器处的电压电平)。
\n\n不过,我想知道为什么我必须指定pullup,因为板上已经有一个 10k 上拉电阻(并且 DVM 显示了正确的逻辑电平)。
我发现了一个早期的原理图,其中 …
我最近开始从事一个项目,该项目要求我的编译器高于 GNAT 4.8.5 - 当我去:帮助 > 关于
可以看到我用的版本是4.8.5
另外,当我运行 gnatls -v 命令时,我可以看到这个......
[parallels@localhost ~]$ gnatls -v
GNATLS 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 1997-2013, Free Software Foundation, Inc.
Source Search Path:
<Current_Directory>
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/adainclude/
Object Search Path:
<Current_Directory>
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/adalib/
Project Search Path:
<Current_Directory>
/usr/x86_64-redhat-linux/lib/gnat
/usr/share/gpr
/usr/lib/gnat
[parallels@localhost ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-multilib --enable-languages=c,c++,ada
Thread model: posix
gcc version 7.3.0 (GCC)
[parallels@localhost ~]$
Run Code Online (Sandbox Code Playgroud)
请问有人能告诉我如何更新我的 GNAT 编译器吗?另外,我使用的是 Centos 7 操作系统。
谢谢,
劳埃德
一位用户最近发布了一个问题,然后将其删除(可能是因为我们不太欢迎)。实际上,这就是问题所在:用 编译gnatmake -gnatwl person_1.adb,结果是
1. with Ada.Text_IO; use Ada.Text_IO;
2. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
3. procedure Person_1 is
4. type String is
5. array (Positive range <>) of Character;
6. S: String (1..10);
7. begin
8. Put("Write a name: ");
9. Get(S);
1 6
>>> no candidate interpretations match the actuals:
>>> missing argument for parameter "Item" in call to "Get" declared at a-tiinio.ads:90, instance at a-inteio.ads:18
>>> missing argument for parameter "Item" in call to "Get" declared …Run Code Online (Sandbox Code Playgroud) 我在谷歌上看了很多,但似乎无法找到如何使用APQ for ada95的任何示例.如果任何人有使用这个库的经验,我将不胜感激任何小例子.
我正在尝试在Ada中定义一个字符串数组来存储可变大小的字符串.我遇到的问题是我必须预先定义我在编译时不知道的字符串的大小,并且使用Unbounded_Strings,String_Split.Create将不起作用,因为它需要Standard.String.
下面是我的代码,我需要能够解析可变大小的字符串,而不仅仅是固定长度4.
提前致谢.
type StrArray is array(1..7) of String(1..4);
function Split(Line : String;Sep : String) return StrArray is
Tokens : String_Split.Slice_Set;
Output : StrArray;
Count : Natural := 0;
begin
String_Split.Create(s => Tokens,
From => Line,
Separators => Sep,
Mode => String_Split.Single);
For I in 1 .. String_Split.Slice_Count (Tokens) loop
Count := Count + 1;
Output(Count) := String_Split.Slice(Tokens,I); -- Not sure how to convert Slice_Count to Integer either!
end loop;
return Output;
end Split;
Run Code Online (Sandbox Code Playgroud) 我想知道将包传递给泛型函数的语法是什么.我已经尝试了几种方法但没有成功.
例如:
generic
with package <<SomeThing>> is <>;
procedure forEach(g: in <<MyType>>);
Run Code Online (Sandbox Code Playgroud)
要么
generic
with package <<SomeThing>>;
procedure forEach(g: in <<MyType>>);
Run Code Online (Sandbox Code Playgroud)
要么
generic
package <<SomeThing>>;
procedure forEach(g: in <<MyType>>);
Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个Ada单元,该单元具有三级包名称声明的规范,例如包ABC但编译失败抱怨没有单元AB这似乎只搜索名为AB.ads的文件而不是ABC.广告.如何让gcc查找正确的文件?谢谢你的帮助.
我目前正在learning.adacore.com上进行Ada教程,现在是第二个示例:读取和输出整数。由于复制粘贴适用于不想学习语法的人,因此我手动键入了大部分代码(其中一些是由gnat-gps生成的,但现在使用的是vim)。
我编译并运行了该程序,令人惊讶的是,输出的第二行大约缩进了一个制表符。为什么?
这是代码:
With Ada.Text_IO;
Use Ada.Text_IO;
With Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
procedure Main is
N : Integer;
begin
-- Insert code here.
Put("Enter an integer value: ");
Get(N);
if N>0 then
Put (N);
Put_Line(" is a positive number");
end if;
end Main;
Run Code Online (Sandbox Code Playgroud)
(如何获取语法突出显示?)
以下是输出示例(第一个输入):
Enter an integer value: 1
1 is a positive number
Run Code Online (Sandbox Code Playgroud)