Recent

Author Topic: NIDAQmxBase header translation  (Read 52439 times)

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #30 on: November 14, 2014, 07:00:59 pm »
Hi,

I added some code examples to wiki there http://wiki.lazarus.freepascal.org/NI-DAQmx_and_NI-DAQmx_Base_examples.
I continue with code examples adding in next days: digital port input/output, counter.

I will be glad, if someone else check it or add something new.  ::)

There is one question, where we can store and maintain nidaqmx.pas and nidaqmxbase.pas
« Last Edit: December 11, 2014, 03:17:11 pm by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #31 on: December 11, 2014, 02:00:51 pm »
Hi, mig-31

I read your nice code examples.
We are waiting for your store.
Thanks.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #32 on: December 11, 2014, 03:30:48 pm »
Hi,

I hope it will be useful for others.

We are waiting for your store.
I don't understand for what you are waiting for.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #33 on: December 11, 2014, 09:49:08 pm »
Hi,mig-31

Thankful for your reply.

I want the "nidaqmx.pas" you used for "wiki code examples".
I'd like to confirm the movement of your examples.

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: NIDAQmxBase header translation
« Reply #34 on: December 11, 2014, 10:49:14 pm »
Good job!
Or I suppose so, since I have not tested ;)
 
There is one question, where we can store and maintain nidaqmx.pas and nidaqmxbase.pas
SorceForge, for example.
I think my bindings for dynamical linking are there.
« Last Edit: December 11, 2014, 10:52:01 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #35 on: December 15, 2014, 09:46:31 am »
I want the "nidaqmx.pas" you used for "wiki code examples".
I'd like to confirm the movement of your examples.

I'm glad to hear it.
Could you test analog output? I will add an analog output example, but I don't have any hardware with analog output to test it.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #36 on: December 15, 2014, 09:48:38 pm »
Hi, mig-31 and Paskal
I'm glad about your reply.

I'd like to confirm of all your examples.

Next...
Continuous sampling above 200kHz 10 seconds.
a: Analog 16bit Differential 3-ch sametime input.
b: A B Z Encoder input.

And...
c: a,b sametime input.

For a while, I have a NI USB-6356.

Thanks.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #37 on: December 17, 2014, 09:28:30 am »
Hi,

It is nice to hear it.

I added NI USB-6356 to wiki.

I see, this card have 2 analog outputs. I will add example for analog output to wiki. Please test it.

Thanks.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #38 on: December 23, 2014, 10:07:05 am »
Hi, mig-31

I fail at the first stage.

When I compiled your "devicelist" by arrangement of default, the next error occurred.
.nidaqmx.pas(61,109) Error: Type identifire expected
.nidaqmx.pas(61,109) Fatal: Syntax error. ")" expected but "CONST" found

( Line61: function DAQmxGetTaskAttribute(taskHandle:TaskHandle; attribute:longint; value:pointer; args:array of const):longint;cdecl;external External_library name 'DAQmxGetTaskAttribute';

109: array of const )

Environment
.Windows7 32Bit
.Lazarus Ver.1.2.6
.NI-DAQmx 14.0

I'm a beginner about
.Linux
.Lazarus...

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #39 on: December 28, 2014, 10:42:26 pm »
Hi, Tonbo
I'm on vacation until 5-th of January. Out of work I use only Linux and I haven't any device. I check it after vacation.

From you description, I think you should check line before, if you have this symbol ")" or you have const word.

Upload you project in .zip here to check error without exe file.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #40 on: January 07, 2015, 08:29:22 am »
Hi, mig-31

How was a vacation?
I have just taken short vacation days, too.

When you'll check it, I'm happy.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #41 on: January 07, 2015, 01:16:26 pm »
Hi,
If you open nidaqmx unit, you see that nidaqmx in your project is for linux 32-bit.
If I replace it by nidaqmx Windows unit and try to compile your project I get a same error as you.
But when i create new program and copy/paste code, I compile it without error.
There is a zip project file.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #42 on: January 08, 2015, 03:42:42 am »
Hi, mig-31

Thank you very much.
I moved safely and was shown as follows.
  -------------------------------------------------------------
  |Device name | Product Type | # Serial number | Is Simulated?
  -------------------------------------------------------------
  |Dev1 | USB-6356 (64 MS) | $015714C0 |No

5 hours have not passed yet from my UP.
It's miracle.

If possible, please tell me.
What kind of tool did you use? H2Pas?
I couldn't use it well.

I'll test your sample programs.
Please wait for some days.

Thanks.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #43 on: January 08, 2015, 01:36:11 pm »
If possible, please tell me.
What kind of tool did you use? H2Pas?
I couldn't use it well.
Hi, tonbo
If you mean translation tool C headers to Pascal bindings, in our case nidaqmx.h to nidaqmx.pas, yes I use h2pas tool.
In case of nidaqmx.h, there are some issues: you should wrap lines with length more than 255 number of letters(chars) and remove C macros. I think, before translation I devided nidaqmx.h on three parts: part with constants definitions, part with function...
Usually I divide big C header on parts, befor translation.
For wrapping lines I use KWrite text editor under linux.
« Last Edit: January 08, 2015, 02:13:12 pm by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #44 on: January 09, 2015, 10:18:20 am »
Hi, mig-31

Thank you very much for your a lot of hints.
I'd like to try someday.

Now, I tested the 'diport' of your sample program.

Your original cord is the 'diport(original).zip'.
Several compile errors occurred by Windows7 32bit.
(Sorry, I can't deal with Linux.)

I rewrote the part of the cord and made them move.
Changed one is the 'diport(change).zip'.
Those changes were marked by '//change'.

Screen indication

  number of readed samples: 10
  data (0) = %00000000
  data [1] = %00000000
  data [2] = %00000000
  data [3] = %00000000
  data [4] = %00000000
  data [5] = %00000000
  data [6] = %00000000
  data [7] = %00000000
  data [8] = %00000000
  data [9] = %00000000

The easy explanation

(a)nidaqmx.pas

I changed it as follows according to the function of 'NIDAQmx.h'.

.function DAQmxCreateTask(taskName:PChar; var taskHandle:TTaskHandle):LongInt;stdcall;external External_library name 'DAQmxCreateTask';
 ->
 function DAQmxCreateTask(taskName:PChar; taskHandle:TTaskHandle):LongInt;stdcall;external External_library name 'DAQmxCreateTask';

.function DAQmxReadDigitalU8(taskHandle:TTaskHandle; numSampsPerChan:LongInt; timeout:Double; fillMode:Cardinal; var readArray:Byte;
           arraySizeInSamps:Cardinal; var sampsPerChanRead:LongInt; reserved:Pointer):LongInt;stdcall;external External_library name 'DAQmxReadDigitalU8';
 ->
 function DAQmxReadDigitalU8(taskHandle:TTaskHandle; numSampsPerChan:LongInt; timeout:Double; fillMode:Cardinal; readArray:PByte;
           arraySizeInSamps:Cardinal; sampsPerChanRead:PLongInt; reserved:Pointer):LongInt;stdcall;external External_library name 'DAQmxReadDigitalU8';

(b)diport.lpr

'ATaskHandle' on the calling side is a Pointer.
So,

.procedure ErrorCheck(AError:longint;ATaskHandle:longint);
 ->
 procedure ErrorCheck(AError:longint;ATaskHandle:Plongint);

.if DITaskHandle<>0 then begin
 ->
 if DITaskHandle^<>0 then begin

Those change may not be best.

Thanks.

 

TinyPortal © 2005-2018