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

Gus Cerda <[email protected]> Tue, 27 May 2025 05:37:03 -0700 (PDT)
Newsgroups gmane.linux.comedi
Message-ID <[email protected]>
------=_Part_309902_1178778849.1748349423852
Content-Type: multipart/alternative; 
	boundary="----=_Part_309903_899457549.1748349423852"

------=_Part_309903_899457549.1748349423852
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Ian,

This is the output without any input signals:

Input bits: 0x000000C1

Exciting some inputs doesn't make a difference. Any further test that I can=
=20
make to check any incompatibility with current Kernels?

Thank you so much!!

El martes, 27 de mayo de 2025 a las 14:23:18 UTC+2, Ian Abbott escribi=C3=
=B3:

> Hi Gus,
>
> On 27/05/2025 08:01, Gus Cerda wrote:
>
> Hi all,=20
> I'm working with ADlink LPCIe-7250 and comedi drivers, the driver loads=
=20
> 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() {         comedi_t=
=20
> *dev =3D comedi_open("/dev/comedi0");         if (!dev) {=20
> perror("comedi_open");         return 1;          }         int value;   =
 =20
>     comedi_dio_read(dev, 1, 0, &value); // Read subdevice 1, channel 0   =
 =20
>     printf("Input value: %d\n", value);         comedi_close(dev);       =
 =20
> return 0; }*
>
> I'm always receiving a "1", independently of applying voltage or not to=
=20
> the input.=20
>
> The card works fine in windows environment, for this input.
>
> Could someone give me an advice or something to look in order to make the=
=20
> card work under Linux?
>
> Apparently, I wrote this driver in 2015 (which was a surprise to me as I'=
d=20
> forgotten writing it!), based on the fairly simple register layout from t=
he=20
> user manual, but I didn't test it myself. It was reported working by Emma=
=20
> 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 any=
=20
> 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()
> {
>         comedi_t *dev =3D comedi_open("/dev/comedi0");
>         if (!dev) { perror("comedi_open");
>         return 1;
>          }
>         unsigned int bits;
>         comedi_dio_bitfield(dev, 1, 0, &bits); // Get bits from subdevice=
 1
>         printf("Input bits: 0x%08X\n", bits);
>         comedi_close(dev);
>         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 a=
re=20
> for the PCI-7250 with PCI-7251 extension cards fitted.) These 32 inputs a=
re=20
> read from register offsets 1, 3, 5, and 7, 8 bits per register. (Register=
=20
> offsets 0, 2, 4, and 6, 8 bits per register are used to control the relay=
s.)
>
> 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 Non-AC-Filter=
=20
> (DC signal), although it's probably OK as you already tested the input in=
=20
> 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 a=
go!
>
> 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=
/eb9922e1-5c85-4f96-a4d0-1972be315604n%40googlegroups.com.

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

Hi Ian,<div><br /></div><div>This is the output without any input signals:<=
/div><div><br /></div><div>Input bits: 0x000000C1</div><div><br /></div><di=
v>Exciting some inputs doesn't make a difference. Any further test that I c=
an make to check any incompatibility with current Kernels?</div><div><br />=
</div><div>Thank you so much!!<br /><br /></div><div class=3D"gmail_quote">=
<div dir=3D"auto" class=3D"gmail_attr">El martes, 27 de mayo de 2025 a las =
14:23:18 UTC+2, Ian Abbott escribi=C3=B3:<br/></div><blockquote class=3D"gm=
ail_quote" style=3D"margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;"><u></u>

 =20
   =20
 =20
  <div>
    <div>Hi Gus,</div></div><div>
    <div><br>
    </div>
    <div>On 27/05/2025 08:01, Gus Cerda wrote:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      Hi all,
      <div>I&#39;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@t=
ramuntana:~#
                lspci | grep -i adlink</span></i></b></p>
        <p>
        </p>
        <p><b><i><span style=3D"font-family:&quot;Courier New&quot;">41:00.=
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://cas=
5-0-urlprotect.trendmicro.com:443/wis/clicktime/v1/query?url=3Dhttp%3a%2f%2=
fwww.comedi.org&amp;umid=3Dee5ef60d-3a1f-11f0-90ed-0022487ef3e8&amp;rct=3D1=
748256931&amp;auth=3D84fd7b44f3c6e5843978f04d97647fc72161b300-d6755bb34c562=
2b9b70ff2815b8ad8e134942afc" target=3D"_blank" rel=3D"nofollow" data-safere=
directurl=3D"https://www.google.com/url?hl=3Des&amp;q=3Dhttps://cas5-0-urlp=
rotect.trendmicro.com:443/wis/clicktime/v1/query?url%3Dhttp%253a%252f%252fw=
ww.comedi.org%26umid%3Dee5ef60d-3a1f-11f0-90ed-0022487ef3e8%26rct%3D1748256=
931%26auth%3D84fd7b44f3c6e5843978f04d97647fc72161b300-d6755bb34c5622b9b70ff=
2815b8ad8e134942afc&amp;source=3Dgmail&amp;ust=3D1748435144377000&amp;usg=
=3DAOvVaw09xj2aCWIsROkROnpBZ-Lt">http://www.comedi.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(&qu=
ot;/dev/comedi0&quot;);<br>
              =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!dev) { perror(&quot;comedi_o=
pen&quot;);<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(&quot;Input value: %d\n&qu=
ot;, 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&#39;m always receiving a &quot;1&quot;, independently of apply=
ing 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>
    </div><div><p>Apparently, I wrote this driver in 2015 (which was a surp=
rise to
      me as I&#39;d forgotten writing it!), based on the fairly simple
      register layout from the user manual, but I didn&#39;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/a=
a-EadJxy8AJ" target=3D"_blank" rel=3D"nofollow" data-saferedirecturl=3D"htt=
ps://www.google.com/url?hl=3Des&amp;q=3Dhttps://groups.google.com/g/comedi_=
list/c/RaQGeavOr0U/m/aa-EadJxy8AJ&amp;source=3Dgmail&amp;ust=3D174843514437=
7000&amp;usg=3DAOvVaw3v1N8qBv1AB_heVFzhu6Cn">https://groups.google.com/g/co=
medi_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&#39;t know why it is not working for you. It&#39;s a fairly si=
mple
      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(&q=
uot;/dev/comedi0&quot;);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!dev) { perror(&quot;comedi_=
open&quot;);
=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(&quot;Input bits: 0x%08X\=
n&quot;, 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;
}
</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&#39;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">
      <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 cols=3D"72">--=20
-=3D( Ian Abbott <a href data-email-masked rel=3D"nofollow">&lt;abb...@mev.=
co.uk&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 href=3D"http://www.mev.=
co.uk" target=3D"_blank" rel=3D"nofollow" data-saferedirecturl=3D"https://w=
ww.google.com/url?hl=3Des&amp;q=3Dhttp://www.mev.co.uk&amp;source=3Dgmail&a=
mp;ust=3D1748435144377000&amp;usg=3DAOvVaw1k2Gky4JyJbTGNDXwb9Sfg">www.mev.c=
o.uk</a> )=3D-</pre>
  </div>

</blockquote></div>

<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/eb9922e1-5c85-4f96-a4d0-1972be315604n%40googlegroups.com?utm_me=
dium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/comedi_=
list/eb9922e1-5c85-4f96-a4d0-1972be315604n%40googlegroups.com</a>.<br />

------=_Part_309903_899457549.1748349423852--

------=_Part_309902_1178778849.1748349423852--