{"id":25,"date":"2005-11-05T00:02:30","date_gmt":"2005-11-05T08:02:30","guid":{"rendered":"http:\/\/www.11h.net\/blog\/?p=25"},"modified":"2005-11-05T00:02:30","modified_gmt":"2005-11-05T08:02:30","slug":"freebsd-parallel-port-interface","status":"publish","type":"post","link":"https:\/\/11h.net\/blog\/freebsd-parallel-port-interface\/","title":{"rendered":"FreeBSD Parallel Port interface"},"content":{"rendered":"<p>I&#8217;m too impatient for Dallas Semi to send samples of the DS2408 so I implemented a switch using the parallel port on my FreeBSD server.<\/p>\n<p>The idea is to use the DS2408 or parallel port to drive a relay to switch the HVAC &#8220;call for heat&#8221; line.  This way I can cron my heating schedule.<\/p>\n<p>Brian and Smart-Works were nice enough to loan me two temperature sensors and some space on their web server for the temperature log.<\/p>\n<p>I thought I would be able to echo 1 > \/dev\/lpt0.  Ha.  No&#8230;<\/p>\n<p>FreeBSD includes the ability to use the &#8220;geek&#8221; port.  I wish I were making that up, but that&#8217;s what `man ppi` says.  FreeBSD uses ioctl to access the parallel port interface.  Here&#8217;s the sample from the ppi man page:<\/p>\n<p>#include   stdio .h<br \/>\n#include   dev\/ppbus\/ppi.h<br \/>\n#include   dev\/ppbus\/ppbconf.h<br \/>\n#include   fcntl .h<br \/>\n\/\/The includes above need less than greater than brackets.<\/p>\n<p>int main (void)<br \/>\n{<br \/>\n  int             fd;<br \/>\n  u_int8_t        val;<\/p>\n<p>  fd = open (&#8220;\/dev\/ppi0&#8221;, O_RDWR);<br \/>\n  val = 0x1;<\/p>\n<p>  ioctl (fd, PPISDATA, &#038;val);<br \/>\n  ioctl (fd, PPIGCTRL, &#038;val);<br \/>\n  val |= STROBE;<br \/>\n  ioctl (fd, PPISCTRL, &#038;val);<br \/>\n  val &#038;= ~STROBE;<br \/>\n  ioctl (fd, PPISCTRL, &#038;val);<br \/>\n}<\/p>\n<p>I&#8217;m actually going to use some logic so that I can use more than eight devices connected to the parallel port.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Interfacing the parallel port with FreeBSD to switch a relay (or 254). <a href=\"https:\/\/11h.net\/blog\/freebsd-parallel-port-interface\/\">&#8230;<\/p>\n<p>[Continue reading]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":0,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"wp:attachment":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}