1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
|
<?xml version='1.0' ?> <!-- -*- xml -*- -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY libieee1284 "libieee1284">
<!ENTITY e1284ok "<errorcode>E1284_OK</errorcode>">
<!ENTITY e1284nomem "<errorcode>E1284_NOMEM</errorcode>">
<!ENTITY e1284notavail "<errorcode>E1284_NOTAVAIL</errorcode>">
<!ENTITY e1284notimpl "<errorcode>E1284_NOTIMPL</errorcode>">
<!ENTITY e1284init "<errorcode>E1284_INIT</errorcode>">
<!ENTITY e1284negfailed "<errorcode>E1284_NEGFAILED</errorcode>">
<!ENTITY e1284rejected "<errorcode>E1284_REJECTED</errorcode>">
<!ENTITY e1284timedout "<errorcode>E1284_TIMEDOUT</errorcode>">
<!ENTITY e1284sys "<errorcode>E1284_SYS</errorcode>">
<!ENTITY e1284noid "<errorcode>E1284_NOID</errorcode>">
<!ENTITY e1284invalidport "<errorcode>E1284_INVALIDPORT</errorcode>">
]>
<book id="index">
<bookinfo>
<title>Public interface of &libieee1284;</title>
<subtitle>API 3.2</subtitle>
<author>
<firstname>Tim</firstname>
<surname>Waugh</surname>
<affiliation>
<address><email>twaugh@redhat.com</email></address>
</affiliation>
</author>
<copyright>
<year>2001-2003</year>
<holder>Tim Waugh</holder>
</copyright>
</bookinfo>
<preface>
<title>Introduction</title>
<refentry>
<refmeta>
<refentrytitle>&libieee1284;</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>&libieee1284;</refname>
<refpurpose>IEEE1284 communications library</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
#include <ieee1284.h>
cc files... -lieee1284</synopsis>
</refsynopsisdiv>
<refsect1><title>Overview</title>
<para>The &libieee1284; library is a library for accessing
parallel port devices.</para>
<!-- Commented out for stable release.
It is currently under development, and this is CVS ID
<literal>$Id: interface.xml,v 1.19 2003/05/30 14:39:22 twaugh Exp $</literal>.
-->
<para>The model presented to the user is fairly abstract: a
list of parallel ports with arbitrary names, with functions
to access them in various ways ranging from bit operations
to block data transfer in one of the IEEE 1284 sanctioned
protocols.</para>
<para>Although the library resides in user space the speed
penalty may not be as bad as you initially think, since the
operating system may well provide assistance with block data
transfer operations; in fact, the operating system may even
use hardware assistance to get the job done. So, using
&libieee1284;, ECP transfers using DMA are possible.</para>
<para>The normal sequence of events will be that the application
<orderedlist>
<listitem>
<para>calls <function>ieee1284_find_ports</function> to
get a list of available ports</para>
</listitem>
<listitem>
<para>then <function>ieee1284_get_deviceid</function> to
look for a device on each port that it is interested
in</para>
</listitem>
<listitem>
<para>and then <function>ieee1284_open</function> to
open each port it finds a device it can control
on.</para>
</listitem>
<listitem>
<para>The list of ports returned from
<function>ieee1284_find_ports</function> can now be
disposed of using
<function>ieee1284_free_ports</function>.</para>
</listitem>
<listitem>
<para>Then when it wants to control the device, it will
call <function>ieee1284_claim</function> to prevent
other drivers from using the port</para>
</listitem>
<listitem>
<para>then perhaps do some data transfers</para>
</listitem>
<listitem>
<para>and then <function>ieee1284_release</function>
when it is finished that that particular command.
This claim-control-release sequence will be repeated
each time it wants to tell the device to do
something.</para>
</listitem>
<listitem>
<para>Finally when the application is finished with the
device it will call
<function>ieee1284_close</function>.</para>
</listitem>
</orderedlist></para>
<para>Usually a port needs to be claimed before it can be
used. This is to prevent multiple drivers from trampling on
each other if they both want to use the same port. The
exception to this rule is the collection of IEEE 1284 Device
IDs, which has an implicit open-claim-release-close
sequence. The reason for this is that it may be possible to
collect a Device ID from the operating system, without
bothering the device with it.</para>
</refsect1>
<refsect1>
<title>Configuration</title>
<para>When <function>ieee1284_find_ports</function> is first
called, the library will look for a configuration file,
<filename>/etc/ieee1284.conf</filename>.</para>
<para>Comments begin with a '#' character and extend to the
end of the line. Everything else is freely-formatted
tokens. A non-quoted (or double-quoted) backslash character
'\' preserves the literal value of the next character, and
single and double quotes may be used for preserving
white-space. Braces and equals signs are recognised as
tokens, unless quoted or escaped.</para>
<para>The only configuration instruction that is currently
recognised is <quote>disallow method ppdev</quote>, for
preventing the use of the Linux ppdev driver.</para>
</refsect1>
<refsect1>
<title>Environment</title>
<para>You can enable debugging output from the library by
setting the environment variable
<envar>LIBIEEE1284_DEBUG</envar> to any value.</para>
</refsect1>
<refsect1>
<title>Files</title>
<variablelist>
<varlistentry>
<term><filename>/etc/ieee1284.conf</filename></term>
<listitem>
<para>Configuration file.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See Also</title>
<para><xref linkend="parport"/>,
<xref linkend="parport-list"/>,
<xref linkend="find-ports"/>,
<xref linkend="free-ports"/>,
<xref linkend="get-deviceid"/>,
<xref linkend="open"/>,
<xref linkend="close"/>,
<xref linkend="claim"/>,
<xref linkend="release"/>,
<xref linkend="data-pin-access"/>,
<xref linkend="status-pin-access"/>,
<xref linkend="control-line-access"/>,
<xref linkend="negotiation"/>,
<xref linkend="fwd-rev"/>,
<xref linkend="transfer"/>,
<xref linkend="irq"/>,
<xref linkend="timeout"/></para>
</refsect1>
</refentry>
</preface>
<reference>
<title>Structures</title>
<refentry id="parport">
<refmeta>
<refentrytitle>parport</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>parport</refname>
<refpurpose>representation of a parallel port</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><![CDATA[#include <ieee1284.h>]]></synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>A <structname>parport</structname> structure represents
a parallel port.</para>
</refsect1>
<refsect1>
<title>Structure members</title>
<para>The structure has the following members:</para>
<programlisting><![CDATA[struct parport {
/* An artibrary name for the port. */
const char *name;
/* The base address of the port, if that has any meaning, or zero. */
unsigned long base_addr;
/* The ECR address of the port, if that has any meaning, or zero. */
unsigned long hibase_addr;
/* The filename associated with this port,
* if that has any meaning, or NULL. */
const char *filename;
};]]></programlisting>
</refsect1>
</refentry>
<refentry id="parport-list">
<refmeta>
<refentrytitle>parport_list</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>parport_list</refname>
<refpurpose>a collection of parallel ports</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><![CDATA[#include <ieee1284.h>]]></synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>A <structname>parport_list</structname> structure is
just a vector of <structname>parport</structname>
structures.</para>
</refsect1>
<refsect1>
<title>Structure members</title>
<para>The structure has the following members:</para>
<programlisting><![CDATA[struct parport_list {
/* Number of elements in the vector. */
int portc;
/* The ports. */
struct parport **portv;
};]]></programlisting>
</refsect1>
</refentry>
</reference>
<reference>
<title>Functions</title>
<refentry id="find-ports">
<refmeta>
<refentrytitle>ieee1284_find_ports</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_find_ports</refname>
<refpurpose>find ports on the system</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int
<function>ieee1284_find_ports</function></funcdef>
<paramdef>struct parport_list
*<parameter>list</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This function should be called before the other
&libieee1284; functions. This gives the library a chance to
look around and see what's available, and gives the program a
chance to choose a port to use.</para>
<para>The <parameter>list</parameter> is a pointer to a
<structname>parport_list</structname> structure that will be
filled in on success.</para>
<para>There are no <parameter>flags</parameter> defined; use
zero for this parameter.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>Success. <parameter>list</parameter> is filled in
and must be destroyed using
<citerefentry>
<refentrytitle>ieee1284_free_ports</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284nomem;</term>
<listitem>
<para>There is not enough memory available.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notimpl;</term>
<listitem>
<para>One or more of the supplied flags is not
supported in this implementation.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="free-ports">
<refmeta>
<refentrytitle>ieee1284_free_ports</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_free_ports</refname>
<refpurpose>safely deallocate a port list</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>void <function>ieee1284_free_ports</function></funcdef>
<paramdef>struct parport_list
*<parameter>list</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>When the port list will no longer be used, the program
should call <function>ieee1284_free_ports</function> giving
it a pointer to the <structname>parport_list</structname>
structure that holds the list of ports returned by
<citerefentry>
<refentrytitle>ieee1284_find_ports</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>. The ports are reference counted with the
<function>ieee1284_open</function> and
<function>ieee1284_close</function> functions, and so the
port list may be freed even if it contains pointers to ports
that are still open.</para>
</refsect1>
</refentry>
<refentry id="get-deviceid">
<refmeta>
<refentrytitle>ieee1284_get_deviceid</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_get_deviceid</refname>
<refpurpose>retrieve an IEEE 1284 Device ID</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_get_deviceid</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>daisy</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This function is for retrieving the IEEE 1284 Device ID
of the specified device. The device is specified by the
<parameter>port</parameter> to which it is attached, and
optionally an address (<parameter>daisy</parameter>) on the
daisy chain of devices on that port.</para>
<para><parameter>daisy</parameter> should be −1 to
indicate that the device is not participating in a IEEE
1284.3 daisy chain, meaning it is the last (or only) device
on the port, or should be a number from 0 to 3 inclusive to
indicate that it has the specified daisy chain address (0 is
next to the port).</para>
<para>The <parameter>flags</parameter> parameter should be a
bitwise union of any flags that the program wants to use.
Available flags are:</para>
<variablelist>
<varlistentry>
<term><constant>F1284_FRESH</constant></term>
<listitem>
<para>Guarantee a fresh Device ID. A cached or
OS-provided ID will not be used.</para>
</listitem>
</varlistentry>
</variablelist>
<para>The provided <parameter>buffer</parameter> must be at
least <parameter>len</parameter> bytes long, and will contain
the Device ID including the initial two-byte length field and
a terminating zero byte on successful return, or as much of
the above as will fit into the buffer.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>A return value less than zero indicates an error as
below. Otherwise, the return value is the number of bytes of
<parameter>buffer</parameter> that have been filled. A
return value equal to the length of the buffer indicates that
the Device ID may be longer than the buffer will
allow.</para>
<variablelist>
<varlistentry>
<term>&e1284noid;</term>
<listitem>
<para>The device did not provide an IEEE 1284 Device ID
when interrogated (perhaps by the operating system if
<constant>F1284_FRESH</constant> was not
specified).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notimpl;</term>
<listitem>
<para>One or more of the supplied flags is not supported
in this implementation, or if no flags were supplied
then this function is not implemented for this type of
port or this type of system. This can also be returned
if a daisy chain address is specified but daisy chain
Device IDs are not yet supported.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para><constant>F1284_FRESH</constant> was specified
and the library is unable to access the port to
interrogate the device.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284nomem;</term>
<listitem>
<para>There is not enough memory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284init;</term>
<listitem>
<para>There was a problem initializing the port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>Unless the <constant>F1284_FRESH</constant> flag is
given, the library will try to find the device's ID as
unobtrusively as possible. First it will ask the operating
system if it knows it, and then it will try actually asking
the device for it. Because of this, the Device ID may be
partially computed (the length field, for example) or even
partially missing if the operating system has only remembered
some parts of the ID. To guarantee that you are getting the
bytes that the device sent, use
<constant>F1284_FRESH</constant>. Be aware that the
operating system may allow any user to inspect the Device IDs
that it provides, whereas device access is normally more
restricted.</para>
<para>The initial two-byte length field is a big-endian 16 bit
unsigned integer provided by the device and may not be
accurate. In particular, it is meant to indicate the length
of the entire string including the length field itself;
however, some manufacturers exclude the length field or just
set the length field to some arbitrary number greater than
the ID length.</para>
</refsect1>
</refentry>
<refentry id="open">
<refmeta>
<refentrytitle>ieee1284_open</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_open</refname>
<refpurpose>open a port</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_open</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>int *<parameter>capabilities</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>In order to begin using a port it must be opened. Any
initial set-up of the port is done at this stage. When an
open port is no longer needed it should be closed with
<citerefentry>
<refentrytitle>ieee1284_close</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>.</para>
<para>The possible <parameter>flags</parameter> are:</para>
<variablelist>
<varlistentry>
<term><constant>F1284_EXCL</constant></term>
<listitem>
<para>This device cannot share the port with any other
device. If this is the case it must be declared at
this stage, so that other drivers trying to access the
port know not to bother; otherwise they will wait until
this driver releases the port, i.e. never.</para>
<remark>The iopl/dev-port access methods don't support
this yet, but the ppdev ones do.</remark>
</listitem>
</varlistentry>
</variablelist>
<para>If <parameter>capabilities</parameter> is not
<constant>NULL</constant> it must point to storage for an
<type>int</type>, which will be treated as a set of flags,
one per bit, which the library sets or clears as
appropriate. If a capability is present it will be used
when asked for. They are:</para>
<variablelist>
<varlistentry>
<term><constant>CAP1284_RAW</constant></term>
<listitem>
<para>Pin-level access is available. If this capability
is present then the following functions are effective:
<function>ieee1284_write_data</function>,
<function>ieee1284_read_status</function>,
<function>ieee1284_wait_status</function>,
<function>ieee1284_write_control</function>,
<function>ieee1284_read_control</function>,
<function>ieee1284_frob_control</function>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_NIBBLE</constant></term>
<listitem>
<para>There is an implementation of nibble mode for this
port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_BYTE</constant></term>
<listitem>
<para>There is an implementation of byte mode for this
port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_COMPAT</constant></term>
<listitem>
<para>There is an implementation of compatibility mode
for this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_ECP</constant></term>
<listitem>
<para>There is a hardware implementation of ECP mode for
this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_ECPRLE</constant></term>
<listitem>
<para>There is an RLE-aware implementation of ECP mode
for this port (the <constant>F1284_RLE</constant> flag
is recognised by the ECP transfer functions).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_ECPSWE</constant></term>
<listitem>
<para>There is a software implementation of ECP mode for
this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_BECP</constant></term>
<listitem>
<para>There is an implementation of bounded ECP mode for
this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_EPP</constant></term>
<listitem>
<para>There is a hardware implementation of EPP mode for
this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_EPPSWE</constant></term>
<listitem>
<para>There is a software implementation of EPP mode for
this port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_IRQ</constant></term>
<listitem>
<para>An interrupt line is configured for this
port and interrupt notifications can be received using
<citerefentry>
<refentrytitle>ieee1284_get_irq_fd</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>CAP1284_DMA</constant></term>
<listitem>
<para>A DMA channel is configured for this port.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>The port is now opened.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284init;</term>
<listitem>
<para>There was a problem during port initialization.
This could be because another driver has opened the
port exclusively, or some other reason.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284nomem;</term>
<listitem>
<para>There is not enough memory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>One or more of the supplied flags is not supported
by this type of port.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, the <parameter>port</parameter>
may already be open).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was a problem at the operating system
level. The global variable <varname>errno</varname>
has been set appropriately.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See also</title>
<para><citerefentry>
<refentrytitle>ieee1284_close</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry></para>
</refsect1>
</refentry>
<refentry id="close">
<refmeta>
<refentrytitle>ieee1284_close</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_close</refname>
<refpurpose>close an open port</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_close</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>To close an open port and free any resources associated
with it, call <function>ieee1284_close</function>.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>The port is now closed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (perhaps it is not open, for instance).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was a problem at the operating system
level. The global variable <varname>errno</varname>
has been set appropriately.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See also</title>
<para><citerefentry>
<refentrytitle>ieee1284_open</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry></para>
</refsect1>
</refentry>
<refentry id="ref">
<refmeta>
<refentrytitle>ieee1284_ref</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_ref</refname>
<refname>ieee1284_unref</refname>
<refpurpose>modify a port's reference count</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_ref</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_unref</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>If you want to free the port list from
<function>ieee1284_find_ports</function> but open one of the
ports later on, you will need to prevent it from being
destroyed in <function>ieee1284_free_ports</function>. Each
port has a reference count, and you can use
<function>ieee1284_ref</function> to increment it and
<function>ieee1284_unref</function> to decrement it.</para>
<para>If you use <function>ieee1284_ref</function> at any
stage, you must later call
<function>ieee1284_unref</function> to relinquish the extra
reference. If you do not do this, the resources associated
with the port will not be cleaned up.</para>
<para>If you have not previously used
<function>ieee1284_ref</function> on a port, you must not
use <function>ieee1284_unref</function> on it.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>These functions return the number of references held
after the increment or decrement.</para>
</refsect1>
<refsect1>
<title>See also</title>
<para><citerefentry>
<refentrytitle>ieee1284_open</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry></para>
</refsect1>
</refentry>
<refentry id="claim">
<refmeta>
<refentrytitle>ieee1284_claim</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_claim</refname>
<refpurpose>claim access to the port</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_claim</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>With the exception of <citerefentry>
<refentrytitle>ieee1284_get_deviceid</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>, <function>ieee1284_claim</function> must be
called on an open port before any other &libieee1284;
function for accessing a device on it.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>Success. Note that, unless the
<constant>F1284_EXCL</constant> flag was specified to
start with, the port should be released within a
<quote>reasonable</quote> amount of time.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284nomem;</term>
<listitem>
<para>There is not enough memory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, it might not have been opened
yet).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was a problem at the operating system
level. The global variable <varname>errno</varname>
has been set appropriately.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See also</title>
<para><citerefentry>
<refentrytitle>ieee1284_release</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry></para>
</refsect1>
</refentry>
<refentry id="release">
<refmeta>
<refentrytitle>ieee1284_release</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_release</refname>
<refpurpose>release a port</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>void <function>ieee1284_release</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This function undoes the effect of
<citerefentry>
<refentrytitle>ieee1284_claim</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry> by releasing the port for use by other
drivers. It is good practice to release the port whenever
convenient. If it is never convenient to do so, the
<constant>F1284_EXCL</constant> flag should be specified at
initialization.</para>
</refsect1>
</refentry>
<refentry id="data-pin-access">
<refmeta>
<refentrytitle>ieee1284_data</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_read_data</refname>
<refname>ieee1284_write_data</refname>
<refname>ieee1284_data_dir</refname>
<refname>ieee1284_wait_data</refname>
<refpurpose>control the data lines</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_read_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>ieee1284_write_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>dt</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_data_dir</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>reverse</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_wait_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>mask</parameter></paramdef>
<paramdef>unsigned char <parameter>val</parameter></paramdef>
<paramdef>struct timeval *<parameter>timeout</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>These functions manipulate the data lines of the
parallel port associated with <parameter>port</parameter>
(which must have been claimed using <citerefentry>
<refentrytitle>ieee1284_claim</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>). The lines are represented by an 8-bit
number (one line per bit) and a direction. The data lines
are driven as a group; they may be all host-driven
(<firstterm>forward</firstterm> direction) or not
(<firstterm>reverse</firstterm> direction). When the
peripheral is driving them the host must not.</para>
<para>For <function>ieee1284_data_dir</function> the
<parameter>reverse</parameter> parameter should be zero to
turn the data line drivers on and non-zero to turn them off.
Some port types may be unable to switch off the data line
drivers.</para>
<para>Setting the data lines may have side effects on some
port types (for example, some Amiga ports pulse
nStrobe).</para>
<para><function>ieee1284_wait_data</function> waits, up until
the <parameter>timeout</parameter>, for the data bits
specified in <parameter>mask</parameter> to have the
corresponding values in <parameter>val</parameter>.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para><function>ieee1284_read_data</function> returns the
8-bit number representing the data lines unless it is not
possible to return such a value with this port type, in which
case it returns an error code. Possible error codes:</para>
<variablelist>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>Bi-directional data lines are not available on
this system.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (perhaps it has not been claimed, for
instance).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was an error at the operating system level,
and <varname>errno</varname> has been set
accordingly.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284timedout;</term>
<listitem>
<para>The <parameter>timeout</parameter> has
elapsed.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Whereas <function>ieee1284_read_data</function> may
return &e1284notavail; on its first invocation on the port,
if it does not do so then it cannot until
<function>ieee1284_close</function> is called for that
port.</para>
</refsect1>
</refentry>
<refentry id="status-pin-access">
<refmeta>
<refentrytitle>ieee1284_status</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_read_status</refname>
<refname>ieee1284_wait_status</refname>
<refpurpose>analyse status lines</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_read_status</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_wait_status</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>mask</parameter></paramdef>
<paramdef>unsigned char <parameter>val</parameter></paramdef>
<paramdef>struct timeval *<parameter>timeout</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>There are five status lines, one of which is usually
inverted on PC-style ports. Where they differ, &libieee1284;
operates on the IEEE 1284 values, not the PC-style inverted
values. The status lines are represented by the following
enumeration:</para>
<programlisting><![CDATA[enum ieee1284_status_bits
{
S1284_NFAULT = 0x08,
S1284_SELECT = 0x10,
S1284_PERROR = 0x20,
S1284_NACK = 0x40,
S1284_BUSY = 0x80,
/* To convert those values into PC-style register values, use this: */
S1284_INVERTED = S1284_BUSY,
};]]></programlisting>
<para>These functions all act on the parallel port associated
with <parameter>port</parameter>, which must be
claimed.</para>
<para>The purpose of <function>ieee1284_wait_status</function>
is to wait until particular status lines have specified
values. Its <parameter>timeout</parameter> parameter may be
modified on return.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>For <function>ieee1284_read_status</function>, the
return value is a non-negative integer with bits set as
appropriate representing the status lines. A negative result
indicates an error.</para>
<para>For <function>ieee1284_wait_status</function>, the
return value is &e1284ok; if the status
lines now reflect the desired values (i.e. status &
<parameter>mask</parameter> is <parameter>val</parameter>),
or a negative result indicating an error.</para>
<para>Possible error codes:</para>
<variablelist>
<varlistentry>
<term>&e1284notimpl;</term>
<listitem>
<para>The <parameter>port</parameter> lacks the
required capability. This could be due to a limitation
of this version of &libieee1284;, or a hardware
limitation.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>Access to the status lines is not available on this
port type.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284timedout;</term>
<listitem>
<para>The <parameter>timeout</parameter> has
elapsed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not claimed).</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>The nAck pin is often able to trigger interrupts on the
host machine. With operating system help these interrupts
may be visible to the application via the file descriptor
returned by <function>ieee1284_get_irq_fd</function>.</para>
<para>Under Linux, the conditions are that the parallel port
driver knows which interrupt line to use and is using it, and
that the relevant <filename>/dev/parport</filename> device
node is accessible and backed by a device driver.</para>
</refsect1>
</refentry>
<refentry id="control-line-access">
<refmeta>
<refentrytitle>ieee1284_control</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_read_control</refname>
<refname>ieee1284_write_control</refname>
<refname>ieee1284_frob_control</refname>
<refname>ieee1284_do_nack_handshake</refname>
<refpurpose>manipulate control lines</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_read_control</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>ieee1284_write_control</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>ct</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>ieee1284_frob_control</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>mask</parameter></paramdef>
<paramdef>unsigned char <parameter>val</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int
<function>ieee1284_do_nack_handshake</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>unsigned char <parameter>ct_before</parameter></paramdef>
<paramdef>unsigned char <parameter>ct_after</parameter></paramdef>
<paramdef>struct timeval *<parameter>timeout</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>There are four control lines, three of which are usually
inverted on PC-style ports. Where they differ, &libieee1284;
operates on the IEEE 1284 values, not the PC-style inverted
values. The control lines are represented by the following
enumeration:</para>
<programlisting><![CDATA[enum ieee1284_control_bits
{
C1284_NSTROBE = 0x01,
C1284_NAUTOFD = 0x02,
C1284_NINIT = 0x04,
C1284_NSELECTIN = 0x08,
/* To convert those values into PC-style register values, use this: */
C1284_INVERTED = (C1284_NSTROBE|
C1284_NAUTOFD|
C1284_NSELECTIN),
};]]></programlisting>
<para>These functions all act on the parallel port associated
with <parameter>port</parameter>, which must be
claimed.</para>
<para>The current values on the control lines are available by
calling <function>ieee1284_read_control</function>, and may
be set by calling
<function>ieee1284_write_control</function>.</para>
<para>To adjust the values on a set of control lines, use
<function>ieee1284_frob_control</function>. The effect of
this can be expressed by: <literal>ctr = ((ctr & ~mask) ^
val)</literal>; that is, the bits in
<parameter>mask</parameter> are unset, and then those in
<parameter>val</parameter> are inverted.</para>
<para>The special function
<function>ieee1284_do_nack_handshake</function> is for
responding very quickly in a protocol where the peripheral
sets nAck and the host must respond by setting a control
line. Its operation, which relies on the host machine
knowing which interrupt nAck generates, is as follows:</para>
<procedure>
<step>
<para>Set the control lines as indicated in
<parameter>ct_before</parameter>.</para>
</step>
<step>
<para>Wait for nAck interrupt. If
<parameter>timeout</parameter> elapses, return
&e1284timedout;.</para>
</step>
<step>
<para>Set the control lines as indicated in
<parameter>ct_after</parameter>.</para>
</step>
</procedure>
<para>On Linux using the ppdev driver, this is performed by
the device driver in the kernel, and so is faster than
normally possible in a user-space library.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>The return value of
<function>ieee1284_read_control</function>, if non-negative,
is a number representing the value on the control lines.</para>
<para>Possible error codes for
<function>ieee1284_read_control</function>:</para>
<variablelist>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>The control lines of this port are not accessible
by the application.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps it is not
claimed).</para>
</listitem>
</varlistentry>
</variablelist>
<para>Possible error codes for
<function>ieee1284_do_nack_handshake</function>:</para>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>The handshake was successful.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>This operation is not available on this port type
or system. This could be because port interrupts are
not available, or because the underlying device driver
does not support the operation.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps it is not
claimed).</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="negotiation">
<refmeta>
<refentrytitle>ieee1284_negotiation</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_negotiate</refname>
<refname>ieee1284_terminate</refname>
<refpurpose>IEEE 1284 negotiation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_negotiate</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>mode</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>ieee1284_terminate</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>These functions are for negotiating to and terminating
from IEEE 1284 data transfer modes. The default mode is
called compatibility mode, or in other words normal printer
protocol. It is a host-to-peripheral mode only. There are
special modes that allow peripheral-to-host transfer as well,
which may be negotiated to using
<function>ieee1284_negotiate</function>. IEEE 1284
negotiation is a process by which the host requests a
transfer mode and the peripheral accepts or rejects it. An
IEEE 1284-compliant device will require a successful
negotiation to a particular mode before it is used for data
transfer (but simpler devices may not if they only speak one
transfer mode).</para>
<para>To terminate the special mode and go back to
compatilibity mode use
<function>ieee1284_terminate</function>.</para>
<para>These functions act on the parallel port associated with
<parameter>port</parameter>, which must be claimed.</para>
<para>With a device strictly complying to IEEE 1284 you will
need to call <function>ieee1284_terminate</function> in
between any two calls to
<function>ieee1284_negotiate</function> for modes other than
<constant>M1284_COMPAT</constant>.</para>
</refsect1>
<refsect1>
<title>Available modes</title>
<refsect2>
<title>Uni-directional modes</title>
<itemizedlist>
<listitem>
<para><constant>M1284_COMPAT</constant>: Compatibility
mode. Normal printer protocol. This is not a
negotiated mode, but is the default mode in absence of
negotiation. <userinput>ieee1284_negotiate(port,
M1284_COMPAT)</userinput> is equivalent to
<userinput>ieee1284_terminate(port)</userinput>. This
host-to-peripheral mode is used for sending data to
printers, and is historically the mode that has been
used for that before IEEE 1284.</para>
</listitem>
<listitem>
<para><constant>M1284_NIBBLE</constant>: Nibble mode.
This peripheral-to-host mode uses the status lines to
read data from the peripheral four bits at a time.</para>
</listitem>
<listitem>
<para><constant>M1284_BYTE</constant>: Byte mode. This
peripheral-to-host mode uses the data lines in reverse
mode to read data from the peripheral a byte at a
time.</para>
</listitem>
</itemizedlist>
</refsect2>
<refsect2>
<title>Bi-directional modes</title>
<itemizedlist>
<listitem>
<para><constant>M1284_ECP</constant>: ECP mode. On
entry to ECP mode it is a host-to-peripheral
(i.e. forward) mode, but it may be set to reverse mode
using <citerefentry>
<refentrytitle>ieee1284_ecp_fwd_to_rev</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>. It is common
for PC hardware to provide assistance with this mode by
the use of a FIFO which the host (or, in reverse mode,
the peripheral) may fill, so that the hardware can do
the handshaking itself.</para>
</listitem>
<listitem>
<para><constant>M1284_EPP</constant>: EPP mode. In this
bi-directional mode the direction of data transfer is
signalled at each byte.</para>
</listitem>
</itemizedlist>
</refsect2>
<refsect2>
<title>Mode variations</title>
<itemizedlist>
<listitem>
<para><constant>M1284_FLAG_DEVICEID</constant>: Device
ID retrieval. This flag may be combined with a nibble,
byte, or ECP mode to notify the device that it should
send its IEEE 1284 Device ID when asked for
data.</para>
</listitem>
<listitem>
<para><constant>M1284_BECP</constant>: Bounded ECP is a
modification to ECP that makes it more robust at the
point that the direction is changed. (Unfortunately it
is not yet implemented in the Linux kernel
driver.)</para>
</listitem>
<listitem>
<para><constant>M1284_ECPRLE</constant>: ECP with run
length encoding. In this mode, consecutive data bytes
of the same value may be transferred in only a few
cycles.</para>
</listitem>
</itemizedlist>
</refsect2>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>The negotiation was successful.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>Negotiation is not available with this port
type.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284rejected;</term>
<listitem>
<para>Negotiation was rejected by the peripheral.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284negfailed;</term>
<listitem>
<para>Negotiation failed for some reason. Perhaps the
device is not IEEE 1284 compliant.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>A system error occured during negotiation.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not claimed).</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="fwd-rev">
<refmeta>
<refentrytitle>ieee1284_ecp_fwd_to_rev</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_ecp_fwd_to_rev</refname>
<refname>ieee1284_ecp_rev_to_fwd</refname>
<refpurpose>ECP direction switching</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ieee1284_ecp_fwd_to_rev</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_ecp_rev_to_fwd</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>These functions are used to switch directions when in
ECP mode. On negotiation to ECP mode the direction is
forward (in other words, host-to-peripheral). Use
<function>ieee1284_ecp_fwd_to_rev</function> to switch from
forward to reverse, and
<function>ieee1284_ecp_rev_to_fwd</function> to switch from
reverse to forward.</para>
<para>They act on the parallel port associated with
<parameter>port</parameter>, which must be claimed.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>Direction switched successfully.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notimpl;</term>
<listitem>
<para>The <parameter>port</parameter> lacks the
required capability. This could be due to a limitation
of this version of &libieee1284;, or a hardware
limitation.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not claimed).</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="transfer">
<refmeta>
<refentrytitle>ieee1284_transfer</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_nibble_read</refname>
<refname>ieee1284_compat_write</refname>
<refname>ieee1284_byte_read</refname>
<refname>ieee1284_epp_read_data</refname>
<refname>ieee1284_epp_write_data</refname>
<refname>ieee1284_epp_read_addr</refname>
<refname>ieee1284_epp_write_addr</refname>
<refname>ieee1284_ecp_read_data</refname>
<refname>ieee1284_ecp_write_data</refname>
<refname>ieee1284_ecp_read_addr</refname>
<refname>ieee1284_ecp_write_addr</refname>
<refpurpose>data transfer functions</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_nibble_read</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_compat_write</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>const char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t <function>ieee1284_byte_read</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_epp_read_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_epp_write_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>const char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_epp_read_addr</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_epp_write_addr</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>const char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_ecp_read_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_ecp_write_data</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>const char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_ecp_read_addr</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>ssize_t
<function>ieee1284_ecp_write_addr</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>int <parameter>flags</parameter></paramdef>
<paramdef>const char *<parameter>buffer</parameter></paramdef>
<paramdef>size_t <parameter>len</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This set of functions is for tranferring bytes in the
relevant transfer mode. For ECP and EPP modes two types of
transfer are possible: <firstterm>data</firstterm> and
<firstterm>address</firstterm> (usually referred to as
<firstterm>channel</firstterm> in ECP).</para>
<para>The supplied <parameter>port</parameter> must be a
claimed port.</para>
<para>The supplied <parameter>buffer</parameter> must be at
least <parameter>len</parameter> bytes long. When reading,
the transferred data is stored in the buffer; when writing
the data to be transferred is taken from the buffer.</para>
<para>For reads (peripheral to host): if no data is available
and <constant>F1284_NONBLOCK</constant> is not in effect,
the inactivity timer is started. If data becomes available
before the inactivity time-out elapses it is read; otherwise
the return value will be &e1284timedout;.</para>
<para>For writes (host to peripheral): if the peripheral is
not willing to accept data and
<constant>F1284_NONBLOCK</constant> is not in effect, the
inactivity timer is started. If the peripheral indicates
that it is willing to accept data before the inactivity
time-out elapses it is sent; otherwise the return value will
be &e1284timedout;</para>
<para>The <parameter>flags</parameter> may alter the behaviour
slightly:</para>
<variablelist>
<varlistentry>
<term><constant>F1284_NONBLOCK</constant></term>
<listitem>
<para>For reads (peripheral to host): if no data is
available, return immediately (with
&e1284timedout;).</para>
<para>For writes (host to peripheral): if the peripheral
is not willing to accept data, return immediately (with
&e1284timedout;).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>F1284_SWE</constant></term>
<listitem>
<para>Don't use hardware assistance for the transfer,
but instead set the parallel port pins according to the
wire protocol.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>F1284_RLE</constant> (for ECP only)</term>
<listitem>
<para>Use run length encoding. If the
peripheral is in ECP mode with RLE, calls to
<function>ieee1284_ecp_read_data</function>
<emphasis>must</emphasis> set this flag in order for
the RLE from the peripheral to be interpreted
correctly, and calls to
<function>ieee1284_ecp_write_data</function>
<emphasis>may</emphasis> set this flag in order to take
advantage of RLE.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>F1284_FASTEPP</constant> (for EPP only)</term>
<listitem>
<para>Use multi-byte transfers. Several bytes at a time
are transferred using hardware assistance, if
supporting hardware is present. The price of this
increased speed is that the return value will be less
reliable when this flag is used.</para>
</listitem>
</varlistentry>
</variablelist>
<para>For ECP mode, a given direction is in force at any
particular time, and it is up to the application to ensure
that it is only writing when in forward mode, and reading
when in reverse mode.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>The return value is the number of bytes successfully
transferred or, if negative, one of:</para>
<variablelist>
<varlistentry>
<term>&e1284notimpl;</term>
<listitem>
<para>This transfer mode and flags combination is not
yet implemented in &libieee1284;.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284timedout;</term>
<listitem>
<para>Timed out waiting for peripheral to
handshake.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284nomem;</term>
<listitem>
<para>Not enough memory is available.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was a problem at the operating system
level. The global variable <varname>errno</varname>
has been set appropriately.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not claimed).</para>
</listitem>
</varlistentry>
</variablelist>
<para>If any bytes are successfully transferred, that number
is returned. An error is returned only if no bytes are
transferred.</para>
<para>For host-to-peripheral transfers, all data is at the
peripheral by the time the call returns.</para>
</refsect1>
<refsect1>
<title>See also</title>
<para><citerefentry>
<refentrytitle>ieee1284_ecp_fwd_to_rev</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry></para>
</refsect1>
</refentry>
<refentry id="irq">
<refmeta>
<refentrytitle>ieee1284_get_irq_fd</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_get_irq_fd</refname>
<refname>ieee1284_clear_irq</refname>
<refpurpose>interrupt notification</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>ieee1284_get_irq_fd</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>ieee1284_clear_irq</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter>,
unsigned int *<parameter>count</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>If the <parameter>port</parameter> has a configured
interrupt line and the port type supports interrupt
notification, it is possible to obtain a file descriptor that
may be used for
<citerefentry>
<refentrytitle>select</refentrytitle>
<manvolnum>2</manvolnum>
</citerefentry> or <citerefentry>
<refentrytitle>poll</refentrytitle>
<manvolnum>2</manvolnum>
</citerefentry>. Any event (readable, writable
or exception) means that an interrupt has been
triggered. No operations other than
<function>select</function> or <function>poll</function> may
be performed on the file descriptor.</para>
<para>The port must be open in order to call
<function>ieee1284_get_irq_fd</function>, and must be claimed
when using <function>select</function> or
<function>poll</function>.</para>
<para>The caller must not close the file descriptor, and may
not use it at all when the port is not claimed.</para>
<para>When an interrupt has been detected, the caller must
call <function>ieee1284_clear_irq</function> to clear the
interrupt condition, at which point the number of interrupts
raised can be obtained by supplying a
non-<constant>NULL</constant>
<parameter>count</parameter>.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>For <function>ieee1284_get_irq_fd</function>: If the
return value is negative then it is an error code listed
below. Otherwise it is a valid file descriptor.
<variablelist>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>No such file descriptor is available.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not open).</para>
</listitem>
</varlistentry>
</variablelist></para>
<para>For <function>ieee1284_clear_irq</function>:
<variablelist>
<varlistentry>
<term>&e1284ok;</term>
<listitem>
<para>The interrupt has been cleared. If
<parameter>count</parameter> was not
<constant>NULL</constant> the count of interrupts has
been atomically stored to
<parameter>count</parameter> and reset.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284notavail;</term>
<listitem>
<para>The <parameter>count</parameter> parameter was
not <constant>NULL</constant> but interrupt counting
is not supported on this type of port. The interrupt
has been cleared.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284sys;</term>
<listitem>
<para>There was a problem clearing the
interrupt.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>&e1284invalidport;</term>
<listitem>
<para>The <parameter>port</parameter> parameter is
invalid (for instance, perhaps the
<parameter>port</parameter> is not claimed).</para>
</listitem>
</varlistentry>
</variablelist></para>
</refsect1>
</refentry>
<refentry id="timeout">
<refmeta>
<refentrytitle>ieee1284_set_timeout</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ieee1284_set_timeout</refname>
<refpurpose>modify inactivity timeout</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ieee1284.h></funcsynopsisinfo>
<funcprototype>
<funcdef>struct timeval
*<function>ieee1284_set_timeout</function></funcdef>
<paramdef>struct parport *<parameter>port</parameter></paramdef>
<paramdef>struct timeval *<parameter>timeout</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This function sets a new value for the inactivity
timeout (used for block transfer functions), and returns the
old value.</para>
<para>The <parameter>port</parameter> must be claimed.</para>
<para>The <parameter>timeout</parameter> parameter may be
<constant>NULL</constant>, in which case the old value is
left unchanged.</para>
</refsect1>
<refsect1>
<title>Return value</title>
<para>This function returns a pointer to a <structname>struct
timeval</structname> representing the old value. This uses
the same storage as the <parameter>port</parameter>
structure, and so is not valid after closing the port.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>Note that this is an inactivity time-out, not an
absolute time-out. During a data transfer, if the peripheral
is inactive for the length of time specified then the host
gives up.</para>
<para>It is also advisory; no guarantee is made that the
transfer will ever complete.</para>
</refsect1>
</refentry>
</reference>
</book>
|