From: Neil C. <nc...@li...> - 2007-09-15 00:23:14
|
Matthew Williams wrote: > Neil Cherry wrote: >> I'll be adding this to ~mh/lib/ but what is its file name in >> relation to the rest of this information? > > This is already in X10_Interface.pm. I was only demonstrating how to extend > classes in Perl. Got it, thanks, I've removed the file I created in ~mh/lib. >>> mh.ini: >>> test_device=/tmp/testpipe >>> test_device_datatype=record >>> test_device_mode=rw >> What does this do? > > This defines the location of the named pipe that the device "test" will be > using in the code below. It also chooses the record (as opposed to raw) > datatype which wait for CR/LR combinations. As well, the "mode" is set to > read/write so that the Device_Item will allow both reads and writes, > although I only test reads in the code below. Got it! > For your USB stuff, I assume that you are creating a character device file > in /dev. Let's says its called /dev/neil. You would point your device > definition to /dev/neil instead of /tmp/testpipe and set datatype to raw. > You could then, once you create the Device_Item, read/write to the USB > device through ->said and ->set. Got it, I've got some work to do here wrt the usb Perl code.. >>> code: >>> >>> $testDevice= new Device_Item(undef,undef,'test'); >>> >>> if ($state = $testDevice->said) { >>> &print_log("test device said $state"); >>> } >> I'll add this to my code directory as file: test_device.pl >> > > To use the test device as defined in my original e-mail, you should create > /tmp/testpipe: > > # mknod /tmp/testpipe p > # chmod 777 /tmp/testpipe > > Then, whenever you write to this pipe, mh will respond with a log message: > > # echo Hi there misterhouse > /tmp/testpipe MH sees it but it doesn't read anything from the pipe. I'm running 2.104, I've added the lines to my ini file. Here's the startup output: creating generic device test on /tmp/testpipe When I do: # echo Hi there misterhouse > /tmp/testpipe or # echo -e "Hi there misterhouse\n" > /tmp/testpipe I get nothing from the MH print log. # ls -l /tmp/testpipe prwxrwxrwx 1 njc njc 0 Sep 14 20:16 /tmp/testpipe -- Linux Home Automation Neil Cherry nc...@li... http://www.linuxha.com/ Main site http://linuxha.blogspot.com/ My HA Blog Author of: Linux Smart Homes For Dummies |