From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: .h header file in ObjectAda 8.2.2 source code? Date: Mon, 22 Jul 2013 23:04:10 +0300 Organization: Tidorum Ltd Message-ID: References: <54f7f0d4-29ef-4de0-94d8-8320e8df24e2@googlegroups.com> <18255aa3-c926-4e18-a8a6-d19fe6b3ad93@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net GLLgKoudXOFFzIz0jfFWVQu88WPlRvP/GDOa+q0Bxqi/dvj9xL Cancel-Lock: sha1:Mfjw/FbRGdYmRzzzwIf1JdbrlDg= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <18255aa3-c926-4e18-a8a6-d19fe6b3ad93@googlegroups.com> Xref: news.eternal-september.org comp.lang.ada:16484 Date: 2013-07-22T23:04:10+03:00 List-Id: 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 . @ .