1-Wire on OpenBSD
OpenBSD 4.1 has basic 1-Wire support including support for the Maxim/Dallas DS2490 USB 1-Wire master (uow).
For OpenBSD 4.1, Grange@ commited my patch (thanks!) for a new driver owsbm which adds support for the DS2438 (1-Wire Smart Battery monitor). The driver supports the basic A/D functions for getting the three voltages (VDD, VAD, and CR) and the temperature.
demeter:~ linville$ sysctl hw.sensors hw.sensors.owtemp0.temp0=22.75 degC hw.sensors.owsbm0.temp0=22.34 degC (Temp) hw.sensors.owsbm0.volt0=4.82 VDC (VDD) hw.sensors.owsbm0.volt1=1.59 VDC (VAD) hw.sensors.owsbm0.volt2=0.00 VDC (CR) hw.sensors.owid0.raw0=2541210 (ID) demeter:~ linville$
I've written a couple small daemons to dump the temperature values into a database. The DS2438 is wired up to an HIH-3605 humidity sensor. VDD is the power supply voltage. VAD is the output from the HIH-3605 and is proportional to the power supply voltage. Here is a paper describing the use of a DS2438 and HIH-3605 to measure humidity. CR is the voltage across two pins and is used to calculate the current (in the case of the circuit I have, it's used to measure solar radiation). If you're interested in this setup, it is a Hobby-Board HTS3-R1-A (Humidity/Temp/Solar). It has been working quite well for me.
A quick PHP script later and we have a really nice graph of the temperature. You'll need an SVG capable browser to view it like Firefox, Opera or Safari. I'll put all the sources up once I remove the hardcoded badness. :-)
Both sensors (owtemp and owsbm) are on the same board and are currently placed right above a vent in my apartment. The spikes in temperature are when the heat pump turns on.
Example Code
These programs are basic examples of how to use forks, threads, signals, and semaphores. They should compile fine in most POSIX environments.
- forkey.cpp - A process that forks off a child, prints the pid and then waits for the child to die.
- thread.c - An example pthread program that creates several threads that announce creation, sleep, and announce waking up.
- sigcatch.c - An example program that installs a signal handler to catch a SIGINT.
- semaphore.cpp - The classic producer/consumer problem implamented with semaphores to provide for synchronized production and consumption.
- memmanager.cpp - A program that forks off a specified amount of children who then request memory to use. The parent attaches to a several segments of shared memory which it then keeps track of what children are using what portions. Children will request memory, use it, then return it to the parent and the parent will compact it. Uses find first, find worst, and find best techniques for finding free memory for the children. Change the first #define in the beginning to change techniques.
- sun_audio_tester.c - This is an example of how to control the standard /dev/audio device. Generates a psuedo sin wave alternating on the left and right channel. Compiles cleanly on Solaris 2.7 and Solaris 2.8.
Instructions
- I have written up instructions on how to compile and install DSniff, Libnids, Libpcap, Libnet and SNORT on Mac OS X.
Utilities
- ypfix.cpp - A program that will sort the yp password file by the uid. It also displays errors such as a blank password to stderr. This program is useful because sometimes yp password databases can become fragmented (well, at least ours did anyway, which is the reason I wrote this.)
- Netcat 1.10 (nc110.tgz) - Netcat 1.10 is an incredibly useful utility, but unfortunately the source is very hard to find. It's very useful for opening raw connections to ports (TCP and UDP). I have added a Mac OS X target to the makefile.