Python 如何使用owfs读取iButton温度记录器?

Python 如何使用owfs读取iButton温度记录器?,python,ubuntu,1wire,Python,Ubuntu,1wire,我已经安装并正在尝试从一个数据库读取数据 owfs允许我将iButton装载为一个fuse文件系统,我可以看到所有数据。不过,我很难找出访问数据的最佳方式。我可以通过catting文件获得单独的读数,例如cat-onewire/{deviceid}/log/temperature.1,但是onewire/{deviceid}/log/temperature.ALL文件“损坏”(可能太大,因为histogram/temperature.ALL工作正常) 读取所有文件的python脚本似乎可以工作,

我已经安装并正在尝试从一个数据库读取数据

owfs
允许我将iButton装载为一个fuse文件系统,我可以看到所有数据。不过,我很难找出访问数据的最佳方式。我可以通过
cat
ting文件获得单独的读数,例如
cat-onewire/{deviceid}/log/temperature.1
,但是
onewire/{deviceid}/log/temperature.ALL
文件“损坏”(可能太大,因为
histogram/temperature.ALL
工作正常)

读取所有文件的python脚本似乎可以工作,但需要很长时间。有更好的方法吗?有人举过例子吗

我使用的是Ubuntu 8.04,无法运行java“one wire viewer”应用程序

更新:使用(与owfs一起安装),我可以获取当前温度,但不知道如何访问记录的日志:

>>> import ow
>>> ow.init("u") # initialize USB
>>> ow.Sensor("/").sensorList()
[Sensor("/81.7FD921000000"), Sensor("/21.C4B912000000")]
>>> x = ow.Sensor("/21.C4B912000000")
>>> print x.type, x.temperature
DS1921           22

x.log
给出了一个
属性错误

我认为没有一个聪明的方法。owpython不支持API文档中的说明。我想
/proc
是你最安全的赌注。也许可以看看owpython模块的源代码,看看它是如何工作的。

我也遇到过owfs的问题。我发现对于一个简单的问题,这是一个过度设计的解决方案。现在我使用的代码没有问题。我发现它灵活可靠。例如,我每分钟运行一次,将房间温度存储在日志文件中

/usr/local/bin/digitemp_DS9097U -c /usr/local/etc/digitemp.conf \
    -q -t0 -n0 -d60 -l/var/log/temperature
为了达到这一点,我下载了源文件,将其解压,然后执行以下操作

# Compile the hardware-specific command
make ds9097u
# Initialize the configuration file
./digitemp_DS9097U -s/dev/ttyS0 -i
# Run command to obtain temperature, and verify your setup
./digitemp_DS9097U -a 
# Copy the configuration file to an accessible place
cp .digitemprc /usr/local/etc/digitemp.conf
我还手动编辑了配置文件,以使其适应我的设置。结果就是这样

TTY /dev/ttyS0
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 1
ROM 0 0x10 0xD3 0x5B 0x07 0x00 0x00 0x00 0x05 
在我的例子中,我还创建了一个/etc/init.d/digitemp文件,并使其能够在启动时运行

#! /bin/sh
#
# System startup script for the temperature monitoring daemon
#
### BEGIN INIT INFO
# Provides: digitemp
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:  2 3 5
# Default-Stop:   0 1 6
# Description:    Start the temperature monitoring daemon
### END INIT INFO

DIGITEMP=/usr/local/bin/digitemp_DS9097U
test -x $DIGITEMP || exit 5

DIGITEMP_CONFIG=/root/digitemp.conf
test -f $DIGITEMP_CONFIG || exit 6

DIGITEMP_LOGFILE=/var/log/temperature

# Source SuSE config
. /etc/rc.status

rc_reset
case "$1" in
    start)
        echo -n "Starting temperature monitoring daemon"
        startproc $DIGITEMP -c $DIGITEMP_CONFIG  -q -t0 -n0 -d60 -l$DIGITEMP_LOGFILE
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down temperature monitoring daemon"
        killproc -TERM $DIGITEMP
        rc_status -v
        ;;
    try-restart)
        $0 status >/dev/null && $0 restart
        rc_status
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    force-reload)
        $0 try-restart
        rc_status
        ;;
    reload)
        $0 try-restart
        rc_status
        ;;
    status)
        echo -n "Checking for temperature monitoring service"
        checkproc $DIGITEMP
        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
        exit 1
        ;;
esac
rc_exit

我刚刚开始研究ibuttons,并想使用python

这看起来更有希望:


除了docstring之外,我找不到任何文档。还有什么吗?谢谢你提供的信息,但我认为这无助于访问DS1922T上存储的日志。我可以使用owpython或owfs读取当前温度,它只是访问存储的测量值,我正在努力解决这个问题。