linux.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>fhem.pl - Hints for GNU/Linux</title>
  5. <script type="text/javascript" src="fhemdoc.js"></script>
  6. <noscript>
  7. <link rel="stylesheet" type="text/css" href="../www/pgm2/style.css" />
  8. </noscript>
  9. <meta http-equiv="Content-type" content="text/html;charset=ISO-8859-1"/>
  10. </head>
  11. <body>
  12. <div id="menuScrollArea">
  13. <div id="logo"></div>
  14. <div id="menu">
  15. <h3>fhem.pl - Hints for GNU/Linux</h3>
  16. Version: <b>EN</b>&nbsp;<a href="linux_DE.html">DE</a>
  17. </div>
  18. </div>
  19. <div id="right">
  20. <h2>fhem.pl - Hints for GNU/Linux</h2>
  21. <table border=1><tr><td>
  22. Note: Depending on the GNU/Linux distribution (Debian, openSuSE, etc.) and
  23. version of the Linux kernel you may or <i>may not</i> have to do the
  24. following steps.<br>
  25. It is worth giving it a try without any modifications <b>first</b>.<br> We
  26. have convinced the kernel developers to enable all (currently known) ELV
  27. devices by default. Starting with kernel 2.6.24.2 (e.g. openSUSE 11) the
  28. changes below are <b>not</b> required. You can check your running kernel
  29. version using the command:
  30. <code><br>uname -r<br></code>
  31. </td></tr></table>
  32. <hr>
  33. <p><b><a name="onedevice">One device</a></b><br>
  34. If you connect one USB device (FHZ1000PC, FHZ1300PC, EM1010PC, WS300, ...) to
  35. your GNU/Linux server you can use the regular <i>ftdi_sio</i> kernel module.
  36. However, it may not recognize our device. Therefore you need to get the
  37. <i>vendor</i> and <i>product</i> codes:
  38. <code><br>
  39. # lsusb<br>
  40. ...<br>
  41. Bus 002 Device 002: ID <b>0403</b>:<b>e0e8</b> Future Technology Devices International, Ltd <br>
  42. ...<br>
  43. </code><br>
  44. Now you need to edit your <code>/etc/modprobe.conf</code> or
  45. <code>/etc/modprobe.conf.local</code> file (depending on your distribution).
  46. Add the following line to it:<br>
  47. <code><br>
  48. options ftdi_sio vendor=0x<b>0403</b> product=0x<b>e0e8</b><br>
  49. </code><br>
  50. Replace the vendor and product code with the output of the <i>lsusb</i>
  51. command. The you load the module using:<br>
  52. <code><br>
  53. # modprobe ftdi_sio<br>
  54. </code><br>
  55. <hr>
  56. <p><b><a name="multipledevices">Multiple devices</a></b><br>
  57. If you're using multiple USB devices (FHZ1000PC, FHZ1300PC, EM1010PC, WS300,
  58. ...) you cannot use the method above. You need to modify the ftdi_sio kernel
  59. module to make it work. The following example was done with openSuSE 10.1:<br>
  60. You need to have the kernel-source-<i>version</i> RPM of your current kernel
  61. (see output of <code>uname -r</code>) installed.<br>
  62. <code><br>
  63. # cd /usr/src/linux<br>
  64. # make cloneconfig<br>
  65. # make modules_prepare<br>
  66. # cp /boot/symvers-2.6.*-default.gz /usr/src/linux<br>
  67. # mv symvers-2.6.*-default.gz Module.symvers.gz<br>
  68. # gunzip /usr/src/linux/Module.symvers.gz<br>
  69. # make modules_prepare<br>
  70. # cd drivers/usb/serial<br>
  71. </code>
  72. For the EM1010PC you (may) need to add the following line:
  73. <code><br>
  74. # vi ftdi_sio.h<br>
  75. ...<br>
  76. #define FTDI_ELV_WS500_PID 0xE0E9 /* PC-Wetterstation (WS 500) */<br>
  77. <b>#define FTDI_ELV_EM1010PC_PID 0xE0EF /* EM 1010 PC */</b><br>
  78. </code><br>
  79. Now we need to uncomment some lines to enable all of our devices.
  80. <code><br>
  81. # vi ftdi_sio.c<br>
  82. ...<br>
  83. { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, <br>
  84. { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) },<br>
  85. { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, <br>
  86. { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1010PC_PID) },<br>
  87. ...<br>
  88. </code><br>
  89. Remove the <b>/*</b> and <b>*/</b> of your devices and save the file.
  90. <br>
  91. <code>
  92. # cd /usr/src/linux<br>
  93. </code>
  94. Now you have 3 choices:<br>
  95. <table border=1>
  96. <tr><td>
  97. <code>
  98. # mv Module.symvers Module.symvers.notneeded<br>
  99. # make M=drivers/usb/serial</code>
  100. <td>
  101. ... to build the modules for all of <i>usb serial</i>.<br>
  102. If you have a less powerful machine like the ARM-Based NSLU2 then it is
  103. sufficient to only build the required module.
  104. </td></tr>
  105. <td><code>
  106. # make modules</code>
  107. </td><td>
  108. ... to build all modules (takes a long time).
  109. </td></tr>
  110. <tr><td>
  111. <code>
  112. # make driver/usb/serial/ftdi_sio.ko
  113. </code>
  114. </td><td>
  115. ... to build just the <i>ftdi_sio.ko</i> module. However, this does not seem
  116. to be working always.
  117. </td></tr>
  118. </table>
  119. Once you have the module:<br>
  120. <code><br>
  121. # cd /lib/modules/<i>yourKernelVerion</i>/kernel/drivers/usb/serial<br>
  122. # cp ftdi_sio.ko ftdi_sio.ko_backup<br>
  123. # cp /usr/src/linux/drivers/usb/serial/ftdi_sio.ko .<br>
  124. </code><br>
  125. To activete it you may need to stop applications (like fhem) who
  126. are using the /dev/ttyUSB device and unload the module and load it again.<br>
  127. <code><br>
  128. # rmmod ftdi_so<br>
  129. # modprobe ftdi_so<br>
  130. </code><br>
  131. You should now see multiple ttyUSB devices:
  132. <code><br>
  133. # ls -l /dev/ttyUSB*<br>
  134. crw-rw---- 1 root uucp 188, 0 2007-02-11 23:00 /dev/ttyUSB0<br>
  135. crw-rw---- 1 root uucp 188, 1 2007-02-11 23:00 /dev/ttyUSB1<br>
  136. </code><br>
  137. <hr>
  138. <p><b><a name="devicelinks">Device links</a></b><br>
  139. If you're using multiple USB devices (FHZ, EM, WS...) it might occur that the
  140. enumeration of the /dev/ttyUSB<i>n</i> numbers get mixed up if one of the
  141. device is missing or after a reboot.<br> Starting with kernel 2.6 the UDEV
  142. implements means for using virtual names instead of the bare numbers.<br>
  143. Edit the file <code>/etc/udev/rules.d/10-udev.rules</code> (create if
  144. necessary) and insert the following lines: <br>
  145. If you use udev prior to version 103:<br>
  146. <code>
  147. KERNEL=="ttyUSB*", SYSFS{product}=="ELV FHZ 1300 PC", SYMLINK+="elv_fhz1300pc"<br>
  148. KERNEL=="ttyUSB*", SYSFS{product}=="ELV EM 1010 PC", SYMLINK+="elv_em1010pc"<br>
  149. </code><br>
  150. Starting with udev 103 the SYSFS will be replaced by ATTRS:
  151. <br>
  152. <code>
  153. KERNEL=="ttyUSB*", ATTRS{product}=="ELV FHZ 1300 PC", SYMLINK+="elv_fhz1300pc"<br>
  154. KERNEL=="ttyUSB*", ATTRS{product}=="ELV EM 1010 PC", SYMLINK+="elv_em1010pc"<br>
  155. </code><br>
  156. Now you need to reload (rmmod/modprobe) the ftdio_sio kernel module to
  157. use the device paths <code><b>/dev/elv_fhz1300pc</b></code> or
  158. <code><b>/dev/elv_em1010pc</b></code> in your FHEM configuration file.
  159. <hr>
  160. <p><b><a name="log">Perl Device::SerialPort</a></b><br>
  161. On debian you may install the missing Device::SerialPort package with:
  162. <pre>
  163. apt-get install libdevice-serialport-perl
  164. </pre>
  165. <hr>
  166. <p><b><a name="log">Logfile config</a></b><br>
  167. For a weekly fhem.log rotation add to /etc/logrotate.conf:<br>
  168. <pre>
  169. /var/log/fhem.log {
  170. missingok
  171. weekly
  172. copytruncate
  173. rotate 5
  174. compress
  175. }
  176. </pre>
  177. </div>
  178. </body>
  179. </html>