Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
regression-suites
Commits
a059f7c9
Commit
a059f7c9
authored
Dec 19, 2018
by
Maxime Perrotin
Browse files
Add interrupt handler in user code
parent
142a7a2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Demo_Ada_GUI/displayer/displayer.adb
View file @
a059f7c9
...
...
@@ -4,73 +4,91 @@
--pragma Profile (Ravenscar);
pragma
s
tyle_
c
hecks
(
off
);
pragma
w
arnings
(
off
);
pragma
S
tyle_
C
hecks
(
off
);
pragma
W
arnings
(
off
);
with
dataview
;
use
dataview
;
with
dataview
;
use
dataview
;
with
adaasn1rtl
;
use
adaasn1rtl
;
with
adaasn1rtl
;
use
adaasn1rtl
;
with
ada
.
Integer_Text_IO
;
use
ada
.
Integer_Text_IO
;
with
ada
.
Integer_Text_IO
;
use
ada
.
Integer_Text_IO
;
with
ada
.
Long_Float_Text_IO
;
use
ada
.
Long_Float_Text_IO
;
with
ada
.
Long_Float_Text_IO
;
use
ada
.
Long_Float_Text_IO
;
with
system
.
io
;
use
system
.
io
;
with
system
.
io
;
use
system
.
io
;
with
Interfaces
;
use
Interfaces
;
with
Interfaces
;
use
Interfaces
;
with
Ada
.
Interrupts
,
Ada
.
Interrupts
.
Names
;
use
Ada
.
Interrupts
,
Ada
.
Interrupts
.
Names
;
package
body
displayer
is
type
A_String
is
access
String
;
Person
:
asn1Scctm_t
;
S
:
A_String
;
bTmHasArrived
:
boolean
;
Number
:
asn1SccHK_T_value_to_plot
:=
0
;
HK
:
aliased
asn1SccHK_T
;
procedure
Displayer_Put_TC
(
TC
:
access
asn1SccTC_T
)
is
begin
case
TC
.
Action
.
Kind
is
when
Display_PRESENT
=>
for
J
in
1
..
TC
.
Action
.
Display
.
Length
loop
person
.
data
(
J
)
:=
TC
.
Action
.
Display
.
Data
(
J
);
end
loop
;
Person
.
Length
:=
TC
.
Action
.
Display
.
Length
;
if
(
person
.
length
>
0
)
then
bTmHasArrived
:=
True
;
end
if
;
when
housekeeping_PRESENT
=>
HK
:=
(
Exist
=>
(
Value_To_Plot
=>
1
),
Value_To_Plot
=>
Number
,
Destination
=>
TC
.
Action
.
Housekeeping
);
HousekeepingTM
(
HK
'
access
);
when
others
=>
null
;
end
case
;
end
displayer_put_tc
;
procedure
cyclicdisplayer
is
My_TM
:
aliased
asn1Scctm_t
;
I
:
Integer
;
begin
System
.
IO
.
Put_Line
(
"cyclicdisplayer"
);
if
bTmHasArrived
then
for
i
in
1
..
Person
.
Length
loop
My_TM
.
Data
(
i
)
:=
Person
.
Data
(
i
);
end
loop
;
My_TM
.
Length
:=
Person
.
Length
;
Router_Send_TM
(
My_TM
'
access
);
type
A_String
is
access
String
;
Person
:
asn1Scctm_t
;
S
:
A_String
;
bTmHasArrived
:
Boolean
;
Number
:
asn1SccHK_T_value_to_plot
:=
0
;
HK
:
aliased
asn1SccHK_T
;
-- Add a signal handler: use " pkill -usr1 mypartition " to trigger it
-- it works with both pohic and pohiada
package
Sigusr1_Handler
is
protected
Handler
is
procedure
Handle
;
pragma
Interrupt_Handler
(
Handle
);
pragma
Attach_Handler
(
Handle
,
Sigusr1
);
end
Handler
;
end
Sigusr1_Handler
;
package
body
Sigusr1_Handler
is
protected
body
Handler
is
procedure
Handle
is
begin
System
.
IO
.
Put_Line
(
"Got interrupt!"
);
end
Handle
;
end
Handler
;
end
Sigusr1_Handler
;
procedure
Displayer_Put_TC
(
TC
:
access
asn1SccTC_T
)
is
begin
case
TC
.
Action
.
Kind
is
when
Display_PRESENT
=>
for
J
in
1
..
TC
.
Action
.
Display
.
Length
loop
person
.
data
(
J
)
:=
TC
.
Action
.
Display
.
Data
(
J
);
end
loop
;
Person
.
Length
:=
TC
.
Action
.
Display
.
Length
;
if
(
person
.
length
>
0
)
then
bTmHasArrived
:=
True
;
end
if
;
Number
:=
(
Number
+
1
)
mod
16535
;
end
cyclicdisplayer
;
when
housekeeping_PRESENT
=>
HK
:=
(
Exist
=>
(
Value_To_Plot
=>
1
),
Value_To_Plot
=>
Number
,
Destination
=>
TC
.
Action
.
Housekeeping
);
HousekeepingTM
(
HK
'
access
);
when
others
=>
null
;
end
case
;
end
Displayer_Put_TC
;
procedure
cyclicdisplayer
is
My_TM
:
aliased
asn1Scctm_t
;
I
:
Integer
;
begin
System
.
IO
.
Put_Line
(
"cyclicdisplayer"
);
if
bTmHasArrived
then
for
i
in
1
..
Person
.
Length
loop
My_TM
.
Data
(
i
)
:=
Person
.
Data
(
i
);
end
loop
;
My_TM
.
Length
:=
Person
.
Length
;
router_send_tm
(
My_TM
'
access
);
end
if
;
Number
:=
(
Number
+
1
)
mod
16535
;
end
cyclicdisplayer
;
begin
system
.
io
.
put_line
(
"init of displayer done"
);
person
:=
asn1SccTM_T_Init
;
bTmHasArrived
:=
False
;
system
.
io
.
put_line
(
"init of displayer done"
);
person
:=
asn1SccTM_T_Init
;
bTmHasArrived
:=
False
;
end
displayer
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment