* Re: .h header file in ObjectAda 8.2.2 source code?
2013-07-20 5:41 ` Randy Brukardt
@ 2013-07-22 19:06 ` dd24fan
2013-07-22 19:08 ` dd24fan
2013-07-22 19:50 ` dd24fan
2 siblings, 0 replies; 11+ messages in thread
From: dd24fan @ 2013-07-22 19:06 UTC (permalink / raw)
Thanks for the insight. My latest debugging efforts have pointed me to the Initialization of the device. I do have a compare of what the C code is doing because the vendor has software in a analyzer/simulator that i was able to run.
Here is the snippet of the C code:
==============
.
.
.
S16BIT s16Result = 0x0000;
S16BIT s16DevNum = LOGICAL_DEVICE_NUMBER;
.
.
/* Initialize device */
s16Result = Initialize(s16DevNum, ACCESS_CARD, MODE, 0, 0, 0);
.
.
==============
ACCESS_CARD is defined as 16BIT
MODE is U16BIT
The last 3 parameters are defined U32BIT
so in my latest ada code i have this:
==============
.
.
function Initialize (DevNum : S16Bit_Type;
wAccess: S16Bit_Type;
Mode : U16Bit_Type;
Mem_Wrd_Size : U32Bit_Type;
Reg_Addr : U32Bit_Type;
Mem_Addr : U32Bit_Type
) return S16Bit_Type;
pragma Import (Stdcall, Initialize, "Initialize");
.
.
procedure Open (Device_Num : in S16Bit_Type;
Is_Open : in out Boolean;
Good : out Boolean) is
Result : S16Bit_Type;
ACCESS_CARD : U16Bit_Type := 16#0000#;
MODE : 16Bit_Type := 1;
.
.
begin
Good := False;
Results := Gb.Msgbox(Text => "procedure Open begin",
Caption => "procedure Open begin",
Style => 4,
Handle => Gb.Handle(Form));
-- Initialize device
Result := Initialize (S16Bit_Type (Device_Num),
ACCESS_CARD,
MODE,
16#00000000#,
16#00000000#,
16#00000000#);
Print (Device_Num, "Initialize => ", Result);
Results := Gb.Msgbox(Text => "Initialized?",
Caption => "Initialized?",
Style => 4,
Handle => Gb.Handle(Form));
.
.
.
==============
Some notes: Device_Num is originally defined as an integer elsewhere in the code so I type cast it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: .h header file in ObjectAda 8.2.2 source code?
2013-07-20 5:41 ` Randy Brukardt
2013-07-22 19:06 ` dd24fan
@ 2013-07-22 19:08 ` dd24fan
2013-07-22 20:04 ` Niklas Holsti
2013-07-22 19:50 ` dd24fan
2 siblings, 1 reply; 11+ messages in thread
From: dd24fan @ 2013-07-22 19:08 UTC (permalink / raw)
Thanks for the insight. My latest debugging efforts have pointed me to the Initialization of the device. I do have a compare of what the C code is doing because the vendor has software in a analyzer/simulator that i was able to run.
Here is the snippet of the C code:
==============
.
.
.
S16BIT s16Result = 0x0000;
S16BIT s16DevNum = LOGICAL_DEVICE_NUMBER;
.
.
/* Initialize device */
s16Result = Initialize(s16DevNum, ACCESS_CARD, MODE, 0, 0, 0);
.
.
==============
ACCESS_CARD is defined as 16BIT
MODE is U16BIT
The last 3 parameters are defined U32BIT
so in my latest ada code i have this:
==============
.
.
function Initialize (DevNum : S16Bit_Type;
wAccess: S16Bit_Type;
Mode : U16Bit_Type;
Mem_Wrd_Size : U32Bit_Type;
Reg_Addr : U32Bit_Type;
Mem_Addr : U32Bit_Type
) return S16Bit_Type;
pragma Import (Stdcall, Initialize, "Initialize");
.
.
procedure Open (Device_Num : in S16Bit_Type;
Is_Open : in out Boolean;
Good : out Boolean) is
Result : S16Bit_Type;
ACCESS_CARD : U16Bit_Type := 16#0000#;
MODE : S16Bit_Type := 1;
.
.
begin
Good := False;
Results := Gb.Msgbox(Text => "procedure Open begin",
Caption => "procedure Open begin",
Style => 4,
Handle => Gb.Handle(Form));
-- Initialize device
Result := Initialize (S16Bit_Type (Device_Num),
ACCESS_CARD,
MODE,
16#00000000#,
16#00000000#,
16#00000000#);
Print (Device_Num, "Initialize => ", Result);
Results := Gb.Msgbox(Text => "Initialized?",
Caption => "Initialized?",
Style => 4,
Handle => Gb.Handle(Form));
.
.
.
==============
Some notes: Device_Num is originally defined as an integer elsewhere in the code so I type cast it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: .h header file in ObjectAda 8.2.2 source code?
2013-07-22 19:08 ` dd24fan
@ 2013-07-22 20:04 ` Niklas Holsti
2013-07-23 12:05 ` dd24fan
0 siblings, 1 reply; 11+ messages in thread
From: Niklas Holsti @ 2013-07-22 20:04 UTC (permalink / raw)
On 13-07-22 22:08 , dd24fan wrote:
> Thanks for the insight. My latest debugging efforts have pointed me
> to the Initialization of the device. I do have a compare of what
> the C code is doing because the vendor has software in a
> analyzer/simulator that i was able to run.
>
> Here is the snippet of the C code:
>
> ==============
> .
> .
> .
> S16BIT s16Result = 0x0000;
> S16BIT s16DevNum = LOGICAL_DEVICE_NUMBER;
> .
> .
> /* Initialize device */
> s16Result = Initialize(s16DevNum, ACCESS_CARD, MODE, 0, 0, 0);
> .
> .
> ==============
> ACCESS_CARD is defined as 16BIT
> MODE is U16BIT
Are those the types of the variables ACCESS_CARD and MODE -- the actual
parameters in the Initialize call -- or the types of the corresponding
formal parameters of Initialize? In other words, how is Initialize
declared in the .h file? The actual and formal types in C are not
necessarily the same, since C converts automatically. For the Ada
declaration, you should use the formal types.
Also, what are the values of ACCESS_CARD and MODE in the C program?
> The last 3 parameters are defined U32BIT
>
> so in my latest ada code i have this:
> ==============
> .
> .
> function Initialize (DevNum : S16Bit_Type;
> wAccess: S16Bit_Type;
> Mode : U16Bit_Type;
> Mem_Wrd_Size : U32Bit_Type;
> Reg_Addr : U32Bit_Type;
> Mem_Addr : U32Bit_Type
> ) return S16Bit_Type;
> pragma Import (Stdcall, Initialize, "Initialize");
> .
> .
> procedure Open (Device_Num : in S16Bit_Type;
> Is_Open : in out Boolean;
> Good : out Boolean) is
>
> Result : S16Bit_Type;
>
> ACCESS_CARD : U16Bit_Type := 16#0000#;
> MODE : S16Bit_Type := 1;
I assume that these values of ACCESS_CARD and MODE match the values used
in the C program, right?
> Result := Initialize (S16Bit_Type (Device_Num),
> ACCESS_CARD,
> MODE,
> 16#00000000#,
> 16#00000000#,
> 16#00000000#);
(You could as well write the three last parameters using a single "0"
for each, just as in the C code. The hexadecimal base and the multiple
zeros make no difference.)
> Some notes: Device_Num is originally defined as an integer
> elsewhere in the code so I type cast it.
That seems unnecessary, if (as your code suggests) this Device_Num is
the parameter to the Open procedure, because that parameter is declared
as S16Bit_Type, so there is no need to convert it to S16Bit_Type in the
calls. (But it does no harm either.)
You didn't say if this Ada code still hangs. Does it?
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: .h header file in ObjectAda 8.2.2 source code?
2013-07-22 20:04 ` Niklas Holsti
@ 2013-07-23 12:05 ` dd24fan
0 siblings, 0 replies; 11+ messages in thread
From: dd24fan @ 2013-07-23 12:05 UTC (permalink / raw)
> Are those the types of the variables ACCESS_CARD and MODE -- the actual parameters in the Initialize call -- or the types of the corresponding formal parameters of Initialize?
> In other words, how is Initialize declared in the .h file? The actual and formal types in C are not necessarily the same, since C converts automatically. For the Ada declaration, you should use the formal types.
> Also, what are the values of ACCESS_CARD and MODE in the C program?
Yes, the variables are the actual parameters in the call.
in the .h the code is like this:
.
.
/* wAccess can be one of the following */ Note:(Just listing the one I need)
#define ACCESS_CARD 0 /* card running on W32 OS */
/* wMode parameter can be one of the following */ Note:(Just listing the one I need)
#define MODE 0x0001 /* mode */
.
.
_EXTERN S16BIT _DECL _Initialize(S16BIT DevNum, U16BIT wAccess, U16BIT wMode, U32BIT dwMemWrdSize, U32BIT dwRegAddr, U32BIT dwMemAddr);
.
.
> I assume that these values of ACCESS_CARD and MODE match the values used in the C program, right?
Yes, that's right.
> You didn't say if this Ada code still hangs. Does it?
Yes, the application is still hung up.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: .h header file in ObjectAda 8.2.2 source code?
2013-07-20 5:41 ` Randy Brukardt
2013-07-22 19:06 ` dd24fan
2013-07-22 19:08 ` dd24fan
@ 2013-07-22 19:50 ` dd24fan
2 siblings, 0 replies; 11+ messages in thread
From: dd24fan @ 2013-07-22 19:50 UTC (permalink / raw)
Thanks for the insight. My latest debugging efforts have pointed me to the Initialization of the device. I do have a compare of what the C code is doing because the vendor has software in a analyzer/simulator that i was able to run.
Here is the snippet of the C code:
==============
.
.
.
S16BIT s16Result = 0x0000;
S16BIT s16DevNum = LOGICAL_DEVICE_NUMBER;
.
.
/* Initialize device */
s16Result = Initialize(s16DevNum, ACCESS_CARD, MODE, 0, 0, 0);
.
.
==============
ACCESS_CARD is defined as S16BIT
MODE is U16BIT
The last 3 parameters are defined U32BIT
so in my latest ada code i have this:
==============
.
.
function Initialize (DevNum : S16Bit_Type;
wAccess: S16Bit_Type;
Mode : U16Bit_Type;
Mem_Wrd_Size : U32Bit_Type;
Reg_Addr : U32Bit_Type;
Mem_Addr : U32Bit_Type
) return S16Bit_Type;
pragma Import (Stdcall, Initialize, "Initialize");
.
.
procedure Open (Device_Num : in S16Bit_Type;
Is_Open : in out Boolean;
Good : out Boolean) is
Result : S16Bit_Type;
ACCESS_CARD : S16Bit_Type := 0;
MODE : U16Bit_Type := 16#0001#;
.
.
begin
Good := False;
Results := Gb.Msgbox(Text => "procedure Open begin",
Caption => "procedure Open begin",
Style => 4,
Handle => Gb.Handle(Form));
-- Initialize device
Result := Initialize (S16Bit_Type (Device_Num),
ACCESS_CARD,
MODE,
16#00000000#,
16#00000000#,
16#00000000#);
Print (Device_Num, "Initialize => ", Result);
Results := Gb.Msgbox(Text => "Initialized?",
Caption => "Initialized?",
Style => 4,
Handle => Gb.Handle(Form));
.
.
.
==============
Some notes: Device_Num is originally defined as an integer elsewhere in the code so I type cast it.
^ permalink raw reply [flat|nested] 11+ messages in thread