Re: [comedi] Comedi Driver with LPCIe-7250 problem

Ian Abbott <[email protected]> Tue, 27 May 2025 13:23:12 +0100
Newsgroups gmane.linux.comedi
Organization MEV Ltd.
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------nwZuvW7F1ia6SYcuvtpRzzwi
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: quoted-printable

Hi Gus,

On 27/05/2025 08:01, Gus Cerda wrote:
> Hi all,
> I'm working with ADlink LPCIe-7250 and comedi drivers, the driver=20
> loads correctly:
>
> */root@tramuntana:~# lspci | grep -i adlink/*
>
> */41:00.0 DPIO module: Adlink Technology PCI-7250 (rev 01)/*
>
> */
> /*
>
> */root@tramuntana:~# dmesg | grep comedi/*
>
> */[ 3.136992] comedi: loading out-of-tree module taints kernel./*
>
> */[ 3.143073] comedi: version 0.7.76.1 - http://www.comedi.org=20
> <https://cas5-0-urlprotect.trendmicro.com:443/wis/clicktime/v1/query?url=
=3Dhttp%3a%2f%2fwww.comedi.org&umid=3Dee5ef60d-3a1f-11f0-90ed-0022487ef3e8&=
rct=3D1748256931&auth=3D84fd7b44f3c6e5843978f04d97647fc72161b300-d6755bb34c=
5622b9b70ff2815b8ad8e134942afc>/*
>
> */[ 3.162617] comedi0: adl_pci7250/*
>
> */[ 3.162799] comedi: base addr 92001000/*
>
> */[ 3.162804] comedi: attached/*
>
> But when I try to capture channel 0 with this sample code:
>
> */#include <comedilib.h>
> #include <stdio.h>
> int main()
> {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 comedi_t *dev =3D comedi_open("/dev/comedi0")=
;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!dev) { perror("comedi_open");
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 int value;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 comedi_dio_read(dev, 1, 0, &value); // Read s=
ubdevice 1, channel 0
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("Input value: %d\n", value);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0comedi_close(dev);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
> }/*
>
> I'm always receiving a "1", independently of applying voltage or not=20
> to the input.
>
> The card works fine in windows environment, for this input.
>
> Could someone give me an advice or something to look in order to make=20
> the card work under Linux?
>
Apparently, I wrote this driver in 2015 (which was a surprise to me as=20
I'd forgotten writing it!), based on the fairly simple register layout=20
from the user manual, but I didn't test it myself. It was reported=20
working by Emma Peace in this email:

https://groups.google.com/g/comedi_list/c/RaQGeavOr0U/m/aa-EadJxy8AJ

She wrote that she had tested input and output fairly heavily without=20
any problems.

I don't know why it is not working for you. It's a fairly simple driver.

Could you try reading all dio inputs at once as a bitmask using the=20
following sample code?

#include <comedilib.h>
#include <stdio.h>
int main()
{
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_t *dev =3D comedi_open("=
/dev/comedi0");
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!dev) { perror("comedi_open=
");
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 1;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int bits;
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_dio_bitfield(dev, 1, 0, =
&bits); // Get bits from subdevice 1
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf("Input bits: 0x%08X\n", =
bits);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_close(dev);
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
}

This will read all 32 digital inputs as a 32-bit value, although only=20
channels 0 to 7 will be valid on the LPCIe-7250. (The other 24 channels=20
are for the PCI-7250 with PCI-7251 extension cards fitted.) These 32=20
inputs are read from register offsets 1, 3, 5, and 7, 8 bits per=20
register. (Register offsets 0, 2, 4, and 6, 8 bits per register are used=20
to control the relays.)

Looking at the manual, one other thing to check is that the input signal=20
jumpers JP1 to JP8 on the board are set to position 2-3 for=20
Non-AC-Filter (DC signal), although it's probably OK as you already=20
tested the input in Windows.


I should really port this driver (assuming it is not completely broken)=20
for inclusion in the Linux kernel. I probably meant to do that 10 years ago=
!

> Thank you in advance.
>
I hope you manage to get it working!

Ian

--=20
-=3D( Ian Abbott<[email protected]> || MEV Ltd. is a company  )=3D-
-=3D( registered in England & Wales.  Regd. number: 02862268.  )=3D-
-=3D( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=3D-
-=3D( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. ||www.mev.co.uk )=3D-

--=20
You received this message because you are subscribed to the Google Groups "=
Comedi: Linux Control and Measurement Device Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/comedi_list=
/ef9928ae-e9c5-4f24-bcfc-e4284b3ed703%40mev.co.uk.

--------------nwZuvW7F1ia6SYcuvtpRzzwi
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8=
">
  </head>
  <body>
    <div class=3D"moz-cite-prefix">Hi Gus,</div>
    <div class=3D"moz-cite-prefix"><br>
    </div>
    <div class=3D"moz-cite-prefix">On 27/05/2025 08:01, Gus Cerda wrote:<br=
>
    </div>
    <blockquote type=3D"cite"
      cite=3D"mid:[email protected]">
      <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF=
-8">
      Hi all,
      <div>I'm working with ADlink LPCIe-7250 and comedi drivers, the
        driver loads correctly:</div>
      <div>
        <p><b><i><span style=3D"font-family: &quot;Courier New&quot;;">root=
@tramuntana:~#
                lspci | grep -i adlink</span></i></b></p>
        <p>
        </p>
        <p><b><i><span style=3D"font-family: &quot;Courier New&quot;;">41:0=
0.0
                DPIO module: Adlink Technology
                PCI-7250 (rev 01)</span></i></b></p>
        <p><b><i><br>
            </i></b></p>
        <p><b><i><font face=3D"Courier New">root@tramuntana:~#
                dmesg | grep comedi</font></i></b></p>
        <p><b><i><font face=3D"Courier New">[=C2=A0=C2=A0=C2=A0
                3.136992] comedi: loading out-of-tree module taints
                kernel.</font></i></b></p>
        <p><b><i><font face=3D"Courier New">[=C2=A0=C2=A0=C2=A0
                3.143073] comedi: version 0.7.76.1 - <a
href=3D"https://cas5-0-urlprotect.trendmicro.com:443/wis/clicktime/v1/query=
?url=3Dhttp%3a%2f%2fwww.comedi.org&amp;umid=3Dee5ef60d-3a1f-11f0-90ed-00224=
87ef3e8&amp;rct=3D1748256931&amp;auth=3D84fd7b44f3c6e5843978f04d97647fc7216=
1b300-d6755bb34c5622b9b70ff2815b8ad8e134942afc"
                  target=3D"_blank" moz-do-not-send=3D"true">http://www.com=
edi.org</a></font></i></b></p>
        <p><b><i><font face=3D"Courier New">[=C2=A0=C2=A0=C2=A0
                3.162617] comedi0: adl_pci7250</font></i></b></p>
        <p><b><i><font face=3D"Courier New">[=C2=A0=C2=A0=C2=A0
                3.162799] comedi: base addr 92001000</font></i></b></p>
        <p><b><i><font face=3D"Courier New">[=C2=A0=C2=A0=C2=A0
                3.162804] comedi: attached</font></i></b></p>
        <p>But when I try to capture channel 0 with this sample code:</p>
        <p><b><i>#include &lt;comedilib.h&gt;<br>
              #include &lt;stdio.h&gt;<br>
              int main()<br>
              {<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 comedi_t *dev =3D comedi_open("/d=
ev/comedi0");<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!dev) { perror("comedi_open")=
;<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1;<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 int value;<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 comedi_dio_read(dev, 1, 0, &amp;v=
alue); // Read
              subdevice 1, channel 0<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("Input value: %d\n", value=
);<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0comedi_close(dev);<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;<br>
              }</i></b><br>
        </p>
        <p>I'm always receiving a "1", independently of applying voltage
          or not to the input.=C2=A0</p>
        <p>The card works fine in windows environment, for this input.</p>
        <p>Could someone give me an advice or something to look in order
          to make the card work under Linux?</p>
      </div>
    </blockquote>
    <p>Apparently, I wrote this driver in 2015 (which was a surprise to
      me as I'd forgotten writing it!), based on the fairly simple
      register layout from the user manual, but I didn't test it myself.
      It was reported working by Emma Peace in this email:<br>
    </p>
    <p><a
href=3D"https://groups.google.com/g/comedi_list/c/RaQGeavOr0U/m/aa-EadJxy8A=
J"
        class=3D"moz-txt-link-freetext">https://groups.google.com/g/comedi_=
list/c/RaQGeavOr0U/m/aa-EadJxy8AJ</a><br>
    </p>
    <p>She wrote that she had tested input and output fairly heavily
      without any problems.</p>
    <p>I don't know why it is not working for you. It's a fairly simple
      driver.</p>
    <p>Could you try reading all dio inputs at once as a bitmask using
      the following sample code?</p>
    <pre>#include &lt;comedilib.h&gt;
#include &lt;stdio.h&gt;
int main()
{
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_t *dev =3D comedi_open("/=
dev/comedi0");
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!dev) { perror("comedi_open"=
);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 1;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int bits;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_dio_bitfield(dev, 1, 0, &=
amp;bits); // Get bits from subdevice 1
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf("Input bits: 0x%08X\n", b=
its);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 comedi_close(dev);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
}
</pre>
    <p>This will read all 32 digital inputs as a 32-bit value, although
      only channels 0 to 7 will be valid on the LPCIe-7250. (The other
      24 channels are for the PCI-7250 with PCI-7251 extension cards
      fitted.) These 32 inputs are read from register offsets 1, 3, 5,
      and 7, 8 bits per register. (Register offsets 0, 2, 4, and 6, 8
      bits per register are used to control the relays.)<br>
    </p>
    <p>Looking at the manual, one other thing to check is that the input
      signal jumpers JP1 to JP8 on the board are set to position 2-3 for
      Non-AC-Filter (DC signal), although it's probably OK as you
      already tested the input in Windows.</p>
    <p><br>
    </p>
    <p>I should really port this driver (assuming it is not completely
      broken) for inclusion in the Linux kernel. I probably meant to do
      that 10 years ago!<br>
    </p>
    <blockquote type=3D"cite"
      cite=3D"mid:[email protected]">
      <div>
        <p>Thank you in advance.</p>
      </div>
    </blockquote>
    <p>I hope you manage to get it working!<br>
    </p>
    <p>Ian<br>
    </p>
    <pre class=3D"moz-signature" cols=3D"72">--=20
-=3D( Ian Abbott <a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:abbotti@=
mev.co.uk">&lt;[email protected]&gt;</a> || MEV Ltd. is a company  )=3D-
-=3D( registered in England &amp; Wales.  Regd. number: 02862268.  )=3D-
-=3D( Regd. addr.: S11 &amp; 12 Building 67, Europa Business Park, )=3D-
-=3D( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || <a class=3D"moz-txt-link-a=
bbreviated" href=3D"http://www.mev.co.uk">www.mev.co.uk</a> )=3D-</pre>
  </body>
</html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Comedi: Linux Control and Measurement Device Interface&quot; group.<br=
 />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">comedi_=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
comedi_list/ef9928ae-e9c5-4f24-bcfc-e4284b3ed703%40mev.co.uk?utm_medium=3De=
mail&utm_source=3Dfooter">https://groups.google.com/d/msgid/comedi_list/ef9=
928ae-e9c5-4f24-bcfc-e4284b3ed703%40mev.co.uk</a>.<br />

--------------nwZuvW7F1ia6SYcuvtpRzzwi--