├── .github
├── FUNDING.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── LICENSE
├── README.md
├── VERSION
├── ccu1
├── cuxd
│ ├── cdc-acm.ko
│ ├── cp210x.ko
│ ├── cuxd
│ ├── cuxd_addon.cfg
│ ├── dfu-programmer
│ ├── extra
│ │ ├── artdmxdim
│ │ ├── curl
│ │ ├── digitemp_DS9097U
│ │ ├── ether-wake
│ │ ├── jq
│ │ ├── logfilter
│ │ ├── socat
│ │ └── systemname.tcl
│ ├── index.ccc
│ ├── libusb-0.1.so.4
│ ├── libusb-0.1.so.4.4.4
│ ├── mos7720.ko
│ ├── pl2303.ko
│ ├── redir.ccc
│ └── update_addon
├── rc.d
│ └── cuxdaemon
└── update_script
├── ccu2
├── cuxd
│ ├── cuxd
│ ├── dfu-programmer
│ ├── extra
│ │ ├── artdmxdim
│ │ ├── ctl_startup
│ │ ├── curl
│ │ ├── curl.tgz
│ │ ├── digitemp_DS9097U
│ │ ├── ether-wake
│ │ ├── jq
│ │ ├── logfilter
│ │ ├── socat
│ │ ├── systemname.tcl
│ │ └── update-check.cgi
│ ├── index.ccc
│ ├── libusb-1.0.so
│ ├── libusb-1.0.so.0
│ ├── libusb-1.0.so.0.1.0
│ ├── redir.ccc
│ └── update_addon
├── modules
│ ├── 3.4.11.ccu2
│ │ ├── cdc-acm.ko
│ │ ├── ch341.ko
│ │ ├── cp210x.ko
│ │ ├── ftdi_sio.ko
│ │ ├── mos7720.ko
│ │ ├── pl2303.ko
│ │ └── usbserial.ko
│ └── 3.4.113.ccu2
│ │ ├── cdc-acm.ko
│ │ ├── ch341.ko
│ │ ├── cp210x.ko
│ │ ├── ftdi_sio.ko
│ │ ├── mos7720.ko
│ │ ├── pl2303.ko
│ │ └── usbserial.ko
├── rc.d
│ └── cuxdaemon
└── update_script
├── ccu3
├── cuxd
│ ├── cuxd
│ ├── dfu-programmer
│ ├── extra
│ │ ├── artdmxdim
│ │ ├── ctl_startup
│ │ ├── curl
│ │ ├── digitemp_DS9097U
│ │ ├── ether-wake
│ │ ├── jq
│ │ ├── logfilter
│ │ ├── socat
│ │ ├── systemname.tcl
│ │ └── update-check.cgi
│ ├── index.ccc
│ ├── redir.ccc
│ └── update_addon
├── rc.d
│ └── cuxdaemon
└── update_script
├── ccux86
├── cuxd
│ ├── cuxd
│ ├── dfu-programmer
│ ├── extra
│ │ ├── artdmxdim
│ │ ├── ctl_startup
│ │ ├── curl
│ │ ├── digitemp_DS9097U
│ │ ├── ether-wake
│ │ ├── jq
│ │ ├── logfilter
│ │ ├── socat
│ │ ├── systemname.tcl
│ │ └── update-check.cgi
│ ├── index.ccc
│ ├── redir.ccc
│ └── update_addon
├── rc.d
│ └── cuxdaemon
└── update_script
├── common
└── cuxd
│ ├── CUXD.PNG
│ ├── ajax.gif
│ ├── cproxy.ccc
│ ├── curl
│ ├── cuxd.inc
│ ├── cuxd_addon.cfg
│ ├── devicelist.inc
│ ├── dfu
│ ├── at90usb1286.zip
│ ├── at90usb162.tgz
│ ├── at90usb646.zip
│ ├── atmega32u2.tgz
│ ├── atmega32u4.tgz
│ ├── atxmega128a4u.zip
│ └── table.txt
│ ├── extra
│ ├── blind.tcl
│ ├── cacert.pem
│ ├── ccu_backup
│ ├── dim.tcl
│ ├── dom_backup
│ ├── dom_save
│ ├── dutycycle
│ ├── dutycycle.tcl
│ ├── export_ftp.sh
│ ├── hmserver
│ ├── pty2tcp
│ ├── timer.tcl
│ └── toggle.tcl
│ ├── index.html
│ ├── maintenance.html
│ ├── robots.txt
│ ├── user
│ └── .userdir
│ └── webcamconfig-default.ini
├── docs
├── cuxd.png
├── cuxd_2.10.pdf
├── cuxd_alpha2_1.12.pdf
├── cuxd_dali_2.9.pdf
├── cuxd_enocean_2.10.pdf
├── cuxd_klf200_2.10.pdf
└── cuxd_wmbus_2.5.pdf
├── generate_img.sh
└── src
├── dfu-programmer
├── .gitignore
├── AUTHORS
├── COPYING
├── ChangeLog
├── Makefile.am
├── NEWS
├── README
├── SF_ReadMe.txt
├── bootstrap.sh
├── configure.ac
├── dfu_completion
├── docs
│ ├── Makefile.am
│ ├── dfu-programmer.1
│ └── dfu-programmer.html
├── fedora
│ ├── 10-dfu-programmer.fdi
│ ├── README
│ └── dfu-programmer.spec.in
├── m4
│ ├── depcomp
│ ├── install-sh
│ └── missing
├── release_proc.txt
├── src
│ ├── Makefile.am
│ ├── arguments.c
│ ├── arguments.h
│ ├── atmel.c
│ ├── atmel.h
│ ├── commands.c
│ ├── commands.h
│ ├── dfu-bool.h
│ ├── dfu-device.h
│ ├── dfu.c
│ ├── dfu.h
│ ├── intel_hex.c
│ ├── intel_hex.h
│ ├── main.c
│ ├── stm32.c
│ ├── stm32.h
│ ├── util.c
│ └── util.h
└── windows
│ ├── atmel_usb_dfu.inf
│ ├── libusb.a
│ └── usb.h
├── digitemp
├── COPYING
├── COPYRIGHT
├── CREDITS
├── ChangeLog
├── DS9097_Schematic.gif
├── FAQ
├── Makefile
├── README
├── TODO
├── contrib
│ ├── digitemp-freebsd.patch
│ └── libusb.patch.txt
├── digitemp-cflags.patch
├── digitemp.1
├── digitemp.spec
├── dthowto.txt
├── perl
│ ├── README
│ ├── check_digitemp.pl
│ ├── digitemp_mysql.pl
│ ├── grant_mysql.sql
│ ├── inc_temp
│ ├── make_mysql.sql
│ ├── maxplot
│ └── rem_temp
├── python
│ ├── gui
│ │ ├── .digitemprc
│ │ ├── digitemp_gui.py
│ │ ├── dtgraph.py
│ │ ├── dttest.py
│ │ └── test_graph.py
│ └── mysql
│ │ ├── README
│ │ ├── home_weather.py
│ │ ├── make_rain_rrd
│ │ ├── make_sensor_rrd
│ │ └── make_wind_rrd
├── rrdb
│ ├── README
│ ├── log-temperature.pl
│ ├── log_temp
│ ├── make_temps
│ ├── temp-all.cgi
│ ├── temp-minmax.cgi
│ └── temp-one.cgi
├── src
│ ├── device_name.c
│ ├── device_name.h
│ ├── digitemp.c
│ ├── digitemp.h
│ ├── ds2438.c
│ ├── ds2490.c
│ ├── ds9097.c
│ └── ds9097u.c
└── userial
│ ├── ad26.c
│ ├── ad26.h
│ ├── cnt1d.c
│ ├── crcutil.c
│ ├── ds2490
│ ├── ownet.c
│ ├── owtran.c
│ ├── usblnk.c
│ ├── usblnk.h
│ └── usbses.c
│ ├── ds9097
│ ├── linuxlnk.c
│ ├── linuxses.c
│ ├── owerr.c
│ ├── ownet.c
│ └── owtran.c
│ ├── ds9097u
│ ├── ds2480.h
│ ├── ds2480ut.c
│ ├── linuxlnk.c
│ ├── owllu.c
│ ├── ownetu.c
│ ├── owsesu.c
│ └── owtrnu.c
│ ├── ioutil.c
│ ├── owerr.c
│ ├── ownet.h
│ ├── owproto.h
│ ├── swt1f.c
│ ├── thermo21.c
│ ├── thermo21.h
│ └── win32
│ └── win32lnk.c
├── ether-wake
├── Makefile
└── ether-wake.c
├── logfilter
├── Makefile
└── logfilter.c
└── update_addon
├── Makefile
└── update_addon.c
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | #github: uwe111 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | #patreon: # Replace with a single Patreon username
5 | #open_collective: # Replace with a single Open Collective username
6 | #ko_fi: # Replace with a single Ko-fi username
7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | #liberapay: # Replace with a single Liberapay username
10 | #issuehunt: # Replace with a single IssueHunt username
11 | #otechie: # Replace with a single Otechie username
12 | custom: https://www.paypal.com/donate/?cmd=_s-xclick&hosted_button_id=PRZ6MMMLY44RE
13 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | pull_request:
5 |
6 | jobs:
7 | generate_img:
8 | runs-on: ubuntu-20.04
9 | steps:
10 | - uses: actions/checkout@v2
11 | - name: generate_img
12 | run: ./generate_img.sh
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /tmp
2 | .DS_Store
3 | cuxd_*.tar.gz
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2016, Uwe Langhammer
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 
2 |
3 | [](https://github.com/jens-maus/cuxd/releases/latest)
4 | [](https://github.com/jens-maus/cuxd/releases/latest)
5 | [](https://github.com/jens-maus/cuxd/actions)
6 | [](https://opensource.org/licenses/BSD-3-Clause)
7 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PRZ6MMMLY44RE)
8 |
9 | This repository hosts the CCU-Addon build environment for the CUx-Daemon (CUxD) project (http://cuxd.de) which provides a universal interface between the HomeMatic/CCU layer (ReGa HSS) and third-party external and virtual devices.
10 |
11 | ## Supported CCU Devices
12 |
13 | An installation of the CUxD Addon is currently supported on the following CCU devices:
14 | * RaspberryMatic (arm, x86)
15 | * HomeMatic CCU3 / piVCCU3
16 | * HomeMatic CCU2 / YAHM / LXCCU / piVCCU2
17 | * HomeMatic CCU1
18 |
19 | ## Installation
20 |
21 | 1. Download the latest CUxD release.
22 | 2. Upload it via the HomeMatic WebUI provided Addon functionality.
23 | 3. Configure CUxD via http://homematic-ccu2/addons/cuxd
24 |
25 | ## Documentation
26 |
27 | Documentation in form of pdf files can be downloaded from https://homematic-forum.de/forum/viewtopic.php?f=37&t=15298.
28 |
29 | ## License
30 |
31 | The CUxD build environment as published in this Github repository is provided under the BSD license. While source code files provided with the build environment are also released under the same license, binaries files (e.g. 'cuxd', 'redir.ccc', 'index.ccc') are licensed under a properitary closed-source license and just added to this repository to allow to automatically generate release archives.
32 |
33 | ## Authors
34 |
35 | * CUxD is developed by Uwe Langhammer (uwe111) with certain parts being previously developed by Alex Krypthul.
36 | * Parts of the build environment for CUxD has been developed by Jens Maus.
37 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 2.10.1
2 |
--------------------------------------------------------------------------------
/ccu1/cuxd/cdc-acm.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/cdc-acm.ko
--------------------------------------------------------------------------------
/ccu1/cuxd/cp210x.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/cp210x.ko
--------------------------------------------------------------------------------
/ccu1/cuxd/cuxd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/cuxd
--------------------------------------------------------------------------------
/ccu1/cuxd/cuxd_addon.cfg:
--------------------------------------------------------------------------------
1 | {
2 | CONFIG_URL /addons/cuxd/index.ccc
3 | CONFIG_DESCRIPTION {
4 |
SystemFS-20EnOcean...
5 | }
6 | ID cuxd
7 | CONFIG_NAME CUx-Daemon
8 | }
9 |
--------------------------------------------------------------------------------
/ccu1/cuxd/dfu-programmer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/dfu-programmer
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/artdmxdim:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/artdmxdim
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/curl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/curl
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/digitemp_DS9097U:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/digitemp_DS9097U
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/ether-wake:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/ether-wake
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/jq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/jq
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/logfilter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/logfilter
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/socat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/extra/socat
--------------------------------------------------------------------------------
/ccu1/cuxd/extra/systemname.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2021 by Uwe Langhammer
4 | # script for reading sytem.Name()
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: systemname.tcl []
9 | #
10 | load tclrega.so
11 |
12 | set filename [lindex $argv 0]
13 |
14 | set cmd "ret = system.Name();";
15 |
16 | if {[catch {array set values [rega_script $cmd]} fid]} {
17 | puts stderr $fid
18 | } else {
19 | if {[info exists values(ret)]} {
20 | if {[string length $filename] > 1 } {
21 | set fo [open $filename "w"]
22 | puts -nonewline $fo $values(ret)
23 | close $fo
24 | } else {
25 | puts $values(ret)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ccu1/cuxd/index.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/index.ccc
--------------------------------------------------------------------------------
/ccu1/cuxd/libusb-0.1.so.4:
--------------------------------------------------------------------------------
1 | libusb-0.1.so.4.4.4
--------------------------------------------------------------------------------
/ccu1/cuxd/libusb-0.1.so.4.4.4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/libusb-0.1.so.4.4.4
--------------------------------------------------------------------------------
/ccu1/cuxd/mos7720.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/mos7720.ko
--------------------------------------------------------------------------------
/ccu1/cuxd/pl2303.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/pl2303.ko
--------------------------------------------------------------------------------
/ccu1/cuxd/redir.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/redir.ccc
--------------------------------------------------------------------------------
/ccu1/cuxd/update_addon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu1/cuxd/update_addon
--------------------------------------------------------------------------------
/ccu1/rc.d/cuxdaemon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | CUXDIR=/usr/local/addons/cuxd
3 | CONFIG_URL=/addons/cuxd/index.ccc
4 | PIDFILE=/var/run/cuxd.pid
5 | export LD_LIBRARY_PATH=$CUXDIR:$LD_LIBRARY_PATH
6 | export CURL_CA_BUNDLE=$CUXDIR/extra/cacert.pem
7 |
8 | case "$1" in
9 | ""|start)
10 | if [ ! -h /usr/local/etc/config/addons/www/cuxd ]
11 | then ln -sf $CUXDIR /usr/local/etc/config/addons/www/cuxd
12 | fi
13 | if [ -f $CUXDIR/cuxd.ini ]
14 | then
15 | grep -v "^HM-SCRIPTHOST=\|^HM-SCRIPTPORT=\|^HM-REGAPORT=" $CUXDIR/cuxd.ini >/tmp/cuxd.ini
16 | diff -q $CUXDIR/cuxd.ini /tmp/cuxd.ini >/dev/null
17 | if [ $? -ne 0 ]
18 | then mv /tmp/cuxd.ini $CUXDIR/cuxd.ini
19 | fi
20 | fi
21 | chmod 0755 $CUXDIR/cuxd
22 | $CUXDIR/cuxd >/dev/null 2>&1
23 | logger -t cuxd -p user.info "started cux-daemon"
24 | ;;
25 |
26 | stop)
27 | kill -TERM `cat $PIDFILE` 2>/dev/null
28 | sleep 1
29 | kill -0 `cat $PIDFILE` 2>/dev/null
30 | if [ $? = 0 ]
31 | then
32 | sleep 10
33 | kill -KILL `cat $PIDFILE` 2>/dev/null
34 | fi
35 | logger -t cuxd -p user.info "stopped cux-daemon"
36 | ;;
37 |
38 | restart)
39 | kill -HUP `cat $PIDFILE` 2>/dev/null
40 | logger -t cuxd -p user.info "stopped (restart) cux-daemon"
41 | sleep 1
42 | kill -0 `cat $PIDFILE` 2>/dev/null
43 | if [ $? = 0 ]
44 | then
45 | sleep 5
46 | kill -KILL `cat $PIDFILE` 2>/dev/null
47 | fi
48 | chmod 0755 $CUXDIR/cuxd
49 | $CUXDIR/cuxd >/dev/null 2>&1
50 | logger -t cuxd -p user.info "started cux-daemon"
51 | ;;
52 |
53 | info)
54 | VER=`$CUXDIR/cuxd -v`
55 | echo "Info: CUx-Daemon $VER
"
56 | echo "Name: CUx-Daemon"
57 | echo "Version: $VER"
58 | echo "Operations: uninstall restart"
59 | echo "Config-Url: $CONFIG_URL"
60 | echo "Update: http://cuxd.de/cuxd-ccu1.php"
61 | ;;
62 |
63 | uninstall)
64 | logger -t cuxd -p user.info "removing cux-daemon"
65 | killall -KILL cuxd >/dev/null 2>&1 || true
66 | $CUXDIR/update_addon cuxd
67 | rm /usr/local/etc/config/addons/www/cuxd
68 | rm -rf $CUXDIR
69 | ;;
70 |
71 | *)
72 | echo "Usage: $0 {start|stop|restart|uninstall}" >&2
73 | exit 1
74 | ;;
75 | esac
76 |
77 | exit 0
78 |
--------------------------------------------------------------------------------
/ccu1/update_script:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cuxd/cuxd -v 2>/dev/null;if [ "$?" -ne "0" ];then echo "wrong binary";exit 2;fi
4 |
5 | ADDON_DIR=/usr/local/addons/cuxd
6 | RCD_DIR=/usr/local/etc/config/rc.d
7 | CONFIG_DIR=/usr/local/etc/config
8 | LCDTOOL=/bin/lcdtool
9 | $LCDTOOL "installing CUxD "
10 |
11 | if [ "`mount | grep mtdblock3 | wc -l`" -eq 0 ]; then
12 | mount /dev/mtdblock3
13 | fi
14 |
15 | mkdir -p $ADDON_DIR
16 | chmod 775 $ADDON_DIR
17 | mkdir -p $RCD_DIR
18 | chmod 755 $RCD_DIR
19 |
20 | # remove old stuff
21 | rm -f $ADDON_DIR/fw.tar.gz
22 | rm -f $ADDON_DIR/*.ko
23 | rm -f $ADDON_DIR/lib*.so*
24 | rm -f $ADDON_DIR/*.ccc
25 | rm -f $ADDON_DIR/hm_addons.cfg.*
26 |
27 | # remove daemon
28 | rm -f $ADDON_DIR/cuxd
29 |
30 | # disable debugging
31 | rm -f $ADDON_DIR/cuxd.dbg
32 | # enable debugging after installation "LOGLEVEL LOGFILE"
33 | #echo "10 /tmp/cuxddbglog.txt" >$ADDON_DIR/cuxd.dbg
34 |
35 | # remove link to website
36 | rm -f $CONFIG_DIR/addons/www/cuxd
37 |
38 | # save current configuration
39 | cp -af $ADDON_DIR/cuxd.ps $ADDON_DIR/cuxd.ps.old
40 |
41 | # copy addon
42 | cp -af cuxd/* $ADDON_DIR
43 |
44 | # copy startup script
45 | cp -af rc.d/* $RCD_DIR
46 |
47 | # link to website
48 | ln -sf $ADDON_DIR $CONFIG_DIR/addons/www/cuxd
49 |
50 | # add menu
51 | ./update_addon cuxd cuxd_addon.cfg
52 |
53 | sync
54 |
55 | $LCDTOOL "completed CUxD "
56 |
--------------------------------------------------------------------------------
/ccu2/cuxd/cuxd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/cuxd
--------------------------------------------------------------------------------
/ccu2/cuxd/dfu-programmer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/dfu-programmer
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/artdmxdim:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/artdmxdim
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/ctl_startup:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014-2018 by Uwe Langhammer
4 | # script for enabling/disabling server processes
5 | #
6 | # usage: ctl_startup [ ... ]
7 | # mode:0..disable
8 | # mode:1..enable
9 | #
10 | load tclrega.so
11 |
12 | set mode [lindex $argv 0]
13 | set reboot_flag [lindex $argv 1]
14 |
15 | if {!($mode >= 0 && $mode <= 1) || ($argc < 3)} {
16 | puts "usage: $argv0 0|1 0|1 \[ ... \]"
17 | exit 1
18 | }
19 |
20 | set reboot 0
21 | set i 0
22 | foreach process $argv {
23 | incr i
24 | if {$i <= 2} continue
25 |
26 | foreach startscript [glob -nocomplain /etc/init.d/*$process] {
27 | # break
28 | }
29 |
30 | if {[info exists startscript] } {
31 | set fp [open $startscript r]
32 | set file_data [read $fp]
33 | set data [split $file_data "\n"]
34 | set line1 [lindex $data 0]
35 | close $fp
36 | set flag 0
37 | if { ($mode == 0) && ($process == "HMServer") } {
38 | puts ""
39 | puts "###############################################################################"
40 | puts "## ##"
41 | puts "## Nach der Deaktivierung sind unter anderem die folgenden CCU2-Funktionen ##"
42 | puts "## nicht mehr moeglich: ##"
43 | puts "## ##"
44 | puts "## - Diagramme ##"
45 | puts "## - Gruppenfunktion (bei Heizungsthermostaten) ##"
46 | puts "## - Erstinitialisierung der SD-Karte ##"
47 | puts "## - Geraetefirmwareupdate ueber WebUI ##"
48 | puts "## - HomeMatic-IP Interface ##"
49 | puts "## ##"
50 | puts "###############################################################################"
51 | puts ""
52 | }
53 | if {[string range $line1 0 3] == "exit"} {
54 | puts "$process in $startscript disabled"
55 | if {$mode != 0} {
56 | puts "enable $process in $startscript"
57 | set flag 1
58 | }
59 | } else {
60 | puts "$process in $startscript enabled"
61 | if {$mode == 0} {
62 | # puts "stop $process"
63 | # exec $startscript stop
64 | puts "disable $process in $startscript"
65 | set flag 1
66 | }
67 | }
68 |
69 | if {$flag == 1} {
70 | if {!($reboot == 1)} {
71 | exec mount -o remount,rw /
72 | }
73 | puts "write $startscript"
74 | set fp [open $startscript w 0755]
75 | if {$mode != 0} {
76 | puts -nonewline $fp [join [lreplace $data 0 0] \n]
77 | } else {
78 | puts $fp "exit"
79 | puts -nonewline $fp $file_data
80 | }
81 | close $fp
82 | set reboot 1
83 | }
84 | } else {
85 | puts "$process startscript not found!"
86 | # exit 1
87 | }
88 | }
89 |
90 | if {($reboot == 1) && ($reboot_flag == 1)} {
91 | exec mount -o remount,ro /
92 | puts -nonewline "saving DOM..."
93 | flush stdout
94 | catch {
95 | rega system.Save()
96 | }
97 | set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
98 | if {$result == ""} {
99 | puts " OK!"
100 | } else {
101 | puts " XML error!"
102 | exit 1
103 | }
104 | file delete /etc/config/InterfacesList.xml
105 | puts "reboot..."
106 | exec /sbin/reboot
107 | }
108 | exit 0
109 |
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/curl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/curl
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/curl.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/curl.tgz
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/digitemp_DS9097U:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/digitemp_DS9097U
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/ether-wake:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/ether-wake
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/jq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/jq
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/logfilter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/logfilter
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/socat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/extra/socat
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/systemname.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2021 by Uwe Langhammer
4 | # script for reading sytem.Name()
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: systemname.tcl []
9 | #
10 | load tclrega.so
11 |
12 | set filename [lindex $argv 0]
13 |
14 | set cmd "ret = system.Name();";
15 |
16 | if {[catch {array set values [rega_script $cmd]} fid]} {
17 | puts stderr $fid
18 | } else {
19 | if {[info exists values(ret)]} {
20 | if {[string length $filename] > 1 } {
21 | set fo [open $filename "w"]
22 | puts -nonewline $fo $values(ret)
23 | close $fo
24 | } else {
25 | puts $values(ret)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ccu2/cuxd/extra/update-check.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 |
3 | set checkURL "https://cuxd.de/cuxd-ccu2.php?$env(QUERY_STRING)"
4 | set downloadURL "http://cuxd.de/cuxd-ccu2.php?$env(QUERY_STRING)"
5 |
6 | catch {
7 | set input $env(QUERY_STRING)
8 | set pairs [split $input &]
9 | foreach pair $pairs {
10 | if {$pair == "cmd=download"} {
11 | set cmd "download"
12 | break
13 | }
14 | }
15 | }
16 |
17 | if { [info exists cmd ] && $cmd == "download"} {
18 | puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
19 | puts -nonewline ""
20 | } else {
21 | puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
22 | catch {
23 | set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
24 | }
25 | if { [info exists newversion] } {
26 | puts $newversion
27 | } else {
28 | puts "n/a"
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/ccu2/cuxd/index.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/index.ccc
--------------------------------------------------------------------------------
/ccu2/cuxd/libusb-1.0.so:
--------------------------------------------------------------------------------
1 | libusb-1.0.so.0
--------------------------------------------------------------------------------
/ccu2/cuxd/libusb-1.0.so.0:
--------------------------------------------------------------------------------
1 | libusb-1.0.so.0.1.0
--------------------------------------------------------------------------------
/ccu2/cuxd/libusb-1.0.so.0.1.0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/libusb-1.0.so.0.1.0
--------------------------------------------------------------------------------
/ccu2/cuxd/redir.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/redir.ccc
--------------------------------------------------------------------------------
/ccu2/cuxd/update_addon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/cuxd/update_addon
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/cdc-acm.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/cdc-acm.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/ch341.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/ch341.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/cp210x.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/cp210x.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/ftdi_sio.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/ftdi_sio.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/mos7720.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/mos7720.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/pl2303.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/pl2303.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.11.ccu2/usbserial.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.11.ccu2/usbserial.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/cdc-acm.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/cdc-acm.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/ch341.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/ch341.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/cp210x.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/cp210x.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/ftdi_sio.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/ftdi_sio.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/mos7720.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/mos7720.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/pl2303.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/pl2303.ko
--------------------------------------------------------------------------------
/ccu2/modules/3.4.113.ccu2/usbserial.ko:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu2/modules/3.4.113.ccu2/usbserial.ko
--------------------------------------------------------------------------------
/ccu2/update_script:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cuxd/cuxd -v 2>/dev/null;if [ "$?" -ne "0" ];then echo "wrong binary";exit 2;fi
4 |
5 | ADDON_DIR=/usr/local/addons/cuxd
6 | RCD_DIR=/usr/local/etc/config/rc.d
7 | CONFIG_DIR=/usr/local/etc/config
8 | STARTRC=/etc/init.d/S55cuxd
9 | STARTINIT=/etc/init.d/S55InitAddons
10 |
11 | if [ "$1" = "" ];then exit 2;fi
12 |
13 | mount /usr/local
14 |
15 | mkdir -p $ADDON_DIR
16 | chmod 755 $ADDON_DIR
17 | mkdir -p $RCD_DIR
18 | chmod 755 $RCD_DIR
19 |
20 | # remove daemon
21 | rm -f $ADDON_DIR/cuxd
22 |
23 | # disable debugging
24 | rm -f $ADDON_DIR/cuxd.dbg
25 | # enable debugging after installation "LOGLEVEL LOGFILE"
26 | #echo "10 /tmp/cuxddbglog.txt" >$ADDON_DIR/cuxd.dbg
27 |
28 | # remove libraries
29 | rm -f $ADDON_DIR/lib*.so*
30 |
31 | # remove modules dir
32 | rm -rf $ADDON_DIR/modules
33 |
34 | # remove link to website
35 | rm -f $CONFIG_DIR/addons/www/cuxd
36 |
37 | # save current configuration
38 | cp -af $ADDON_DIR/cuxd.ps $ADDON_DIR/cuxd.ps.old
39 |
40 | # copy addon
41 | cp -af cuxd/* $ADDON_DIR
42 |
43 | # copy startup script
44 | cp -af rc.d/* $RCD_DIR
45 |
46 | # link to website
47 | ln -sf $ADDON_DIR $CONFIG_DIR/addons/www/cuxd
48 |
49 | # add menu
50 | ./update_addon cuxd cuxd_addon.cfg
51 |
52 | # create/check init.d symlink
53 | if [ -d /oldroot ]
54 | then
55 | mount -t ubifs ubi0:root /oldroot
56 | if [ -f /oldroot$STARTINIT ]
57 | then
58 | if [ -h /oldroot$STARTRC ]
59 | then
60 | rm -f /oldroot$STARTRC
61 | fi
62 | else
63 | if [ ! -h /oldroot$STARTRC ]
64 | then
65 | ln -sf $RCD_DIR/cuxdaemon /oldroot$STARTRC
66 | fi
67 | fi
68 | fi
69 |
70 | sync
71 |
--------------------------------------------------------------------------------
/ccu3/cuxd/cuxd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/cuxd
--------------------------------------------------------------------------------
/ccu3/cuxd/dfu-programmer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/dfu-programmer
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/artdmxdim:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/extra/artdmxdim
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/ctl_startup:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014-2018 by Uwe Langhammer
4 | # script for enabling/disabling server processes
5 | #
6 | # usage: ctl_startup [ ... ]
7 | # mode:0..disable
8 | # mode:1..enable
9 | #
10 | load tclrega.so
11 |
12 | set mode [lindex $argv 0]
13 | set reboot_flag [lindex $argv 1]
14 |
15 | if {!($mode >= 0 && $mode <= 1) || ($argc < 3)} {
16 | puts "usage: $argv0 0|1 0|1 \[ ... \]"
17 | exit 1
18 | }
19 |
20 | set reboot 0
21 | set i 0
22 | foreach process $argv {
23 | incr i
24 | if {$i <= 2} continue
25 |
26 | foreach startscript [glob -nocomplain /etc/init.d/*$process] {
27 | # break
28 | }
29 |
30 | if {[info exists startscript] } {
31 | set fp [open $startscript r]
32 | set file_data [read $fp]
33 | set data [split $file_data "\n"]
34 | set line1 [lindex $data 0]
35 | close $fp
36 | set flag 0
37 | if { ($mode == 0) && ($process == "HMServer") } {
38 | puts ""
39 | puts "###############################################################################"
40 | puts "## ##"
41 | puts "## Nach der Deaktivierung sind unter anderem die folgenden CCU2-Funktionen ##"
42 | puts "## nicht mehr moeglich: ##"
43 | puts "## ##"
44 | puts "## - Diagramme ##"
45 | puts "## - Gruppenfunktion (bei Heizungsthermostaten) ##"
46 | puts "## - Erstinitialisierung der SD-Karte ##"
47 | puts "## - Geraetefirmwareupdate ueber WebUI ##"
48 | puts "## - HomeMatic-IP Interface ##"
49 | puts "## ##"
50 | puts "###############################################################################"
51 | puts ""
52 | }
53 | if {[string range $line1 0 3] == "exit"} {
54 | puts "$process in $startscript disabled"
55 | if {$mode != 0} {
56 | puts "enable $process in $startscript"
57 | set flag 1
58 | }
59 | } else {
60 | puts "$process in $startscript enabled"
61 | if {$mode == 0} {
62 | # puts "stop $process"
63 | # exec $startscript stop
64 | puts "disable $process in $startscript"
65 | set flag 1
66 | }
67 | }
68 |
69 | if {$flag == 1} {
70 | if {!($reboot == 1)} {
71 | exec mount -o remount,rw /
72 | }
73 | puts "write $startscript"
74 | set fp [open $startscript w 0755]
75 | if {$mode != 0} {
76 | puts -nonewline $fp [join [lreplace $data 0 0] \n]
77 | } else {
78 | puts $fp "exit"
79 | puts -nonewline $fp $file_data
80 | }
81 | close $fp
82 | set reboot 1
83 | }
84 | } else {
85 | puts "$process startscript not found!"
86 | # exit 1
87 | }
88 | }
89 |
90 | if {($reboot == 1) && ($reboot_flag == 1)} {
91 | exec mount -o remount,ro /
92 | puts -nonewline "saving DOM..."
93 | flush stdout
94 | catch {
95 | rega system.Save()
96 | }
97 | set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
98 | if {$result == ""} {
99 | puts " OK!"
100 | } else {
101 | puts " XML error!"
102 | exit 1
103 | }
104 | file delete /etc/config/InterfacesList.xml
105 | puts "reboot..."
106 | exec /sbin/reboot
107 | }
108 | exit 0
109 |
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/curl:
--------------------------------------------------------------------------------
1 | /usr/bin/curl
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/digitemp_DS9097U:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/extra/digitemp_DS9097U
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/ether-wake:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/extra/ether-wake
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/jq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/extra/jq
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/logfilter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/extra/logfilter
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/socat:
--------------------------------------------------------------------------------
1 | /usr/bin/socat
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/systemname.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2021 by Uwe Langhammer
4 | # script for reading sytem.Name()
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: systemname.tcl []
9 | #
10 | load tclrega.so
11 |
12 | set filename [lindex $argv 0]
13 |
14 | set cmd "ret = system.Name();";
15 |
16 | if {[catch {array set values [rega_script $cmd]} fid]} {
17 | puts stderr $fid
18 | } else {
19 | if {[info exists values(ret)]} {
20 | if {[string length $filename] > 1 } {
21 | set fo [open $filename "w"]
22 | puts -nonewline $fo $values(ret)
23 | close $fo
24 | } else {
25 | puts $values(ret)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ccu3/cuxd/extra/update-check.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 |
3 | set checkURL "https://cuxd.de/cuxd-ccurm.php?$env(QUERY_STRING)"
4 | set downloadURL "http://cuxd.de/cuxd-ccurm.php?$env(QUERY_STRING)"
5 |
6 | catch {
7 | set input $env(QUERY_STRING)
8 | set pairs [split $input &]
9 | foreach pair $pairs {
10 | if {$pair == "cmd=download"} {
11 | set cmd "download"
12 | break
13 | }
14 | }
15 | }
16 |
17 | if { [info exists cmd ] && $cmd == "download"} {
18 | puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
19 | puts -nonewline ""
20 | } else {
21 | puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
22 | catch {
23 | set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
24 | }
25 | if { [info exists newversion] } {
26 | puts $newversion
27 | } else {
28 | puts "n/a"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ccu3/cuxd/index.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/index.ccc
--------------------------------------------------------------------------------
/ccu3/cuxd/redir.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/redir.ccc
--------------------------------------------------------------------------------
/ccu3/cuxd/update_addon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccu3/cuxd/update_addon
--------------------------------------------------------------------------------
/ccu3/rc.d/cuxdaemon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | CUXDIR=/usr/local/addons/cuxd
3 | CONFIG_URL=/addons/cuxd/index.ccc
4 | CONFIG_DIR=/usr/local/etc/config
5 | STARTRC=/etc/init.d/S55cuxd
6 | STARTINIT=/etc/init.d/S55InitAddons
7 | PSPID=`ps -o pid,comm | awk '{if($2=="cuxd"){print $1}}'`
8 | export TZ=`cat /etc/config/TZ`
9 | export LD_LIBRARY_PATH=$CUXDIR:$LD_LIBRARY_PATH
10 |
11 | Start () {
12 | echo -n "Starting CUxD: "
13 | if [ ! -h $CONFIG_DIR/addons/www/cuxd ]
14 | then
15 | ln -sf $CUXDIR $CONFIG_DIR/addons/www/cuxd
16 | fi
17 | if [ -f $STARTINIT ]
18 | then
19 | if [ -h $STARTRC ]
20 | then
21 | mount -o remount,rw /
22 | rm -f $STARTRC
23 | mount -o remount,ro /
24 | fi
25 | else
26 | if [ ! -h $STARTRC ]
27 | then
28 | mount -o remount,rw /
29 | ln -sf $CONFIG_DIR/rc.d/cuxdaemon $STARTRC
30 | mount -o remount,ro /
31 | fi
32 | fi
33 | if [ -f /usr/bin/jq ]
34 | then
35 | if [ ! -h $CUXDIR/extra/jq ]
36 | then
37 | ln -sf /usr/bin/jq $CUXDIR/extra/jq
38 | fi
39 | fi
40 | if [ "$PSPID" = "" ]
41 | then
42 | modprobe ehci_hcd 2>/dev/null
43 | if [ -f $CUXDIR/cuxd.ini ]
44 | then
45 | grep -v "^HM-SCRIPTHOST=\|^HM-SCRIPTPORT=\|^HM-REGAPORT=" $CUXDIR/cuxd.ini >/tmp/cuxd.ini
46 | diff -q $CUXDIR/cuxd.ini /tmp/cuxd.ini >/dev/null
47 | if [ $? -ne 0 ]
48 | then
49 | mv /tmp/cuxd.ini $CUXDIR/cuxd.ini
50 | else
51 | rm /tmp/cuxd.ini
52 | fi
53 | fi
54 | chmod 0755 $CUXDIR/cuxd
55 | $CUXDIR/cuxd >/dev/null 2>&1
56 | logger -t cuxd -p user.info "started cux-daemon"
57 | fi
58 | echo "OK"
59 | }
60 |
61 | Stop () {
62 | echo -n "Stopping CUxD: "
63 | if [ "$PSPID" != "" ]
64 | then
65 | kill $1 $PSPID 2>/dev/null
66 | sleep 1
67 | kill -0 $PSPID 2>/dev/null
68 | if [ $? -eq 0 ]
69 | then
70 | sleep 10
71 | kill -KILL $PSPID 2>/dev/null
72 | fi
73 | logger -t cuxd -p user.info "stopped cux-daemon"
74 | fi
75 | echo "OK"
76 | }
77 |
78 | case "$1" in
79 | ""|init|start)
80 | if [ -d $CUXDIR ]
81 | then
82 | Start
83 | fi
84 | ;;
85 |
86 | stop)
87 | Stop -TERM
88 | ;;
89 |
90 | restart)
91 | Stop -HUP
92 | if [ -d $CUXDIR ]
93 | then
94 | echo -n "Starting CUxD: "
95 | chmod 0755 $CUXDIR/cuxd
96 | $CUXDIR/cuxd >/dev/null 2>&1
97 | logger -t cuxd -p user.info "started (restart) cux-daemon"
98 | echo "OK"
99 | fi
100 | ;;
101 |
102 | info)
103 | if [ -d $CUXDIR ]
104 | then
105 | VER=`$CUXDIR/cuxd -v`
106 | echo "Info: CUx-Daemon $VER
"
107 | echo "Name: CUx-Daemon"
108 | echo "Version: $VER"
109 | echo "Operations: uninstall restart"
110 | echo "Config-Url: $CONFIG_URL"
111 | echo "Update: /addons/cuxd/extra/update-check.cgi"
112 | fi
113 | ;;
114 |
115 | uninstall)
116 | logger -t cuxd -p user.info "removing cux-daemon"
117 | killall -KILL cuxd >/dev/null 2>&1 || true
118 | /bin/sed -i '//{:a;N;/<\/ipc>/!ba };/CUxD<\/name>/d' /etc/config/InterfacesList.xml
119 | cat <<-ENDOFTCL >/tmp/remove_cuxd.$$.tcl
120 | load tclrega.so
121 | array set values [rega_script "var o = dom.GetObject('CUxD');if (o) {WriteLine('remove '#o.ID()#' '#o.Name());dom.GetObject(ID_INTERFACES).Remove(o);dom.DeleteObject(o);system.Save();} WriteLine('rega script finished!');"]
122 | puts -nonewline \$values(STDOUT)
123 | ENDOFTCL
124 | tclsh /tmp/remove_cuxd.$$.tcl
125 | rm /tmp/remove_cuxd.$$.tcl
126 | if [ -d $CUXDIR ]
127 | then
128 | $CUXDIR/update_addon cuxd
129 | $CUXDIR/extra/ctl_startup 1 0 rfd HMServer ReGaHss
130 | rm $CONFIG_DIR/addons/www/cuxd
131 | rm -rf $CUXDIR
132 | fi
133 | if [ -h $STARTRC ]
134 | then
135 | mount -o remount,rw /
136 | rm -f $STARTRC
137 | mount -o remount,ro /
138 | fi
139 | ;;
140 |
141 | *)
142 | echo "Usage: $0 {init|start|stop|restart|uninstall}" >&2
143 | exit 1
144 | ;;
145 | esac
146 |
147 | exit 0
148 |
--------------------------------------------------------------------------------
/ccu3/update_script:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cuxd/cuxd -v 2>/dev/null;if [ "$?" -ne "0" ];then echo "wrong binary";exit 2;fi
4 |
5 | ADDON_DIR=/usr/local/addons/cuxd
6 | CONFIG_DIR=/usr/local/etc/config
7 | RCD_DIR=$CONFIG_DIR/rc.d
8 |
9 | # mount /usr/local if not already mounted
10 | mount | grep /usr/local 2>&1 >/dev/null
11 | if [ $? -eq 1 ]; then
12 | mount /usr/local
13 | fi
14 |
15 | # make sure the addon and rc.d dir exist
16 | mkdir -p $ADDON_DIR
17 | chmod 755 $ADDON_DIR
18 | mkdir -p $RCD_DIR
19 | chmod 755 $RCD_DIR
20 |
21 | # remove old stuff
22 | rm -f $ADDON_DIR/fw.tar.gz
23 | rm -f $ADDON_DIR/*.ko
24 | rm -f $ADDON_DIR/lib*.so*
25 | rm -f $ADDON_DIR/*.ccc
26 | rm -f $ADDON_DIR/hm_addons.cfg.*
27 | rm -f $ADDON_DIR/cuxd_addon.cfg
28 | rm -f $ADDON_DIR/extra/curl
29 | rm -f $ADDON_DIR/extra/socat
30 | rm -f $ADDON_DIR/libusb-1.0.*
31 |
32 | # remove daemon
33 | rm -f $ADDON_DIR/cuxd
34 |
35 | # disable debugging
36 | rm -f $ADDON_DIR/cuxd.dbg
37 | # enable debugging after installation "LOGLEVEL LOGFILE"
38 | #echo "10 /tmp/cuxddbglog.txt" >$ADDON_DIR/cuxd.dbg
39 |
40 | # remove link to website
41 | rm -f $CONFIG_DIR/addons/www/cuxd
42 |
43 | # save current configuration
44 | if [ -f "$ADDON_DIR/cuxd.ps" ]; then
45 | cp -af $ADDON_DIR/cuxd.ps $ADDON_DIR/cuxd.ps.old
46 | fi
47 |
48 | # copy addon
49 | cp -af cuxd/* $ADDON_DIR/
50 |
51 | # copy startup script
52 | cp -af rc.d/* $RCD_DIR/
53 |
54 | # link to website
55 | ln -sf $ADDON_DIR $CONFIG_DIR/addons/www/cuxd
56 |
57 | # add menu
58 | touch $CONFIG_DIR/hm_addons.cfg
59 | # $ADDON_DIR/update_addon cuxd $ADDON_DIR/cuxd_addon.cfg
60 | ./update_addon cuxd cuxd_addon.cfg
61 |
62 | # sync filesystems to make sure all changes are written to disk
63 | sync
64 |
65 | PSPID=`ps -o pid,comm | awk '{if($2=="ReGaHss"){print $1}}'`
66 | if [ "$PSPID" != "" ]
67 | then
68 | if [ -f /etc/config/InterfacesList.xml ]
69 | then
70 | grep "CUxD" /etc/config/InterfacesList.xml
71 | rc=$?
72 |
73 | if [ $rc -ne 0 ]
74 | then
75 | # stop ReGa
76 | /etc/init.d/S??ReGaHss stop
77 | fi
78 |
79 | # restart CUxD
80 | $RCD_DIR/cuxdaemon stop
81 | $RCD_DIR/cuxdaemon start
82 |
83 | if [ $rc -ne 0 ]
84 | then
85 | # start ReGa
86 | /etc/init.d/S??ReGaHss start
87 | fi
88 |
89 | fi
90 | fi
91 |
92 | # all CCUs perform a reboot after installing
93 | # addons via WebUI.
94 | exit 0
95 |
--------------------------------------------------------------------------------
/ccux86/cuxd/cuxd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/cuxd
--------------------------------------------------------------------------------
/ccux86/cuxd/dfu-programmer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/dfu-programmer
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/artdmxdim:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/extra/artdmxdim
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/ctl_startup:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014-2018 by Uwe Langhammer
4 | # script for enabling/disabling server processes
5 | #
6 | # usage: ctl_startup [ ... ]
7 | # mode:0..disable
8 | # mode:1..enable
9 | #
10 | load tclrega.so
11 |
12 | set mode [lindex $argv 0]
13 | set reboot_flag [lindex $argv 1]
14 |
15 | if {!($mode >= 0 && $mode <= 1) || ($argc < 3)} {
16 | puts "usage: $argv0 0|1 0|1 \[ ... \]"
17 | exit 1
18 | }
19 |
20 | set reboot 0
21 | set i 0
22 | foreach process $argv {
23 | incr i
24 | if {$i <= 2} continue
25 |
26 | foreach startscript [glob -nocomplain /etc/init.d/*$process] {
27 | # break
28 | }
29 |
30 | if {[info exists startscript] } {
31 | set fp [open $startscript r]
32 | set file_data [read $fp]
33 | set data [split $file_data "\n"]
34 | set line1 [lindex $data 0]
35 | close $fp
36 | set flag 0
37 | if { ($mode == 0) && ($process == "HMServer") } {
38 | puts ""
39 | puts "###############################################################################"
40 | puts "## ##"
41 | puts "## Nach der Deaktivierung sind unter anderem die folgenden CCU2-Funktionen ##"
42 | puts "## nicht mehr moeglich: ##"
43 | puts "## ##"
44 | puts "## - Diagramme ##"
45 | puts "## - Gruppenfunktion (bei Heizungsthermostaten) ##"
46 | puts "## - Erstinitialisierung der SD-Karte ##"
47 | puts "## - Geraetefirmwareupdate ueber WebUI ##"
48 | puts "## - HomeMatic-IP Interface ##"
49 | puts "## ##"
50 | puts "###############################################################################"
51 | puts ""
52 | }
53 | if {[string range $line1 0 3] == "exit"} {
54 | puts "$process in $startscript disabled"
55 | if {$mode != 0} {
56 | puts "enable $process in $startscript"
57 | set flag 1
58 | }
59 | } else {
60 | puts "$process in $startscript enabled"
61 | if {$mode == 0} {
62 | # puts "stop $process"
63 | # exec $startscript stop
64 | puts "disable $process in $startscript"
65 | set flag 1
66 | }
67 | }
68 |
69 | if {$flag == 1} {
70 | if {!($reboot == 1)} {
71 | exec mount -o remount,rw /
72 | }
73 | puts "write $startscript"
74 | set fp [open $startscript w 0755]
75 | if {$mode != 0} {
76 | puts -nonewline $fp [join [lreplace $data 0 0] \n]
77 | } else {
78 | puts $fp "exit"
79 | puts -nonewline $fp $file_data
80 | }
81 | close $fp
82 | set reboot 1
83 | }
84 | } else {
85 | puts "$process startscript not found!"
86 | # exit 1
87 | }
88 | }
89 |
90 | if {($reboot == 1) && ($reboot_flag == 1)} {
91 | exec mount -o remount,ro /
92 | puts -nonewline "saving DOM..."
93 | flush stdout
94 | catch {
95 | rega system.Save()
96 | }
97 | set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
98 | if {$result == ""} {
99 | puts " OK!"
100 | } else {
101 | puts " XML error!"
102 | exit 1
103 | }
104 | file delete /etc/config/InterfacesList.xml
105 | puts "reboot..."
106 | exec /sbin/reboot
107 | }
108 | exit 0
109 |
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/curl:
--------------------------------------------------------------------------------
1 | /usr/bin/curl
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/digitemp_DS9097U:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/extra/digitemp_DS9097U
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/ether-wake:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/extra/ether-wake
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/jq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/extra/jq
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/logfilter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/extra/logfilter
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/socat:
--------------------------------------------------------------------------------
1 | /usr/bin/socat
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/systemname.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2021 by Uwe Langhammer
4 | # script for reading sytem.Name()
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: systemname.tcl []
9 | #
10 | load tclrega.so
11 |
12 | set filename [lindex $argv 0]
13 |
14 | set cmd "ret = system.Name();";
15 |
16 | if {[catch {array set values [rega_script $cmd]} fid]} {
17 | puts stderr $fid
18 | } else {
19 | if {[info exists values(ret)]} {
20 | if {[string length $filename] > 1 } {
21 | set fo [open $filename "w"]
22 | puts -nonewline $fo $values(ret)
23 | close $fo
24 | } else {
25 | puts $values(ret)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ccux86/cuxd/extra/update-check.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 |
3 | set checkURL "https://cuxd.de/cuxd-ccux86.php?$env(QUERY_STRING)"
4 | set downloadURL "http://cuxd.de/cuxd-ccux86.php?$env(QUERY_STRING)"
5 |
6 | catch {
7 | set input $env(QUERY_STRING)
8 | set pairs [split $input &]
9 | foreach pair $pairs {
10 | if {$pair == "cmd=download"} {
11 | set cmd "download"
12 | break
13 | }
14 | }
15 | }
16 |
17 | if { [info exists cmd ] && $cmd == "download"} {
18 | puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
19 | puts -nonewline ""
20 | } else {
21 | puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
22 | catch {
23 | set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
24 | }
25 | if { [info exists newversion] } {
26 | puts $newversion
27 | } else {
28 | puts "n/a"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ccux86/cuxd/index.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/index.ccc
--------------------------------------------------------------------------------
/ccux86/cuxd/redir.ccc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/redir.ccc
--------------------------------------------------------------------------------
/ccux86/cuxd/update_addon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/ccux86/cuxd/update_addon
--------------------------------------------------------------------------------
/ccux86/rc.d/cuxdaemon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | CUXDIR=/usr/local/addons/cuxd
3 | CONFIG_URL=/addons/cuxd/index.ccc
4 | CONFIG_DIR=/usr/local/etc/config
5 | STARTRC=/etc/init.d/S55cuxd
6 | STARTINIT=/etc/init.d/S55InitAddons
7 | PSPID=`ps -A -o pid,comm | awk '{if($2=="cuxd"){print $1}}'`
8 | export TZ=`cat /etc/config/TZ`
9 | export LD_LIBRARY_PATH=$CUXDIR:$LD_LIBRARY_PATH
10 |
11 | Start () {
12 | echo -n "Starting CUxD: "
13 | if [ ! -h $CONFIG_DIR/addons/www/cuxd ]
14 | then
15 | ln -sf $CUXDIR $CONFIG_DIR/addons/www/cuxd
16 | fi
17 | if [ -f $STARTINIT ]
18 | then
19 | if [ -h $STARTRC ]
20 | then
21 | rm -f $STARTRC
22 | fi
23 | else
24 | if [ ! -h $STARTRC ]
25 | then
26 | ln -sf $CONFIG_DIR/rc.d/cuxdaemon $STARTRC
27 | fi
28 | fi
29 | if [ -f /usr/bin/jq ]
30 | then
31 | if [ ! -h $CUXDIR/extra/jq ]
32 | then
33 | ln -sf /usr/bin/jq $CUXDIR/extra/jq
34 | fi
35 | fi
36 | if [ "$PSPID" = "" ]
37 | then
38 | modprobe ehci_hcd 2>/dev/null
39 | chmod 0755 $CUXDIR/cuxd
40 | $CUXDIR/cuxd >/dev/null 2>&1
41 | logger -t cuxd -p user.info "started cux-daemon"
42 | fi
43 | echo "OK"
44 | }
45 |
46 | Stop () {
47 | echo -n "Stopping CUxD: "
48 | if [ "$PSPID" != "" ]
49 | then
50 | kill $1 $PSPID 2>/dev/null
51 | sleep 1
52 | kill -0 $PSPID 2>/dev/null
53 | if [ $? -eq 0 ]
54 | then
55 | sleep 10
56 | kill -KILL $PSPID 2>/dev/null
57 | fi
58 | logger -t cuxd -p user.info "stopped cux-daemon"
59 | fi
60 | echo "OK"
61 | }
62 |
63 | case "$1" in
64 | ""|init|start)
65 | if [ -d $CUXDIR ]
66 | then
67 | Start
68 | fi
69 | ;;
70 |
71 | stop)
72 | Stop -TERM
73 | ;;
74 |
75 | restart)
76 | Stop -HUP
77 | if [ -d $CUXDIR ]
78 | then
79 | echo -n "Starting CUxD: "
80 | chmod 0755 $CUXDIR/cuxd
81 | $CUXDIR/cuxd >/dev/null 2>&1
82 | logger -t cuxd -p user.info "started (restart) cux-daemon"
83 | echo "OK"
84 | fi
85 | ;;
86 |
87 | info)
88 | if [ -d $CUXDIR ]
89 | then
90 | VER=`$CUXDIR/cuxd -v`
91 | echo "Info: CUx-Daemon $VER
"
92 | echo "Name: CUx-Daemon"
93 | echo "Version: $VER"
94 | echo "Operations: uninstall restart"
95 | echo "Config-Url: $CONFIG_URL"
96 | echo "Update: /addons/cuxd/extra/update-check.cgi"
97 | fi
98 | ;;
99 |
100 | uninstall)
101 | logger -t cuxd -p user.info "removing cux-daemon"
102 | killall -KILL cuxd >/dev/null 2>&1 || true
103 | /bin/sed -i '//{:a;N;/<\/ipc>/!ba };/CUxD<\/name>/d' /etc/config/InterfacesList.xml
104 | cat <<-ENDOFTCL >/tmp/remove_cuxd.$$.tcl
105 | load tclrega.so
106 | array set values [rega_script "var o = dom.GetObject('CUxD');if (o) {WriteLine('remove '#o.ID()#' '#o.Name());dom.GetObject(ID_INTERFACES).Remove(o);dom.DeleteObject(o);system.Save();} WriteLine('rega script finished!');"]
107 | puts -nonewline \$values(STDOUT)
108 | ENDOFTCL
109 | tclsh /tmp/remove_cuxd.$$.tcl
110 | rm /tmp/remove_cuxd.$$.tcl
111 | if [ -d $CUXDIR ]
112 | then
113 | $CUXDIR/update_addon cuxd
114 | $CUXDIR/extra/ctl_startup 1 0 rfd HMServer ReGaHss
115 | rm $CONFIG_DIR/addons/www/cuxd
116 | rm -rf $CUXDIR
117 | fi
118 | if [ -h $STARTRC ]
119 | then
120 | rm -f $STARTRC
121 | fi
122 | ;;
123 |
124 | *)
125 | echo "Usage: $0 {init|start|stop|restart|uninstall}" >&2
126 | exit 1
127 | ;;
128 | esac
129 |
130 | exit 0
131 |
--------------------------------------------------------------------------------
/ccux86/update_script:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cuxd/cuxd -v 2>/dev/null;if [ "$?" -ne "0" ];then echo "wrong binary";exit 2;fi
4 |
5 | ADDON_DIR=/usr/local/addons/cuxd
6 | CONFIG_DIR=/usr/local/etc/config
7 | RCD_DIR=$CONFIG_DIR/rc.d
8 |
9 | # make sure the addon and rc.d dir exist
10 | mkdir -p $ADDON_DIR
11 | chmod 755 $ADDON_DIR
12 | mkdir -p $RCD_DIR
13 | chmod 755 $RCD_DIR
14 |
15 | # remove old stuff
16 | rm -f $ADDON_DIR/fw.tar.gz
17 | rm -f $ADDON_DIR/*.ko
18 | rm -f $ADDON_DIR/lib*.so*
19 | rm -f $ADDON_DIR/*.ccc
20 | rm -f $ADDON_DIR/hm_addons.cfg.*
21 | rm -f $ADDON_DIR/cuxd_addon.cfg
22 | rm -f $ADDON_DIR/extra/curl
23 | rm -f $ADDON_DIR/extra/socat
24 | rm -f $ADDON_DIR/libusb-1.0.*
25 |
26 | # remove daemon
27 | rm -f $ADDON_DIR/cuxd
28 |
29 | # disable debugging
30 | rm -f $ADDON_DIR/cuxd.dbg
31 | # enable debugging after installation "LOGLEVEL LOGFILE"
32 | #echo "10 /tmp/cuxddbglog.txt" >$ADDON_DIR/cuxd.dbg
33 |
34 | # remove link to website
35 | rm -f $CONFIG_DIR/addons/www/cuxd
36 |
37 | # save current configuration
38 | if [ -f "$ADDON_DIR/cuxd.ps" ]; then
39 | cp -af $ADDON_DIR/cuxd.ps $ADDON_DIR/cuxd.ps.old
40 | fi
41 |
42 | # copy addon
43 | cp -af cuxd/* $ADDON_DIR/
44 |
45 | # copy startup script
46 | cp -af rc.d/* $RCD_DIR/
47 |
48 | # link to website
49 | ln -sf $ADDON_DIR $CONFIG_DIR/addons/www/cuxd
50 |
51 | # add menu
52 | touch $CONFIG_DIR/hm_addons.cfg
53 | # $ADDON_DIR/update_addon cuxd $ADDON_DIR/cuxd_addon.cfg
54 | ./update_addon cuxd cuxd_addon.cfg
55 |
56 | # sync filesystems to make sure all changes are written to disk
57 | sync
58 |
59 | PSPID=`ps -o pid,comm | awk '{if($2=="ReGaHss"){print $1}}'`
60 | if [ "$PSPID" != "" ]
61 | then
62 | if [ -f /etc/config/InterfacesList.xml ]
63 | then
64 | grep "CUxD" /etc/config/InterfacesList.xml
65 | rc=$?
66 |
67 | if [ $rc -ne 0 ]
68 | then
69 | # stop ReGa
70 | /etc/init.d/S??ReGaHss stop
71 | fi
72 |
73 | # restart CUxD
74 | $RCD_DIR/cuxdaemon stop
75 | $RCD_DIR/cuxdaemon start
76 |
77 | if [ $rc -ne 0 ]
78 | then
79 | # start ReGa
80 | /etc/init.d/S??ReGaHss start
81 | fi
82 |
83 | fi
84 | fi
85 |
86 | # all CCUs perform a reboot after installing
87 | # addons via WebUI.
88 | exit 0
89 |
--------------------------------------------------------------------------------
/common/cuxd/CUXD.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/CUXD.PNG
--------------------------------------------------------------------------------
/common/cuxd/ajax.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/ajax.gif
--------------------------------------------------------------------------------
/common/cuxd/cproxy.ccc:
--------------------------------------------------------------------------------
1 | redir.ccc
--------------------------------------------------------------------------------
/common/cuxd/curl:
--------------------------------------------------------------------------------
1 | extra/curl
--------------------------------------------------------------------------------
/common/cuxd/cuxd.inc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/cuxd.inc
--------------------------------------------------------------------------------
/common/cuxd/cuxd_addon.cfg:
--------------------------------------------------------------------------------
1 | {
2 | CONFIG_URL /addons/cuxd/index.ccc
3 | CONFIG_DESCRIPTION {
4 | de {SystemFS-20EnOcean...}
5 | en {SystemFS-20EnOcean...}
6 | }
7 | ID cuxd
8 | CONFIG_NAME CUx-Daemon
9 | }
10 |
--------------------------------------------------------------------------------
/common/cuxd/dfu/at90usb1286.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/at90usb1286.zip
--------------------------------------------------------------------------------
/common/cuxd/dfu/at90usb162.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/at90usb162.tgz
--------------------------------------------------------------------------------
/common/cuxd/dfu/at90usb646.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/at90usb646.zip
--------------------------------------------------------------------------------
/common/cuxd/dfu/atmega32u2.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/atmega32u2.tgz
--------------------------------------------------------------------------------
/common/cuxd/dfu/atmega32u4.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/atmega32u4.tgz
--------------------------------------------------------------------------------
/common/cuxd/dfu/atxmega128a4u.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/dfu/atxmega128a4u.zip
--------------------------------------------------------------------------------
/common/cuxd/dfu/table.txt:
--------------------------------------------------------------------------------
1 | #
2 | # translation table for dfu-programmer firmware
3 | #
4 | AT90USB162=at90usb162
5 | AT90USB64=at90usb646
6 | AT90USB128=at90usb1286
7 | ATmega32U2=atmega32u2
8 | ATm32U4=atmega32u4
9 | ATXMEGA128A4U=atxmega128a4u
10 |
11 |
--------------------------------------------------------------------------------
/common/cuxd/extra/blind.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # Version 1.0 * (C) '2017 by Uwe Langhammer
4 | # script for controling blinds
5 | #
6 | # usage: blind.tcl [-v] [-ms] [-stop] [] [|] []
7 | #
8 |
9 | load tclrega.so
10 |
11 | proc getopt {_argv name {_var ""}} {
12 | upvar 1 $_argv argv $_var var
13 | set pos [lsearch -regexp $argv ^$name]
14 | if {$pos>=0} {
15 | if {$_var != ""} {
16 | set var 1
17 | }
18 | set argv [lreplace $argv $pos $pos]
19 | incr ::argc -1
20 | return 1
21 | }
22 | return 0
23 | }
24 |
25 | set verbose [getopt argv -v]
26 | set ms [getopt argv -ms]
27 | set stop_cmd [getopt argv -stop]
28 |
29 | if { $argc < 1 } {
30 | puts "USAGE: blind.tcl \[-v\] \[-ms\] \[-stop\] \[\] \[|\] \[\]"
31 | exit 1
32 | }
33 |
34 | set address [lindex $argv 0]
35 | set state [lindex $argv 1]
36 | set set_ontime [lindex $argv 2]
37 | set set_ramptime [lindex $argv 3]
38 |
39 | if {[string is double $set_ontime]} { set set_ontime [expr $set_ontime + 0] }
40 |
41 | if {[regexp -- {\.[^\.]+\:\d+$} $address]} {
42 | append address ".LEVEL"
43 | }
44 |
45 | if { $argc < 2 } {
46 |
47 | append cmd "var ret = dom.GetObject(\"$address\").Value();"
48 | if { $verbose } { puts $cmd }
49 | array set values [rega_script $cmd]
50 |
51 | if { [info exists values(ret)] } {
52 | puts $values(ret)
53 | exit 0
54 | } else {
55 | puts "ERROR"
56 | exit 1
57 | }
58 |
59 | } else {
60 | regsub -- {\.[^\.]+$} $address "" addr
61 |
62 | if { $stop_cmd } {
63 | append cmd "if (dom.GetObject(\"$addr.WORKING\").Value()) \{"
64 | append cmd "dom.GetObject(\"$addr.STOP\").State(1);"
65 | append cmd "\} else \{"
66 | }
67 |
68 | if {[regexp -- {^CUxD\.} $address]} {
69 | if {[string is double $set_ontime] && ($set_ontime > 0)} {
70 | if { $ms } { set set_ontime [expr $set_ontime / 1000.0] }
71 | puts "ON_TIME ${set_ontime}s"
72 | append cmd "dom.GetObject(\"$addr.ON_TIME\").State(\"$set_ontime\");"
73 | }
74 |
75 | if {[string is double $set_ramptime] && ($set_ramptime > 0)} {
76 | if { $ms } { set set_ramptime [expr $set_ramptime / 1000.0] }
77 | puts "RAMP_TIME ${set_ramptime}s"
78 | append cmd "dom.GetObject(\"$addr.RAMP_TIME\").State(\"$set_ramptime\");"
79 | }
80 | } elseif {[regexp -- {\.LEVEL$} $address]} {
81 | if {[string is double $set_ontime] && (($set_ontime > 0) || ($set_ontime < 0))} {
82 | if {($state < 0.5)} { set set_ontime [expr {-$set_ontime}] }
83 | if {($set_ontime > 0)} { set set_ontime [concat "+" $set_ontime] }
84 | append cmd "dom.GetObject(\"$address\").State(dom.GetObject(\"$address\").Value()$set_ontime);"
85 | set level_set 1
86 | }
87 | }
88 |
89 | if {![info exists level_set]} {
90 | append cmd "dom.GetObject(\"$address\").State(\"$state\");"
91 | }
92 |
93 | if { $stop_cmd } {
94 | append cmd "\}"
95 | }
96 |
97 | if { $verbose } { puts $cmd }
98 |
99 | set cmd [concat "if (dom.GetObject(\"$addr.WORKING\")) {" $cmd]
100 | append cmd "var ret = 1;}"
101 |
102 | array set values [rega_script $cmd]
103 |
104 | if { [info exists values(ret)] && ($values(ret) == 1) } {
105 | puts "OK"
106 | exit 0
107 | } else {
108 | puts "ERROR"
109 | exit 1
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/common/cuxd/extra/ccu_backup:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014 by Uwe Langhammer
4 | # script for creating a CCU backup file in the filesystem
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: ccu_backup [] []
9 | #
10 | load tclrega.so
11 |
12 | set ret 0
13 | set HOSTNAME [exec hostname]
14 | set iso8601_date [exec date -Iseconds]
15 | regexp {^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)([+-]\d+.*)$} $iso8601_date dummy year month day hour minute second zone
16 | set BACKUPDIR /var/tmp
17 |
18 | set VERSION 0
19 | set VERSION_FILE /VERSION
20 | if {![file exists $VERSION_FILE]} {
21 | set VERSION_FILE /boot/VERSION
22 | }
23 | catch { set VERSION [exec grep VERSION= $VERSION_FILE | cut -d= -f2] }
24 |
25 | set BACKUPFILE [set HOSTNAME]-$VERSION-$year-$month-$day-$hour$minute.sbk
26 | if { $argc > 0 } {
27 | set BACKUPDIR [lindex $argv 0]
28 | }
29 | if { $argc > 1 } {
30 | set BACKUPFILE [lindex $argv 1]
31 | }
32 | puts "SBK-File: [set BACKUPDIR]/[set BACKUPFILE]"
33 | puts ""
34 | puts -nonewline "saving DOM..."
35 | flush stdout
36 | exec rm -f /etc/config/homematic.regadom.err
37 | exec rm -f /etc/config/homematic.regadom.bak
38 | rega system.Save()
39 | set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
40 | if {$result == ""} {
41 | puts " OK!"
42 | } else {
43 | puts " XML error!"
44 | set ret 1
45 | }
46 | cd /
47 | puts "creating archive..."
48 | exec tar czf /tmp/usr_local.tar.gz --exclude-tag=.nobackup usr/local
49 | cd /tmp/
50 | puts "sign configuration with current key..."
51 | exec crypttool -s -t 1 signature
52 | puts "store current key index..."
53 | exec crypttool -g -t 1 >key_index
54 | puts "copy firmware version..."
55 | file copy -force /boot/VERSION firmware_version
56 | puts "creating [set BACKUPDIR]/[set BACKUPFILE]"
57 | exec tar cf [set BACKUPDIR]/[set BACKUPFILE] usr_local.tar.gz signature firmware_version key_index
58 | puts "clean up temp files..."
59 | exec rm -f usr_local.tar.gz signature firmware_version key_index
60 | exec sync
61 | exit $ret
62 |
--------------------------------------------------------------------------------
/common/cuxd/extra/dim.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # Version 1.1 * (C) '2020 by Uwe Langhammer
4 | # script to dim up/down
5 | #
6 | # usage: dim.tcl [-v] [-ms] [-toggle] [[-]] []
7 | # STOP: dim.tcl 0
8 | #
9 |
10 | load tclrega.so
11 |
12 | set state_file "/var/cache/cuxd/state_"
13 |
14 | proc getopt {_argv name {_var ""}} {
15 | upvar 1 $_argv argv $_var var
16 | set pos [lsearch -regexp $argv ^$name]
17 | if {$pos>=0} {
18 | if {$_var != ""} {
19 | set var 1
20 | }
21 | set argv [lreplace $argv $pos $pos]
22 | incr ::argc -1
23 | return 1
24 | }
25 | return 0
26 | }
27 |
28 | set verbose [getopt argv -v]
29 | set ms [getopt argv -ms]
30 | set toggle [getopt argv -toggle]
31 |
32 | if { $argc < 1 } {
33 | puts "USAGE: dim.tcl \[-v\] \[-ms\] \[-toggle\] \[[-]\] \[= 2 } {
44 | if {[string is double $leveldiff] && ($leveldiff != 0)} {
45 | } else {
46 | puts "STOP"
47 | set run 0
48 | }
49 | } else {
50 | puts "STOP"
51 | set run 0
52 | }
53 |
54 | if { $run } {
55 | set cmd "var ret = dom.GetObject(\"$address\").Value();"
56 | if { $verbose } { puts $cmd }
57 | array set values [rega_script $cmd]
58 | # array set values [list ret 0.5]
59 |
60 | if { [info exists values(ret)] } {
61 | if {[string is double $values(ret)]} {
62 | # puts $values(ret)
63 |
64 | if { $toggle } {
65 | append state_file $address
66 | if [ file exists $state_file ] {
67 | set fp [ open $state_file "r" ]
68 | gets $fp updown
69 | close $fp
70 | if { ( $updown > 0 ) && ($values(ret) > 0.0) } {
71 | set updown -1
72 | } else {
73 | set updown 1
74 | }
75 | } else {
76 | if { $values(ret) > 0.0 } {
77 | set updown -1
78 | } else {
79 | set updown 1
80 | }
81 | }
82 | puts $updown
83 | if { $updown > 0 } {
84 | set leveldiff [ expr {abs($leveldiff)} ]
85 | } else {
86 | set leveldiff [ expr -1 * [ expr {abs($leveldiff)} ]]
87 | }
88 |
89 | set fp [ open $state_file "w" ]
90 | puts -nonewline $fp $updown
91 | close $fp
92 | }
93 |
94 | set new_level $values(ret)
95 | puts "STEP $leveldiff"
96 | if {[string is double $delaytime] && ($delaytime > 0)} {
97 | if { ! $ms } { set delaytime [expr $delaytime * 1000] }
98 | puts "DELAY ${delaytime}ms"
99 | }
100 |
101 | set pidfile [open $pidfilename w]
102 | puts $pidfile [pid]
103 | close $pidfile
104 |
105 | set pidfilemtime [file mtime $pidfilename]
106 |
107 | while { $run } {
108 | set new_level [ expr { $new_level + $leveldiff } ]
109 | if { ($new_level >= 0.999) } {
110 | set new_level 1
111 | }
112 | if { ($new_level <= 0.001) } {
113 | set new_level 0
114 | }
115 | # puts $new_level
116 | set cmd "dom.GetObject(\"$address\").State($new_level);"
117 | if { $verbose } { puts $cmd }
118 | array set values [rega_script $cmd]
119 | if { ($new_level == 0) || ($new_level == 1) } {
120 | set run 0
121 | } else {
122 | if {[string is double $delaytime] && ($delaytime > 0)} {
123 | after [expr int($delaytime)]
124 | if { [file exists $pidfilename] } {
125 | if { $pidfilemtime != [file mtime $pidfilename] } {
126 | puts "ERROR: dim level changed"
127 | exit 1
128 | }
129 | } else {
130 | puts "STOP"
131 | exit 0
132 | }
133 | } else {
134 | set run 0
135 | }
136 | }
137 | }
138 | }
139 | } else {
140 | puts "ERROR"
141 | exit 1
142 | }
143 | }
144 | if { !$run } {
145 | file delete $pidfilename
146 | }
147 | exit 0
--------------------------------------------------------------------------------
/common/cuxd/extra/dom_backup:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014 by Uwe Langhammer
4 | #
5 | # backup DOM
6 | #
7 | # usage: dom_backup [] []
8 | #
9 | load tclrega.so
10 |
11 | set files {homematic.regadom rfd rfd.conf hs485d hs485d.conf addons/www/cuxd/cuxd.ini addons/www/cuxd/cuxd.ps}
12 |
13 | set ret 1
14 | cd /etc/config
15 | set regadom "homematic.regadom"
16 | if [file isfile $regadom] {
17 | puts -nonewline "check $regadom..."
18 | flush stdout
19 | } else {
20 | puts -nonewline "saving DOM..."
21 | flush stdout
22 | exec rm -f /etc/config/homematic.regadom.err
23 | exec rm -f /etc/config/homematic.regadom.bak
24 | rega system.Save()
25 | }
26 | set size [file size $regadom]
27 | if { $size > 100 } {
28 | set seek [expr "$size - 7"]
29 | set chan [open $regadom r]
30 | seek $chan $seek
31 | set dom [gets $chan]
32 | close $chan
33 | if { $dom == "" } {
34 | puts " OK!"
35 | set ret 0
36 | } else {
37 | puts " XML error!"
38 | }
39 | }
40 |
41 | if { $argc > 0 } {
42 | set BACKUPDIR [lindex $argv 0]
43 | if { $argc > 1 } {
44 | set BACKUPFILE [lindex $argv 1]
45 | } else {
46 | set HOSTNAME [exec hostname]
47 | set iso8601_date [exec date -Iseconds]
48 | regexp {^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)([+-]\d+)$} $iso8601_date dummy year month day hour minute second zone
49 | set BACKUPFILE config.$HOSTNAME-$year-$month-$day-$hour$minute.tar.gz
50 | }
51 |
52 | foreach filename $files {
53 | if [file exists $filename] {
54 | append files_ok " $filename"
55 | }
56 | }
57 | set filename homematic.regadom.bak
58 | if { [file isfile homematic.regadom] && [file isfile $filename] } {
59 | if { [file size homematic.regadom] == [file size $filename] } {
60 | if [catch { exec diff homematic.regadom $filename >/dev/null }] {
61 | append files_ok " $filename"
62 | }
63 | } else {
64 | append files_ok " $filename"
65 | }
66 | }
67 |
68 | puts "backup-files:$files_ok"
69 | puts -nonewline "create $BACKUPDIR/$BACKUPFILE"
70 | flush stdout
71 | set cmd "exec /bin/tar czf $BACKUPDIR/$BACKUPFILE$files_ok"
72 | if [catch { eval $cmd } msg] {
73 | puts " ERROR!"
74 | # puts $errorCode
75 | # puts $errorInfo
76 | puts $msg
77 | set ret 1
78 | } else {
79 | puts " OK!"
80 | }
81 | }
82 | exec sync
83 | exit $ret
84 |
--------------------------------------------------------------------------------
/common/cuxd/extra/dom_save:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014 by Uwe Langhammer
4 | #
5 | # saving DOM
6 | #
7 | # usage: dom_save
8 | #
9 | load tclrega.so
10 |
11 | set ret 1
12 | puts -nonewline "saving DOM..."
13 | flush stdout
14 | exec rm -f /etc/config/homematic.regadom.err
15 | exec rm -f /etc/config/homematic.regadom.bak
16 | rega system.Save()
17 | set regadom "/etc/config/homematic.regadom"
18 | set size [file size $regadom]
19 | if { $size > 100 } {
20 | set seek [expr "$size - 7"]
21 | set chan [open $regadom r]
22 | seek $chan $seek
23 | set dom [gets $chan]
24 | close $chan
25 | if { $dom == "" } {
26 | puts " OK!"
27 | set ret 0
28 | } else {
29 | puts " XML error!"
30 | }
31 | }
32 | exec sync
33 | exit $ret
34 |
--------------------------------------------------------------------------------
/common/cuxd/extra/dutycycle:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # DutyCycle Monitor start/stop script
4 | # (C) '2018 by Uwe Langhammer
5 | #
6 | PROCPATH=/usr/local/addons/cuxd/extra
7 | PROC=dutycycle.tcl
8 |
9 | FILENAME=/var/cache/cuxd_dutycycle.txt
10 |
11 | SLEEP=120
12 | if [ "$2" != "" ]
13 | then
14 | SLEEP=$2
15 | fi
16 |
17 | PSPID=`ps -o pid,comm | grep -Ev "\b$$\b" | awk '{if($2=="'$PROC'"){print $1}}'`
18 |
19 | case "$1" in
20 | start|restart|stop)
21 | if [ "$PSPID" != "" ]
22 | then
23 | kill -TERM $PSPID 2>/dev/null
24 | sleep 1
25 | logger $PROC[$PSPID] stopped
26 | fi
27 |
28 | if [ "$1" != "stop" ]
29 | then
30 | PORTS=`grep -A 1 "\-RF" /etc/config/InterfacesList.xml | sed -n 's%.*.*:\([0-9]\+\).*%\1%p'`
31 | PORTS=`echo $PORTS | tr ' ' ','`
32 | #PORTS=2001,2010
33 | if [ -x "$PROCPATH/$PROC" ]
34 | then
35 | $PROCPATH/$PROC $PORTS $FILENAME $SLEEP &
36 | logger $PROC[$!] $PORTS $FILENAME $SLEEP started
37 | else
38 | logger $PROCPATH/$PROC not found!
39 | fi
40 | fi
41 | ;;
42 |
43 | *)
44 | echo "Usage: $0 {start|stop} [SLEEP]" >&2
45 | exit 1
46 | ;;
47 | esac
48 |
49 | exit 0
50 |
--------------------------------------------------------------------------------
/common/cuxd/extra/dutycycle.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2018 by Uwe Langhammer
4 | # script for reading RFD duty cycles
5 | #
6 | # all parameters are optional!
7 | #
8 | # usage: dutycycle.tcl [,...] [] []
9 | #
10 | load tclrpc.so
11 |
12 | set ports [lindex $argv 0]
13 | set filename [lindex $argv 1]
14 | set sleep [lindex $argv 2]
15 |
16 | if { $argc < 1 } {
17 | puts "USAGE: dutycycle.tcl \[,...\] \[i\] \[\]"
18 | exit 1
19 | }
20 |
21 | set sleep1000s 0
22 | if {[string is double $sleep] && ($sleep > 0)} {
23 | set sleep1000s [expr int([expr $sleep * 1000])]
24 | }
25 |
26 | set portlist [split $ports ","]
27 |
28 | while { 1 } {
29 | set lines ""
30 | foreach port $portlist {
31 | set r ""
32 | if {[catch {set r [xmlrpc http://127.0.0.1:$port/ listBidcosInterfaces]} fid]} {
33 | puts stderr $fid
34 | }
35 | if {[string length $r] > 20 } {
36 | foreach gateway $r {
37 | array set gw $gateway
38 | set records {ADDRESS TYPE DUTY_CYCLE}
39 | foreach rec $records {
40 | if {[info exists gw($rec)]} {
41 | append lines "$gw($rec)\t"
42 | } else {
43 | append lines "\t"
44 | }
45 | }
46 | append lines "\n"
47 | }
48 | }
49 | }
50 | if {[string length $filename] > 1 } {
51 | set fo [open $filename "w"]
52 | puts -nonewline $fo $lines
53 | close $fo
54 | } else {
55 | puts $lines
56 | }
57 | if { $sleep1000s > 0 } {
58 | after $sleep1000s
59 | } else {
60 | break
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/common/cuxd/extra/export_ftp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # (C) '2013 by Uwe Langhammer
4 | # export spool directory to external ftp host
5 | #
6 | # usage: export_ftp.sh user:pass 192.168.12.3 import/ccu /tmp/export
7 | #
8 | export LD_LIBRARY_PATH=/usr/local/addons/cuxd
9 | CURL=/usr/local/addons/cuxd/curl
10 | FTP_USERPASS=$1
11 | FTP_HOST=$2
12 | FTP_DIR=$3
13 | EXPORT_DIR=$4
14 | cd $EXPORT_DIR
15 | for file in *
16 | do
17 | if [ -f $file ]
18 | then
19 | $CURL -s -u ${FTP_USERPASS} -T $file ftp://${FTP_HOST}/${FTP_DIR}/${file}.part
20 | if [ $? -eq 0 ]
21 | then
22 | $CURL -s -u ${FTP_USERPASS} ftp://$FTP_HOST -Q "RNFR ${FTP_DIR}/${file}.part" -Q "RNTO ${FTP_DIR}/${file}" >/dev/null
23 | if [ $? -eq 0 ]
24 | then
25 | rm -f $file
26 | fi
27 | fi
28 | fi
29 | done
30 |
31 |
--------------------------------------------------------------------------------
/common/cuxd/extra/hmserver:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # (C) '2014-2016 by Uwe Langhammer
4 | # script for enabling/disabling the Java HMServer process
5 | #
6 | # usage: hmserver 0|1
7 | #
8 | load tclrega.so
9 |
10 | set mode [lindex $argv 0]
11 | if {$mode != 0 && $mode != 1} {
12 | puts "usage: hmserver.tcl 0|1"
13 | exit 1
14 | }
15 |
16 | foreach startscript [glob -nocomplain /etc/init.d/*HMServer] {
17 | break
18 | }
19 |
20 | if {![info exists startscript] } {
21 | puts "HMServer startscript not found!"
22 | exit 1
23 | }
24 |
25 | set fp [open $startscript r]
26 | set file_data [read $fp]
27 | set data [split $file_data "\n"]
28 | set line1 [lindex $data 0]
29 | close $fp
30 | set flag 0
31 | if { $mode == 0 } {
32 | puts ""
33 | puts "###############################################################################"
34 | puts "## ##"
35 | puts "## Nach der Deaktivierung sind unter anderem die folgenden CCU2-Funktionen ##"
36 | puts "## nicht mehr moeglich: ##"
37 | puts "## ##"
38 | puts "## - Diagramme ##"
39 | puts "## - Gruppenfunktion (bei Heizungsthermostaten) ##"
40 | puts "## - Erstinitialisierung der SD-Karte ##"
41 | puts "## - Geraetefirmwareupdate ueber WebUI ##"
42 | puts "## - HomeMatic-IP Interface ##"
43 | puts "## ##"
44 | puts "###############################################################################"
45 | puts ""
46 | }
47 | if {[string range $line1 0 3] == "exit"} {
48 | puts "HMServer in $startscript disabled"
49 | if { $mode == 1 } {
50 | puts "enable HMServer in $startscript"
51 | set flag 1
52 | }
53 | } else {
54 | puts "HMServer in $startscript enabled"
55 | if { $mode == 0 } {
56 | puts "stop HMServer"
57 | exec $startscript stop
58 | puts "disable HMServer in $startscript"
59 | set flag 1
60 | }
61 | }
62 | if {$flag == 1} {
63 | exec mount -o remount,rw /
64 | puts "write $startscript"
65 | set fp [open $startscript w 0755]
66 | if {$mode == 1} {
67 | puts -nonewline $fp [join [lreplace $data 0 0] \n]
68 | } else {
69 | puts $fp "exit"
70 | puts -nonewline $fp $file_data
71 | }
72 | close $fp
73 | exec mount -o remount,ro /
74 | puts -nonewline "saving DOM..."
75 | flush stdout
76 | rega system.Save()
77 | set result [exec /usr/bin/tail -1 /etc/config/homematic.regadom]
78 | if {$result == ""} {
79 | puts " OK!"
80 | } else {
81 | puts " XML error!"
82 | exit 1
83 | }
84 | if {$mode == 1} {
85 | file delete /etc/config/InterfacesList.xml
86 | }
87 | puts "reboot..."
88 | exec /sbin/reboot
89 | }
90 | exit 0
91 |
--------------------------------------------------------------------------------
/common/cuxd/extra/pty2tcp:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # (C) '2015,2021 by Uwe Langhammer
4 | # creates and deletes a pseudo TTY mapped to a TCP port for CUxD
5 | #
6 | # usage:
7 | # pty2tcp start ttyTCP [-ssl] : []
8 | # pty2tcp stop ttyTCP
9 | #
10 |
11 | SOCATP=/usr/local/addons/cuxd/extra/socat
12 |
13 | kill_pid() {
14 | echo "kill ($1)"
15 | logger -p daemon.info -t cuxd.pty2tcp "kill -HUP ($1)"
16 | kill -HUP $1
17 | sleep 1
18 | kill -0 $1 2>/dev/null
19 | if [ $? -eq 0 ]
20 | then
21 | logger -p daemon.info -t cuxd.pty2tcp "kill -TERM ($1)"
22 | kill -TERM $1
23 | sleep 1
24 | kill -0 $1 2>/dev/null
25 | if [ $? -eq 0 ]
26 | then
27 | logger -p daemon.info -t cuxd.pty2tcp "kill -KILL ($1)"
28 | kill -KILL $1
29 | sleep 1
30 | fi
31 | fi
32 | }
33 |
34 | check_device() {
35 | #logger -p daemon.info -t cuxd.pty2tcp "check_device start $1 $2 $3"
36 | while [ -f $2 ]
37 | do
38 | pid=`cat $2 2>/dev/null`
39 | if [ "$1" = "$pid" ]
40 | then
41 | if [ ! -e $3 ]
42 | then
43 | sleep 10
44 | if [ ! -e $3 ]
45 | then
46 | logger -p daemon.err -t cuxd.pty2tcp "$3 not found"
47 | kill_pid $1
48 | fi
49 | else
50 | sleep 2
51 | fi
52 | else
53 | break
54 | fi
55 | done
56 | #logger -p daemon.info -t cuxd.pty2tcp "check_device done $1 $2 $3"
57 | }
58 |
59 | SSL=0
60 | for arg do
61 | shift
62 | if [ `echo "$arg" | grep "-"` ]
63 | then
64 | if [ "$arg" = "-ssl" ]
65 | then
66 | SSL=1
67 | fi
68 | continue
69 | fi
70 | set -- "$@" "$arg"
71 | done
72 |
73 | #logger -p daemon.info -t cuxd.pty2tcp $*
74 |
75 | if [ \( -n "$1" \) -a \( -n "$2" \) ]
76 | then
77 | pid=0
78 | pidfile="/var/run/pty.$2.pid"
79 | if [ -f $pidfile ]
80 | then
81 | pid=`cat $pidfile`
82 | # echo "$pidfile ($pid)"
83 | if [ $pid -gt 1 ]
84 | then
85 | kill -0 $pid 2>/dev/null
86 | if [ $? -eq 1 ]
87 | then
88 | rm -f $pidfile
89 | pid=0
90 | fi
91 | else
92 | rm -f $pidfile
93 | pid=0
94 | fi
95 | fi
96 | case "$1" in
97 | start|restart)
98 | if [ -n "$3" ]
99 | then
100 | if [ $pid -ne 0 ]
101 | then
102 | rm -f $pidfile
103 | kill_pid $pid
104 | fi
105 | echo -n "starting"
106 | echo $$ >$pidfile
107 | ( while [ -f $pidfile ]
108 | do
109 | if [ $SSL -ne 0 ]
110 | then
111 | $SOCATP pty,link=/dev/$2,wait-slave openssl-connect:$3,forever,$4 &
112 | else
113 | $SOCATP pty,link=/dev/$2,wait-slave tcp:$3,forever,$4 &
114 | fi
115 | pid=$!
116 | echo $pid >$pidfile
117 | logger -p daemon.info -t cuxd.pty2tcp "start ($pid) $pidfile"
118 | check_device $pid $pidfile /dev/$2 &
119 | pid2=$!
120 | wait %1
121 | #logger -p daemon.info -t cuxd.pty2tcp "kill check_device($pid2)"
122 | kill -KILL $pid2
123 | done
124 | )&
125 | echo " ok"
126 | fi
127 | ;;
128 | stop)
129 | if [ $pid -ne 0 ]
130 | then
131 | rm -f $pidfile
132 | kill_pid $pid
133 | fi
134 | ;;
135 | esac
136 | else
137 | echo "usage: $0 (start|stop) ttyTCP [-ssl] :"
138 | fi
139 |
140 |
--------------------------------------------------------------------------------
/common/cuxd/extra/timer.tcl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/extra/timer.tcl
--------------------------------------------------------------------------------
/common/cuxd/extra/toggle.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # Version 1.1 * (C) '2020 by Uwe Langhammer
4 | # script to toggle switches/dimmer
5 | #
6 | # usage: toggle.tcl [-v] [-ms] [] [] [] []
7 | #
8 |
9 | load tclrega.so
10 |
11 | set state_file "/var/cache/cuxd/state_"
12 |
13 | proc getopt {_argv name {_var ""}} {
14 | upvar 1 $_argv argv $_var var
15 | set pos [lsearch -regexp $argv ^$name]
16 | if {$pos>=0} {
17 | if {$_var != ""} {
18 | set var 1
19 | }
20 | set argv [lreplace $argv $pos $pos]
21 | incr ::argc -1
22 | return 1
23 | }
24 | return 0
25 | }
26 |
27 | set verbose [getopt argv -v]
28 | set ms [getopt argv -ms]
29 |
30 | if { $argc < 1 } {
31 | puts "USAGE: toggle.tcl \[-v\] \[-ms\] \[\] \[\] \[\] \[\]"
32 | exit 1
33 | }
34 |
35 | set address [lindex $argv 0]
36 | set state [lindex $argv 1]
37 | set set_ramptime0 [lindex $argv 2]
38 | set set_ramptime1 [lindex $argv 3]
39 | set set_ontime [lindex $argv 4]
40 |
41 | if { $argc >= 2 } {
42 | if {[string is double $state] && ($state > 0)} {
43 | } else {
44 | set state 0
45 | }
46 | } else {
47 | set state 0
48 | }
49 |
50 | if { 1 } {
51 | set level 0
52 | if {[regexp -- {\.[^\.]+\:\d+\.LEVEL$} $address]} {
53 | set level 1
54 | }
55 | regsub -- {\.[^\.]+$} $address "" addr
56 |
57 | append cmd "var ret;"
58 |
59 | append state_file $address
60 | if { [ file exists $state_file ] && ([ expr [ clock seconds ] - [ file mtime $state_file ] ] < 4) } {
61 | set fp [ open $state_file "r" ]
62 | gets $fp data
63 | close $fp
64 | if { $data } {
65 | append cmd "if (true) \{"
66 | } else {
67 | append cmd "if (false) \{"
68 | }
69 | } else {
70 | append cmd "if (dom.GetObject(\"$address\").Value()) \{"
71 | }
72 |
73 | if {[string is double $set_ramptime0] && ($set_ramptime0 > 0)} {
74 | if { $ms } { set set_ramptime0 [expr $set_ramptime0 / 1000.0] }
75 | puts "ON_TIME ${set_ramptime0}s"
76 | append cmd "dom.GetObject(\"$addr.RAMP_TIME\").State(\"$set_ramptime0\");"
77 | }
78 |
79 | append cmd "dom.GetObject(\"$address\").State(0);"
80 | append cmd "ret = 0;"
81 | append cmd "\} else \{"
82 |
83 | if {[string is double $set_ramptime1] && ($set_ramptime1 > 0)} {
84 | if { $ms } { set set_ramptime1 [expr $set_ramptime1 / 1000.0] }
85 | puts "ON_TIME ${set_ramptime1}s"
86 | append cmd "dom.GetObject(\"$addr.RAMP_TIME\").State(\"$set_ramptime1\");"
87 | }
88 |
89 | if {[string is double $set_ontime] && ($set_ontime > 0)} {
90 | if { $ms } { set set_ontime [expr $set_ontime / 1000.0] }
91 | puts "ON_TIME ${set_ontime}s"
92 | append cmd "dom.GetObject(\"$addr.ON_TIME\").State(\"$set_ontime\");"
93 | }
94 |
95 | if { $level } {
96 | if { $state } {
97 | append cmd "dom.GetObject(\"$address\").State($state);"
98 | } else {
99 | append cmd "dom.GetObject(\"$addr.OLD_LEVEL\").State(1);"
100 | }
101 | } else {
102 | append cmd "dom.GetObject(\"$address\").State(1);"
103 | }
104 | append cmd "ret = 1;"
105 | append cmd "\}"
106 |
107 | if { $verbose } { puts $cmd }
108 |
109 | array set values [rega_script $cmd]
110 |
111 | if { [info exists values(ret)] && ( $values(ret) != "null" ) } {
112 | puts "OK"
113 | # puts $values(ret)
114 | set fp [ open $state_file "w" ]
115 | puts -nonewline $fp $values(ret)
116 | close $fp
117 | exit 0
118 | } else {
119 | puts "ERROR"
120 | exit 1
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/common/cuxd/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CUxD
5 |
6 |
11 |
12 |
13 | CUxD-AddOn
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/common/cuxd/maintenance.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/maintenance.html
--------------------------------------------------------------------------------
/common/cuxd/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /
3 |
--------------------------------------------------------------------------------
/common/cuxd/user/.userdir:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/common/cuxd/user/.userdir
--------------------------------------------------------------------------------
/docs/cuxd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd.png
--------------------------------------------------------------------------------
/docs/cuxd_2.10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_2.10.pdf
--------------------------------------------------------------------------------
/docs/cuxd_alpha2_1.12.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_alpha2_1.12.pdf
--------------------------------------------------------------------------------
/docs/cuxd_dali_2.9.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_dali_2.9.pdf
--------------------------------------------------------------------------------
/docs/cuxd_enocean_2.10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_enocean_2.10.pdf
--------------------------------------------------------------------------------
/docs/cuxd_klf200_2.10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_klf200_2.10.pdf
--------------------------------------------------------------------------------
/docs/cuxd_wmbus_2.5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/docs/cuxd_wmbus_2.5.pdf
--------------------------------------------------------------------------------
/generate_img.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # function that generate a CCU specific
4 | # install package
5 | generate_pkg()
6 | {
7 | # generate temporary directory
8 | mkdir -p tmp
9 | rm -rf tmp/*
10 |
11 | # generate ccu1 package
12 | cp -a common/* tmp/
13 | cp -a ${1}/* tmp/
14 | mv tmp/cuxd/cuxd_addon.cfg tmp/
15 | ln -s cuxd/update_addon tmp/
16 | cd tmp
17 | tar --owner=root --group=root --exclude=.DS_Store -czvf ../cuxd_$(cat ../VERSION)_${1}.tar.gz *
18 | cd ..
19 | rm -rf tmp
20 | }
21 |
22 | # generate packages now. If specified on
23 | # command-line generate this specific package
24 | # only. If not specified at all, generate all
25 | # packages.
26 | if [ -n "$1" ]; then
27 | generate_pkg $1
28 | else
29 | generate_pkg ccu1
30 | generate_pkg ccu2
31 | generate_pkg ccu3
32 | generate_pkg ccux86
33 | fi
34 |
--------------------------------------------------------------------------------
/src/dfu-programmer/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | Makefile.in
3 | aclocal.m4
4 | autom4te.cache
5 | configure
6 | config.status
7 | config.log
8 | fedora/dfu-programmer.spec
9 | m4/compile
10 | src/.deps/*
11 | src/config.h
12 | src/config.h.in
13 | src/dfu-programmer
14 | src/stamp-h1
15 | src/*.o
16 | src/*.exe
17 | src/*.hex
18 | *.tar.gz
19 |
20 | # tab completion file
21 | dfu_programmer
22 |
--------------------------------------------------------------------------------
/src/dfu-programmer/AUTHORS:
--------------------------------------------------------------------------------
1 | Original Author:
2 | - Weston Schmidt
3 |
4 | Contributors:
5 | - Reinhard Arlt
6 | - at89c5131 chip support
7 | - Anton Blad
8 | - at90usb162 and at90usb82 chip support
9 | - David Brownell
10 | - compiler flag improvements
11 | - command line argument processing improvements
12 | - debugging system improvements
13 | - significant man page improvements
14 | - support for the at90usb series AVR chips
15 | - the beginnings of the move over to using stdint.h
16 | - Nick Hibma
17 | - bug fixes
18 | - Markus Schneider
19 | - OS X porting issues
20 | - Geoffrey Wossum
21 | - added reset command
22 | - Sean D'Epagnier
23 | - eeprom bug fix
24 | - 4K bootloader support fix
25 | - Peter Gammie
26 | - at90usb647 PID fix
27 | - Zachary Clifford
28 | - completed AVR32 support
29 | - identified a number of off-by-one errors waiting to happen
30 | - identified that AVR32 "User Pages" aren't supported yet
31 | - patch to allow proper handling of the trampoline code
32 | - patch to allow flashing user flash space & STDIN
33 | - patch to enable support for windows using mingw32
34 | - patch to enable setting/getting fuses for the AVR32 devices
35 | - Donald Davis
36 | - patch with new AVR devices & testing of support for the devices
37 | - Brad Schick
38 | - identified that the flash memory overlaps the bootloader memory
39 | - identified the off-by-one issue when the bootloader is in upper memory
40 | - Xavier Leprevost
41 | - patch to fix an error in the avr32 user flash dump command
42 | - Dave Fletcher
43 | - patch to enable atmega32u2 chips
44 | - Torsten Rottmann
45 | - patch to enable libusb 1.0 support
46 | - Mitko
47 | - patch to enable at32uc3b1512 and at32uc3b0512 chips
48 | - Darren Gibbs
49 | - identified dead/bad code around the bootloader overlap checking
50 | - Holger Steinhaus
51 | - patch to enable atmega8u2
52 | - Martin Guy
53 | - patch to enable automotive AVR32 flashing without a timeout
54 | - Walker Inman
55 | - bugfix flash user page for avr32
56 | - add stm32 devices
57 | - add progress bar
58 | - update algorithm for converting hex and sending program
59 | - simplify command structure
60 | - add ability to dump to hex file (and hex2bin / bin2hex)
61 | - svn -> git migration
62 | - update --help -h text
63 | - also a lot of formatting updates (sorry)
64 | - More info in README
65 | - Add autocomplete for Ubuntu
66 | - Simon Large
67 | - fix atmel_reset function
68 | - get rid of compiler warnings around fprintf statements
69 | - fix build system for selecting libusb-1.0
70 | - atmega16u2 support
71 | - better support for Windows users
72 | - improve layout of help text
73 | - add security fuse support for AVR32
74 | - fix memory bounds for xmega devices
75 | - Johannes Carlsson
76 | - patch to fix use of libusb in configure.ac
77 | - Grégory S.
78 | - identified too-late check for null pointer
79 | - Dmitry Nedospasov
80 | - support for xmega devices
81 | - Kees Bakker
82 | - support for atxmega256a3bu
83 | - David Nelson
84 | - support for at32uc3a4256s
85 | - support for using a specific usb bus/address
86 | - support for device serialisation
87 | - correction to --quiet output
88 | - Olivier Pisano
89 | - support for atxmega16c4
90 | - Neels Hofmeyr
91 | - improvements to progress bar
92 | - John Szakmeister
93 | - Fix exit status of help-related options and improve start sequence
94 | - Alban Bedel
95 | - Fix infinite loop using rpl_malloc
96 |
--------------------------------------------------------------------------------
/src/dfu-programmer/ChangeLog:
--------------------------------------------------------------------------------
1 | This file is no longer maintained. You can find a summary of changes in
2 | the NEWS file. For a detailed view of the changes go to the online
3 | source repository at GitHub and browse the commit history.
4 |
--------------------------------------------------------------------------------
/src/dfu-programmer/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS = src docs
2 |
3 | EXTRA_DIST = bootstrap.sh fedora/10-dfu-programmer.fdi \
4 | fedora/dfu-programmer.spec
5 |
--------------------------------------------------------------------------------
/src/dfu-programmer/SF_ReadMe.txt:
--------------------------------------------------------------------------------
1 | dfu-programmer-x.x.x.tar.gz contains the source tree for this project.
2 | Download this to build and install on a Linux/Unix/Mac system.
3 |
4 | dfu-programmer-win-x.x.x.zip contains the pre-compiled Windows executable
5 | and the USB drivers for use with Atmel chips in DFU bootloader mode.
6 |
7 | The Windows executable does not need any installation or setup. Just
8 | extract the executable and run it.
9 |
10 | The Windows driver can be installed when prompted by Windows when a DFU
11 | device is attached. Do not let Windows search for a driver; specify
12 | the path to search for a driver and point it to the .inf file.
13 |
--------------------------------------------------------------------------------
/src/dfu-programmer/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | aclocal -I m4
3 | autoheader
4 | automake --foreign --add-missing --copy
5 | autoconf
6 |
7 | TARGET_START_LINE=$( grep START_TARGET_LIST_LINE -n src/arguments.c | \
8 | sed "s/^\(.*\):.*/\1/")
9 | TARGET_END_LINE=$( grep END_TARGET_LIST_LINE -n src/arguments.c | \
10 | sed "s/^\(.*\):.*/\1/")
11 | TARGET_INFO=$( sed -n "$TARGET_START_LINE,$TARGET_END_LINE p" src/arguments.c | \
12 | grep "^\s*{ \"" | sed 's/.*"\(.*\)".*,\s*\([xX0-9A-Fa-f]*\)\s*},/\1::\2/' )
13 |
14 | DFU_COMP=dfu_programmer
15 |
16 | echo \#\ autocomplete\ script > $DFU_COMP
17 | echo "# code sourced from dfu_completion, DO NOT EDIT IN THIS FILE" \
18 | >> $DFU_COMP
19 | echo >> $DFU_COMP
20 | echo -n "TARGET_INFO=\" " >> $DFU_COMP
21 | echo -n $TARGET_INFO >> $DFU_COMP
22 | echo " \"" >> $DFU_COMP
23 | echo >> $DFU_COMP
24 | echo >> $DFU_COMP
25 |
26 | cat dfu_completion >> $DFU_COMP
27 |
28 | chmod +x $DFU_COMP
29 |
30 | if [ "$(echo `uname`)" = "Linux" ]; then
31 | #if [ "$(cat /etc/*release | grep DISTRIB_ID | sed 's/DISTRIB_ID=//')" = "Ubuntu" ]]; then
32 | # FIXME : shouldn't add sudo inside script,
33 | echo "To install tab completion run"
34 | echo " \$ sudo mv $DFU_COMP /etc/bash_completion.d/"
35 | echo "To use tab completion in this terminal run"
36 | echo " \$ source $DFU_COMP"
37 | #fi
38 | fi
39 |
--------------------------------------------------------------------------------
/src/dfu-programmer/configure.ac:
--------------------------------------------------------------------------------
1 | # -*- Autoconf -*-
2 | # Process this file with autoconf to produce a configure script.
3 |
4 | AC_PREREQ(2.59)
5 | AC_INIT([dfu-programmer],[0.7.2],[],[],[https://github.com/dfu-programmer/dfu-programmer])
6 | AC_CONFIG_AUX_DIR(m4)
7 | AC_CONFIG_SRCDIR([src/atmel.c])
8 | AM_INIT_AUTOMAKE
9 | AM_CONFIG_HEADER([src/config.h])
10 |
11 | AM_MAINTAINER_MODE
12 |
13 | # Checks for programs.
14 | AC_PROG_CC
15 |
16 | # Checks for libusb - from sane-backends configuration
17 |
18 | dnl Enable libusb-1.0, if available
19 | disable_libusb_1_0=no
20 | AC_ARG_ENABLE(libusb_1_0,
21 | AC_HELP_STRING([--disable-libusb_1_0], [disable libusb-1.0 support even if available]),
22 | [ if test "x$enableval" = "xno"; then disable_libusb_1_0=yes; fi ], [])
23 |
24 | dnl If libusb-1.0 is enabled and available, prefer that to the old libusb
25 | have_libusb_1_0=no
26 | if test "$disable_libusb_1_0" = "no"; then
27 | ifdef([PKG_CHECK_MODULES],
28 | [PKG_CHECK_MODULES(LIBUSB_1_0, [ libusb-1.0 >= 1.0.0 ], have_libusb_1_0=yes, have_libusb_1_0=no)],
29 | [have_libusb_1_0=yes
30 | LIBUSB_1_0_CFLAGS='-I${includedir}/libusb-1.0 -I${oldincludedir}/libusb-1.0'
31 | LIBUSB_1_0_LIBS=-lusb-1.0])
32 | if test "$have_libusb_1_0" = "yes"; then
33 | AS_ECHO("using libusb_1.0");
34 | CFLAGS="$CFLAGS $LIBUSB_1_0_CFLAGS"
35 | LIBS="$LIBS $LIBUSB_1_0_LIBS"
36 | HAVE_USB=yes
37 | fi
38 | fi
39 |
40 | if test "$have_libusb_1_0" = "no"; then
41 | dnl Fallback to the old libusb
42 | dnl libusb >= 0.1.8 is required, as we need usb_interrupt_read()
43 | AS_ECHO("using libusb");
44 | AC_CHECK_HEADER(usb.h,
45 | AC_CHECK_LIB(usb, usb_interrupt_read,
46 | [LIBS="$LIBS -lusb"
47 | HAVE_USB=yes]))
48 | fi
49 |
50 | dnl The following logic is useful for distributions. If they force
51 | dnl USB support with --enable-libusb=yes then configure will fail
52 | dnl when its detected that it can not be supported. Default is
53 | dnl "auto" which means only enable if libraries are found and do
54 | dnl not error out.
55 | if test "$HAVE_USB" = "no"; then
56 | AC_MSG_ERROR([USB support requested but required libraries not found.])
57 | fi
58 | if test "$HAVE_USB" = "yes"; then
59 | if test "$have_libusb_1_0" = "yes"; then
60 | AC_DEFINE(HAVE_LIBUSB_1_0, 1, [Define to 1 if you have libusb-1.0.])
61 | else
62 | AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have libusb.])
63 | fi
64 | fi
65 |
66 |
67 | # Checks for header files.
68 | AC_HEADER_STDC
69 |
70 | # Checks for typedefs, structures, and compiler characteristics.
71 | AC_C_CONST
72 | AC_TYPE_SIZE_T
73 |
74 | # Checks for library functions.
75 | AC_FUNC_MALLOC
76 | AC_FUNC_MEMCMP
77 | #AC_CHECK_FUNC([memset], :, [AC_CHECK_LIB([libc], [libc])])
78 |
79 | AC_CONFIG_FILES(fedora/dfu-programmer.spec Makefile docs/Makefile src/Makefile)
80 | AC_OUTPUT
81 |
--------------------------------------------------------------------------------
/src/dfu-programmer/dfu_completion:
--------------------------------------------------------------------------------
1 | # dfu_completion file, partial of dfu_programmer script
2 |
3 | TARGETS=$( echo $TARGET_INFO | sed 's/::[xX0-9A-Fa-f]*//g' )
4 |
5 | COMMANDS=(launch read erase flash setsecure config get getfuse setfuse hex2bin bin2hex)
6 |
7 | _dfu-programmer () {
8 | local i filetype
9 | local cur cmd prev target
10 | local flags
11 | local eeprom_size
12 |
13 | export cur=${COMP_WORDS[COMP_CWORD]}
14 | export target=${COMP_WORDS[1]}
15 | export cmd=${COMP_WORDS[2]}
16 | export prev=${COMP_WORDS[COMP_CWORD - 1]}
17 |
18 | COMPREPLY=() # Array variable storing the possible completions.
19 |
20 | if [[ "$COMP_CWORD" == "1" ]]; then
21 | COMPREPLY=( $( compgen -W "$TARGETS" -- $cur ) )
22 | fi
23 |
24 | if [[ "$COMP_CWORD" == "2" ]]; then
25 | COMPREPLY=( $( compgen -W "${COMMANDS[*]}" -- $cur ) )
26 | fi
27 |
28 | if [[ "$COMP_CWORD" > "2" ]]; then
29 |
30 | case "$cmd" in
31 | hex2bin)
32 | filetype="hex"
33 |
34 | if [[ $filetype != none ]]; then
35 | #COMPREPLY+=( $( compgen -f -X "!*.$filetype" -- $cur ) )
36 | COMPREPLY+=( $( compgen -o plusdirs -f -X "!*.$filetype" -- $cur ) )
37 | fi
38 |
39 | # make sure there isn't a trailing space for directories
40 | if [[ ${#COMPREPLY[@]} == 1 ]]; then
41 | if [[ -d ${COMPREPLY[0]} ]]; then
42 | COMPREPLY[0]=$( echo ${COMPREPLY[0]} | sed 's/$/\//' )
43 | # If there's only one option, without =, then allow a space
44 | compopt -o nospace
45 | fi
46 | if [[ ${COMPREPLY[0]} == "--"*"=" ]]; then
47 | compopt -o nospace
48 | fi
49 | fi
50 | ;;
51 | bin2hex)
52 | ;;
53 | launch)
54 | if [[ "$COMP_CWORD" == "3" ]]; then
55 | COMPREPLY=( $( compgen -W '--no-reset' -- $cur ) )
56 | fi
57 | ;;
58 | read)
59 | # only either user or eeprom should be displayed based on if device has
60 | # either feature -- or either one is selected when both features exist
61 | flags="--force --user --eeprom --bin"
62 | eeprom_size=$( echo $TARGET_INFO | sed "s/.* $target:://" | sed 's/ .*//' )
63 | if [[ "$eeprom_size" == 0 ]]; then
64 | flags=$( echo $flags | sed 's/--eeprom//' )
65 | fi
66 | COMPREPLY=( $( compgen -W "$flags" -- $cur ) )
67 | ;;
68 | erase)
69 | COMPREPLY=( $( compgen -W '--force --suppress-validation' -- $cur ) )
70 | ;;
71 | flash)
72 | filetype="hex"
73 | flags="--force --user --eeprom --bin --suppress-validation --suppress-bootloader-mem --serial="
74 | eeprom_size=$( echo $TARGET_INFO | sed "s/.* $target:://" | sed 's/ .*//' )
75 | if [[ "$eeprom_size" == 0 ]]; then
76 | flags=$( echo $flags | sed 's/--eeprom//' )
77 | fi
78 | for (( i = 3; i < COMP_CWORD; i++ )); do
79 | if [[ "${COMP_WORDS[i]}" == *.@(bin|hex) ]]; then
80 | filetype="none"
81 | flags=$( echo $flags | sed 's/--bin//' )
82 | elif [[ "${COMP_WORDS[i]}" == --bin ]]; then
83 | if [[ filetype != none ]]; then
84 | filetype="bin"
85 | fi
86 | flags=$( echo $flags | sed 's/--bin//' )
87 | elif [[ "${COMP_WORDS[i]}" == --@(user|eeprom) ]]; then
88 | flags=$( echo $flags | sed 's/--user//' )
89 | flags=$( echo $flags | sed 's/--eeprom//' )
90 | else
91 | flags=$( echo $flags | sed "s/${COMP_WORDS[i]}//" )
92 | fi
93 | done
94 | COMPREPLY=( $( compgen -W "$flags" -- $cur ) )
95 | if [[ $filetype != none ]]; then
96 | #COMPREPLY+=( $( compgen -f -X "!*.$filetype" -- $cur ) )
97 | COMPREPLY+=( $( compgen -o plusdirs -f -X "!*.$filetype" -- $cur ) )
98 | fi
99 |
100 | #if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != "--"*"=" ]] ; then
101 | # make sure there isn't a trailing space for directories
102 | if [[ ${#COMPREPLY[@]} == 1 ]]; then
103 | if [[ -d ${COMPREPLY[0]} ]]; then
104 | COMPREPLY[0]=$( echo ${COMPREPLY[0]} | sed 's/$/\//' )
105 | # If there's only one option, without =, then allow a space
106 | compopt -o nospace
107 | fi
108 | if [[ ${COMPREPLY[0]} == "--"*"=" ]]; then
109 | compopt -o nospace
110 | fi
111 | fi
112 |
113 | ;;
114 | setsecure)
115 | ;;
116 | configure)
117 | ;;
118 | get)
119 | ;;
120 | getfuse)
121 | COMPREPLY=( $( compgen -W 'LOCK EPFL BOOTPROT BODLEVEL BODHYST BODEN ISP_BOD_EN ISP_IO_COND_EN ISP_FORCE' -- $cur ) )
122 | ;;
123 | setfuse)
124 | COMPREPLY=( $( compgen -W 'LOCK EPFL BOOTPROT BODLEVEL BODHYST BODEN ISP_BOD_EN ISP_IO_COND_EN ISP_FORCE' -- $cur ) )
125 | ;;
126 | esac
127 | fi
128 |
129 | return 0
130 | }
131 |
132 | complete -F _dfu-programmer dfu-programmer
133 |
--------------------------------------------------------------------------------
/src/dfu-programmer/docs/Makefile.am:
--------------------------------------------------------------------------------
1 | man_MANS = dfu-programmer.1
2 |
3 | EXTRA_DIST = $(man_MANS)
4 |
--------------------------------------------------------------------------------
/src/dfu-programmer/fedora/10-dfu-programmer.fdi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | dfu-device
12 | access_control
13 | linux.device_file
14 | dfu-device
15 | uucp
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/dfu-programmer/fedora/README:
--------------------------------------------------------------------------------
1 | Building RPM Binary Packages
2 | ============================
3 | This section is intended to make it easier for those people that wish to
4 | build RPMs from the source included in this package, but aren't sure how.
5 |
6 | 1) Copy dfu-programmer-.tar.gz to your RPM SOURCES directory. Usually
7 | this is /usr/src/redhat/SOURCES/.
8 |
9 | 2) Extract or copy dfu-programmer.spec into your RPM SPECS directory. Usually
10 | this is /usr/src/redhat/SPECS/.
11 |
12 | 3) In your RPM SPECS directory, issue the command 'rpm -ba dfu-programmer.spec'.
13 | This will cause rpm to extract the dfu-programmer sources to a temporary
14 | directory, build them, and build rpm packages based on the information in
15 | the spec file. The binary rpms will be put into your RPM RPMS directory.
16 | Usually this is /usr/src/redhat/RPMS//.
17 |
18 | If you have any further questions, please refer to the RPM documentation.
19 |
--------------------------------------------------------------------------------
/src/dfu-programmer/release_proc.txt:
--------------------------------------------------------------------------------
1 | Update info files
2 | =================
3 |
4 | Make sure the following files are up to date:
5 | - NEWS
6 | - AUTHORS
7 | - README
8 | - docs/dfu-programmer.1
9 | - docs/dfu-programmer.html
10 | - fedora/dfu-programmer.spec.in
11 |
12 | Note that the list of devices shown in README and the docs can be auto-generated
13 | using dfu-programmer --targets / --targets-tex / --targets-html
14 |
15 | Update the version number in configure.ac and push changes to GitHub.
16 |
17 |
18 | To create the source tarball
19 | ============================
20 |
21 | If building the tarball on Windows you need to install pkg-config.
22 | Get the lite version (without dependencies) from here:
23 | http://sourceforge.net/projects/pkgconfiglite
24 | The files need to go into MinGW/bin and MinGW/share/aclocal.
25 |
26 | After updating the version information in configure.ac
27 |
28 | ./bootstrap.sh
29 |
30 | ./configure
31 |
32 | make dist
33 |
34 |
35 | To create the Windows binary zip
36 | ================================
37 |
38 | Create a folder named something like dfu-prog-usb-1.2.2 containing the Atmel
39 | driver set from FLIP. Be sure to include Atmel's COPYING notice too.
40 |
41 | Copy dfu-programmer.exe to the parent of this directory.
42 |
43 | Copy the html man page from the doc folder.
44 |
45 | In the parent directory create a zip archive containing the executable, man page and the
46 | dfu-prog-usb-x.x.x directory.
47 |
48 |
49 | Upload
50 | ======
51 |
52 | Upload the tarball and in file information mark it as the default for everything except Windows.
53 | Set the description as "x.x.x tarball"
54 |
55 | Upload the Windows package and mark it as the default for Windows.
56 | Set the description as "x.x.x Windows binary with USB driver"
57 |
58 | Upload the SF-ReadMe.txt file as ReadMe.txt
59 |
60 |
61 | Web page update
62 | ===============
63 |
64 | Edit the index.php page in the dfu-programmer.github.io repository. As soon as the changes
65 | are pushed back to the repo the web page will update.
66 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CFLAGS = -Wall
2 | bin_PROGRAMS = dfu-programmer
3 | dfu_programmer_SOURCES = main.c arguments.c arguments.h atmel.c atmel.h \
4 | commands.c commands.h dfu.c dfu.h dfu-bool.h \
5 | dfu-device.h intel_hex.c intel_hex.h stm32.c stm32.h \
6 | util.c util.h
7 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/commands.h:
--------------------------------------------------------------------------------
1 | /*
2 | * dfu-programmer
3 | *
4 | * $Id$
5 | *
6 | * This program is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 | */
20 |
21 | #ifndef __COMMANDS_H__
22 | #define __COMMANDS_H__
23 |
24 | #include
25 | #include "arguments.h"
26 | #include "dfu-device.h"
27 |
28 | int32_t execute_command( dfu_device_t *device,
29 | struct programmer_arguments *args );
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/dfu-bool.h:
--------------------------------------------------------------------------------
1 | #ifndef __DFU_BOOL_H__
2 | #define __DFU_BOOL_H__
3 |
4 | typedef enum {
5 | false = 0,
6 | true = 1
7 | } dfu_bool;
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | * dfu-programmer
3 | *
4 | * $Id$
5 | *
6 | * This program is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 | */
20 |
21 | #if HAVE_CONFIG_H
22 | # include
23 | #endif
24 | #include
25 | #include
26 | #ifdef HAVE_LIBUSB_1_0
27 | #include
28 | #else
29 | #include
30 | #endif
31 |
32 | #include "config.h"
33 | #include "dfu-device.h"
34 | #include "dfu.h"
35 | #include "atmel.h"
36 | #include "arguments.h"
37 | #include "commands.h"
38 |
39 |
40 | int debug;
41 | #ifdef HAVE_LIBUSB_1_0
42 | libusb_context *usbcontext;
43 | #endif
44 |
45 | int main( int argc, char **argv )
46 | {
47 | static const char *progname = PACKAGE;
48 | int retval = SUCCESS;
49 | int status;
50 | dfu_device_t dfu_device;
51 | struct programmer_arguments args;
52 | #ifdef HAVE_LIBUSB_1_0
53 | struct libusb_device *device = NULL;
54 | #else
55 | struct usb_device *device = NULL;
56 | #endif
57 |
58 | memset( &args, 0, sizeof(args) );
59 | memset( &dfu_device, 0, sizeof(dfu_device) );
60 |
61 | status = parse_arguments(&args, argc, argv);
62 | if( status < 0 ) {
63 | /* Exit with an error. */
64 | return ARGUMENT_ERROR;
65 | } else if (status > 0) {
66 | /* It was handled by parse_arguments. */
67 | return SUCCESS;
68 | }
69 |
70 | #ifdef HAVE_LIBUSB_1_0
71 | if (libusb_init(&usbcontext)) {
72 | fprintf( stderr, "%s: can't init libusb.\n", progname );
73 | return DEVICE_ACCESS_ERROR;
74 | }
75 | #else
76 | usb_init();
77 | #endif
78 |
79 | if( debug >= 200 ) {
80 | #ifdef HAVE_LIBUSB_1_0
81 | libusb_set_debug(usbcontext, debug );
82 | #else
83 | usb_set_debug( debug );
84 | #endif
85 | }
86 |
87 | if( !(args.command == com_bin2hex || args.command == com_hex2bin) ) {
88 | device = dfu_device_init( args.vendor_id, args.chip_id,
89 | args.bus_id, args.device_address,
90 | &dfu_device,
91 | args.initial_abort,
92 | args.honor_interfaceclass );
93 |
94 | if( NULL == device ) {
95 | fprintf( stderr, "%s: no device present.\n", progname );
96 | retval = DEVICE_ACCESS_ERROR;
97 | goto error;
98 | }
99 | }
100 |
101 | if( 0 != (retval = execute_command(&dfu_device, &args)) ) {
102 | /* command issued a specific diagnostic already */
103 | goto error;
104 | }
105 |
106 | error:
107 | if( NULL != dfu_device.handle ) {
108 | int rv;
109 |
110 | #ifdef HAVE_LIBUSB_1_0
111 | rv = libusb_release_interface( dfu_device.handle, dfu_device.interface );
112 | #else
113 | rv = usb_release_interface( dfu_device.handle, dfu_device.interface );
114 | #endif
115 | /* The RESET command sometimes causes the usb_release_interface command to fail.
116 | It is not obvious why this happens but it may be a glitch due to the hardware
117 | reset in the attached device. In any event, since reset causes a USB detach
118 | this should not matter, so there is no point in raising an alarm.
119 | */
120 | if( 0 != rv && !(com_launch == args.command &&
121 | args.com_launch_config.noreset == 0) ) {
122 | fprintf( stderr, "%s: failed to release interface %d.\n",
123 | progname, dfu_device.interface );
124 | retval = DEVICE_ACCESS_ERROR;
125 | }
126 | }
127 |
128 | if( NULL != dfu_device.handle ) {
129 | #ifdef HAVE_LIBUSB_1_0
130 | libusb_close(dfu_device.handle);
131 | #else
132 | if( 0 != usb_close(dfu_device.handle) ) {
133 | fprintf( stderr, "%s: failed to close the handle.\n", progname );
134 | retval = DEVICE_ACCESS_ERROR;
135 | }
136 | #endif
137 | }
138 |
139 | #ifdef HAVE_LIBUSB_1_0
140 | libusb_exit(usbcontext);
141 | #endif
142 |
143 | return retval;
144 | }
145 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/stm32.h:
--------------------------------------------------------------------------------
1 | /** dfu-programmer
2 | *
3 | * This program is free software; you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation; either version 2 of the License, or
6 | * (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program; if not, write to the Free Software
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
16 | */
17 |
18 | #ifndef __STM32_H__
19 | #define __STM32_H__
20 |
21 | #include
22 | #include
23 | #include "dfu-bool.h"
24 | #include "dfu-device.h"
25 | #include "intel_hex.h"
26 |
27 | #define STM32_FLASH_OFFSET 0x08000000
28 |
29 | typedef enum {
30 | mem_st_sector0 = 0,
31 | mem_st_sector1,
32 | mem_st_sector2,
33 | mem_st_sector3,
34 | mem_st_sector4,
35 | mem_st_sector5,
36 | mem_st_sector6,
37 | mem_st_sector7,
38 | mem_st_sector8,
39 | mem_st_sector9,
40 | mem_st_sector10,
41 | mem_st_sector11,
42 | mem_st_system,
43 | mem_st_otp_area,
44 | mem_st_option_bytes,
45 | mem_st_all,
46 | } stm32_mem_sectors;
47 |
48 |
49 | #define STM32_MEM_UNIT_NAMES "Sector 0", "Sector 1", "Sector 2", "Sector 3", \
50 | "Sector 4", "Sector 5", "Sector 6", "Sector 7", "Sector 8", "Sector 9", \
51 | "Sector 10", "Sector 11", "System Memory", "OTP Area", "Option Bytes", "all"
52 |
53 | #define STM32_READ_PROT_ERROR -10
54 |
55 |
56 | int32_t stm32_erase_flash( dfu_device_t *device, dfu_bool quiet );
57 | /* mass erase flash
58 | * device - the usb_dev_handle to communicate with
59 | * returns status DFU_STATUS_OK if ok, anything else on error
60 | */
61 |
62 | int32_t stm32_page_erase( dfu_device_t *device, uint32_t address,
63 | dfu_bool quiet );
64 | /* erase a page of memory (provide the page address) */
65 |
66 | int32_t stm32_start_app( dfu_device_t *device, dfu_bool quiet );
67 | /* Reset the registers to default reset values and start application
68 | */
69 |
70 | int32_t stm32_read_flash( dfu_device_t *device,
71 | intel_buffer_in_t *buin,
72 | uint8_t mem_segment,
73 | const dfu_bool quiet);
74 | /* read the flash from buin->info.data_start to data_end and place
75 | * in buin.data. mem_segment is the segment of memory from the
76 | * stm32_memory_unit_enum.
77 | */
78 |
79 | int32_t stm32_write_flash( dfu_device_t *device, intel_buffer_out_t *bout,
80 | const dfu_bool eeprom, const dfu_bool force, const dfu_bool hide_progress );
81 | /* Flash data from the buffer to the main program memory on the device.
82 | * buffer contains the data to flash where buffer[0] is aligned with memory
83 | * address zero (which could be inside the bootloader and unavailable).
84 | * buffer[start / end] correspond to the start / end of available memory
85 | * outside the bootloader.
86 | * flash_page_size is the size of flash pages - used for alignment
87 | * eeprom bool tells if you want to flash to eeprom or flash memory
88 | * hide_progress bool sets whether to display progress
89 | */
90 |
91 | int32_t stm32_get_commands( dfu_device_t *device );
92 | /* @brief get the commands list, should be length 4
93 | * @param device pointer
94 | * @retrn 0 on success
95 | */
96 |
97 | int32_t stm32_get_configuration( dfu_device_t *device );
98 | /* @brief get the configuration structure
99 | * @param device pointer
100 | * @retrn 0 on success, negative for error
101 | */
102 |
103 | int32_t stm32_read_unprotect( dfu_device_t *device, dfu_bool quiet );
104 | /* @brief unprotect the device (triggers a mass erase)
105 | * @param device pointer
106 | * @retrn 0 on success
107 | */
108 |
109 |
110 |
111 | #if 0
112 | int32_t stm32_read_config( dfu_device_t *device,
113 | stm32_device_info_t *info );
114 |
115 | int32_t stm32_read_fuses( dfu_device_t *device, stm32_avr32_fuses_t * info );
116 |
117 | int32_t stm32_set_fuse( dfu_device_t *device, const uint8_t property,
118 | const uint32_t value );
119 |
120 | int32_t stm32_set_config( dfu_device_t *device, const uint8_t property,
121 | const uint8_t value );
122 |
123 | int32_t stm32_blank_check( dfu_device_t *device, const uint32_t start,
124 | const uint32_t end, dfu_bool quiet );
125 |
126 | int32_t stm32_secure( dfu_device_t *device );
127 |
128 | int32_t stm32_getsecure( dfu_device_t *device );
129 |
130 | int32_t stm32_user( dfu_device_t *device, intel_buffer_out_t *bout );
131 |
132 | void stm32_print_device_info( FILE *stream, stm32_device_info_t *info );
133 | #endif
134 |
135 | #endif /* __STM32_H__ */
136 |
137 | // vim: shiftwidth=2
138 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/util.c:
--------------------------------------------------------------------------------
1 | /*
2 | * dfu-programmer
3 | *
4 | * $Id: atmel.c 25 2006-06-25 00:01:37Z schmidtw $
5 | *
6 | * This program is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #include "util.h"
25 |
26 | extern int debug; /* defined in main.c */
27 |
28 | void dfu_debug( const char *file, const char *function, const int line,
29 | const int level, const char *format, ... )
30 | {
31 | if( level < debug ) {
32 | va_list va_arg;
33 |
34 | va_start( va_arg, format );
35 | fprintf( stderr, "%s:%d: ", file, line );
36 | vfprintf( stderr, format, va_arg );
37 | va_end( va_arg );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/dfu-programmer/src/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | * dfu-programmer
3 | *
4 | * $Id: atmel.h 21 2006-06-20 06:28:04Z schmidtw $
5 | *
6 | * This program is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 | */
20 |
21 | #ifndef __UTIL_H__
22 | #define __UTIL_H__
23 |
24 | #include
25 |
26 | void dfu_debug( const char *file, const char *function, const int line,
27 | const int level, const char *format, ... );
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/dfu-programmer/windows/atmel_usb_dfu.inf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/src/dfu-programmer/windows/atmel_usb_dfu.inf
--------------------------------------------------------------------------------
/src/dfu-programmer/windows/libusb.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/src/dfu-programmer/windows/libusb.a
--------------------------------------------------------------------------------
/src/digitemp/COPYRIGHT:
--------------------------------------------------------------------------------
1 | DigiTemp v3.6.0
2 | Dallas Semiconductor one-wire temperature sensor interface
3 | http://www.digitemp.com
4 |
5 | Copyright (c) 1996-2008 by Brian C. Lane
6 | http://www.brianlane.com
7 | All rights reserved.
8 |
9 | This program is free software; you can redistribute it and/or modify it
10 | under the terms of the GNU General Public License as published by the Free
11 | Software Foundation; either version 2 of the License, or (at your option)
12 | any later version.
13 |
14 | This program is distributed in the hope that it will be useful, but WITHOUT
15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 | more details.
18 |
19 | You should have received a copy of the GNU General Public License along
20 | with this program; if not, write to the Free Software Foundation, Inc.,
21 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/digitemp/CREDITS:
--------------------------------------------------------------------------------
1 | Brian C. Lane
2 | Original DigiTemp code, and editor of submitted patches
3 |
4 | Erik Rigtorp
5 | Developed the ds9097 code for the owpd kit.
6 |
7 | Jesus Roncero
8 | Debian package maintainer
9 | Hub search fixes
10 | Manpage
11 |
12 | Eric Wilde
13 | DS2438 Humidity support
14 |
15 | Sven Geggus
16 | -n0 infinite loop
17 |
18 | Ewan Leith
19 | AIX Support
20 |
21 | Roland Roberts
22 | DS1822 and DS18B20 changes
23 |
24 | Ted Frohling
25 | 1-wire hub loan
26 |
27 | John Stoffel
28 | Solaris, AIX, FreeBSD patches
29 |
30 | Erik Rigtorp
31 | userial driver for passive DS9097 adapter
32 |
33 | Kevin Pedigo
34 | Makefile cleanup
35 |
36 | Peter Enderborg
37 | sleep change
38 |
39 | Måns Nilsson
40 | OpenBSD
41 |
42 |
43 | (need to add more names here)
44 |
--------------------------------------------------------------------------------
/src/digitemp/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/src/digitemp/ChangeLog
--------------------------------------------------------------------------------
/src/digitemp/DS9097_Schematic.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jens-maus/cuxd/3d6253737ce0c31a8220dec6fc9cbf3af6245704/src/digitemp/DS9097_Schematic.gif
--------------------------------------------------------------------------------
/src/digitemp/TODO:
--------------------------------------------------------------------------------
1 | X 0. Get USB adapter running using libusb and PDK.
2 | Still need to run as root, but it is working.
3 |
4 | X a. Review changes and test code from Erik Rigtorp
5 |
6 | b. Reduce cpu usage in the loop when doing multiple conversions
7 |
8 | X c. Add infinite loop
9 |
10 | d. Catch TERM to exit the loop cleanly
11 |
12 | e. review emails and make any other needed changes
13 |
14 | 1. Add global variables for the slew rate and re/write timing adjustments
15 | in the ds2840ut.c file. Add control of these to the digitemp.c code.
16 |
17 | X 2. Add support for rpm building
18 |
19 | X 4. check for permission to open the serial device and complain when it
20 | fails.
21 |
22 | X 6. Write some SQL based scripts. Perl to feed the database with the output
23 | and PHP scripts to graph it using gd or ? modules in PHP.
24 |
25 | X 7. Change the sensor token so it doesnt conflict with ctime. change small s
26 | to capital S.
27 |
28 | X 8. Loosen up checks for commands so -i -a will work!! -i should be allowed
29 | with all others.
30 |
31 | X 9. Create a lockfile for the serial port in use, and check the lock file
32 | before opening it.
33 |
34 | 10. Fix problems using the USB serial port. Not sure what's happening. It
35 | will sometimes work, most of the time fail. Extending VTIME didn't make
36 | any noticable difference.
37 |
38 | I changed global_msec_max (controls the time delay for characters in
39 | the ReadCOM routine). It might be a slight improvement, but still fails
40 | a considerable percentage of the time.
41 |
42 | Sometimes the DS2480 detection fails, sometimes the search fails. It
43 | will also sometimes run fine (and quickly).
44 |
45 | Getting somewhere:
46 |
47 | Fails: 17 45 5B 0F 91
48 |
49 | Works: 16 44 5A 00 93
50 |
51 | Sent : 17 45 5B 0F 91
52 |
53 | Once : C1 17 45 5B 0F
54 |
55 | I added a wrapper for DS2480Detect that retries up to 10 times before
56 | giving up.
57 |
58 | Extending the maximum time to 1.800 or so (1sec + 800mS) also helps it
59 | run better. Without that it doesn't read the data very well. Without
60 | the loop on DS2480Detect it doesn't work consistently with the dongle.
61 |
62 | I need to add the delays back in, and see how they effect normal
63 | operation.
64 |
65 |
66 |
67 | X11. Add counter and switch support.
68 | Counter support has been added. DS2406 counters.
69 |
70 | 12. Add long-argument switches to the program so that counter and switch
71 | results can be turned on/off. Temperature as well.
72 |
73 | 13. Update and review all documents and directions to make sure they are
74 | current and match the command line.
75 |
76 | X14. Fix the Makefile so that it doesn't need to be edited for different
77 | targets (ie. the ds2490)
78 |
79 | X15. Need to update the digitemp.1 manpage.
80 |
--------------------------------------------------------------------------------
/src/digitemp/contrib/digitemp-freebsd.patch:
--------------------------------------------------------------------------------
1 | diff -urN digitemp-3.2.0-org/userial/cnt1d.c digitemp-3.2.0/userial/cnt1d.c
2 | --- digitemp-3.2.0-org/userial/cnt1d.c Thu May 22 03:50:21 2003
3 | +++ digitemp-3.2.0/userial/cnt1d.c Sat Oct 25 18:17:41 2003
4 | @@ -30,6 +30,8 @@
5 | //
6 | //
7 | #include "ownet.h"
8 | +#include
9 | +typedef unsigned long ulong;
10 |
11 | // external One Wire functions from nework layer
12 | extern SMALLINT owAccess(int);
13 | diff -urN digitemp-3.2.0-org/userial/crcutil.c digitemp-3.2.0/userial/crcutil.c
14 | --- digitemp-3.2.0-org/userial/crcutil.c Thu May 22 03:50:20 2003
15 | +++ digitemp-3.2.0/userial/crcutil.c Sat Oct 25 18:17:41 2003
16 | @@ -29,6 +29,7 @@
17 |
18 | // Include files
19 | #include "ownet.h"
20 | +#include
21 |
22 | // Local subroutines
23 | void setcrc16(int,ushort);
24 | diff -urN digitemp-3.2.0-org/userial/ds9097/owtran.c digitemp-3.2.0/userial/ds9097/owtran.c
25 | --- digitemp-3.2.0-org/userial/ds9097/owtran.c Thu May 22 03:50:19 2003
26 | +++ digitemp-3.2.0/userial/ds9097/owtran.c Sat Oct 25 18:17:41 2003
27 | @@ -34,6 +34,7 @@
28 | //
29 |
30 | #include "ownet.h"
31 | +#include
32 |
33 | //--------------------------------------------------------------------------
34 | // The 'owBlock' transfers a block of data to and from the
35 | diff -urN digitemp-3.2.0-org/userial/ds9097u/owtrnu.c digitemp-3.2.0/userial/ds9097u/owtrnu.c
36 | --- digitemp-3.2.0-org/userial/ds9097u/owtrnu.c Thu May 22 03:50:20 2003
37 | +++ digitemp-3.2.0/userial/ds9097u/owtrnu.c Sat Oct 25 18:17:41 2003
38 | @@ -41,6 +41,7 @@
39 |
40 | #include "ownet.h"
41 | #include "ds2480.h"
42 | +#include
43 |
44 | // external functions defined in owllu.c
45 | extern SMALLINT owTouchReset(int);
46 | diff -urN digitemp-3.2.0-org/userial/ioutil.c digitemp-3.2.0/userial/ioutil.c
47 | --- digitemp-3.2.0-org/userial/ioutil.c Thu May 22 03:50:21 2003
48 | +++ digitemp-3.2.0/userial/ioutil.c Sat Oct 25 18:17:41 2003
49 | @@ -37,6 +37,8 @@
50 | #include
51 | #include "ownet.h"
52 |
53 | +typedef unsigned long ulong;
54 | +
55 | #ifdef __MC68K__
56 | #include
57 | #include
58 | diff -urN digitemp-3.2.0-org/userial/owproto.h digitemp-3.2.0/userial/owproto.h
59 | --- digitemp-3.2.0-org/userial/owproto.h Thu May 22 03:50:21 2003
60 | +++ digitemp-3.2.0/userial/owproto.h Sat Oct 25 18:17:41 2003
61 | @@ -29,7 +29,7 @@
62 | char *owGetErrorMsg(int);
63 | #endif
64 |
65 | -
66 | +typedef unsigned long ulong;
67 |
68 | /* From ioutil.c */
69 | int EnterString(char *, char *, int, int);
70 |
--------------------------------------------------------------------------------
/src/digitemp/contrib/libusb.patch.txt:
--------------------------------------------------------------------------------
1 | --------------070507070300030101020103
2 | Content-Type: text/plain; charset=us-ascii; format=flowed
3 | Content-Transfer-Encoding: 7bit
4 |
5 | I've successfully used the driver found in main PDK archive
6 | (owpd300b2.zip) under generic library using usblnk.c and usbses.lnk.
7 | This driver in turn uses libusb library found on the internet.
8 |
9 | I've found libusb v0.1.7, which contained a small bug in linux.c file.
10 | The fixed routine is below.
11 |
12 | int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
13 | int timeout)
14 | {
15 | struct usb_bulktransfer bulk;
16 | int ret, retrieved = 0, requested;
17 |
18 | /* Ensure the endpoint address is correct */
19 | ep |= USB_ENDPOINT_IN;
20 |
21 | do {
22 | bulk.ep = ep;
23 | requested = size - retrieved;
24 | if (requested > MAX_READ_WRITE)
25 | requested = MAX_READ_WRITE;
26 | bulk.len = requested;
27 | bulk.timeout = timeout;
28 | bulk.data = (unsigned char *)bytes + retrieved;
29 |
30 | ret = ioctl(dev->fd, IOCTL_USB_BULK, &bulk);
31 | if (ret < 0)
32 | USB_ERROR_STR(ret, "error reading from bulk endpoint 0x%x: %s",
33 | ep, strerror(errno));
34 |
35 | retrieved += ret;
36 | } while (ret > 0 && retrieved < size); /* Yefim: && ret == requested */
37 |
38 | return retrieved;
39 | }
40 |
41 | Best regards,
42 |
43 | Mike.
44 |
45 | bcl wrote:
46 |
47 | >On Wed, Jul 23, 2003 at 05:57:50AM -0400, Paul Alfille wrote:
48 | >
49 | >
50 | >>Has anyone written a driver for the DS9490 USB master for Linux?
51 | >>
52 | >>I will try if it hasn't been done, but it's not my area of expertise.
53 | >>
54 | >>
55 | >>
56 | >
57 | >Not yet (to my knowledge), although I am trying to make the time to get
58 | >started on the project.
59 | >
60 | >Brian
61 | >
62 | >
63 | >
64 |
65 | --------------070507070300030101020103
66 | Content-Type: text/html; charset=us-ascii
67 | Content-Transfer-Encoding: 7bit
68 |
69 |
70 |
71 |
72 |
73 |
74 | I've successfully used the driver found in main PDK archive (owpd300b2.zip)
75 | under generic library using usblnk.c and usbses.lnk. This driver in turn
76 | uses libusb library found on the internet.
77 |
78 |
79 |
80 | I've found libusb v0.1.7, which contained a small bug in linux.c file. The
81 | fixed routine is below.
82 |
83 |
84 |
85 | int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
86 |
87 | int timeout)
88 |
89 | {
90 |
91 | struct usb_bulktransfer bulk;
92 |
93 | int ret, retrieved = 0, requested;
94 |
95 |
96 |
97 | /* Ensure the endpoint address is correct */
98 |
99 | ep |= USB_ENDPOINT_IN;
100 |
101 |
102 |
103 | do {
104 |
105 | bulk.ep = ep;
106 |
107 | requested = size - retrieved;
108 |
109 | if (requested > MAX_READ_WRITE)
110 |
111 | requested = MAX_READ_WRITE;
112 |
113 | bulk.len = requested;
114 |
115 | bulk.timeout = timeout;
116 |
117 | bulk.data = (unsigned char *)bytes + retrieved;
118 |
119 |
120 |
121 | ret = ioctl(dev->fd, IOCTL_USB_BULK, &bulk);
122 |
123 | if (ret < 0)
124 |
125 | USB_ERROR_STR(ret, "error reading from bulk endpoint 0x%x: %s",
126 |
127 | ep, strerror(errno));
128 |
129 |
130 |
131 | retrieved += ret;
132 |
133 | } while (ret > 0 && retrieved < size); /* Yefim: &&
134 | ret == requested */
135 |
136 |
137 |
138 | return retrieved;
139 |
140 | }
141 |
142 |
143 |
144 | Best regards,
145 |
146 |
147 |
148 | Mike.
149 |
150 |
151 |
152 | bcl wrote:
153 |
154 | >On Wed, Jul 23, 2003 at 05:57:50AM -0400, Paul Alfille wrote:
155 | >
156 | >
157 | >>Has anyone written a driver for the DS9490 USB master for Linux?
158 | >>
159 | >>I will try if it hasn't been done, but it's not my area of expertise.
160 | >>
161 | >>
162 | >>
163 | >
164 | >Not yet (to my knowledge), although I am trying to make the time to get
165 | >started on the project.
166 | >
167 | >Brian
168 | >
169 | >
170 | >
171 |
172 |
--------------------------------------------------------------------------------
/src/digitemp/digitemp-cflags.patch:
--------------------------------------------------------------------------------
1 | --- digitemp-3.6.0/Makefile 2008-08-28 14:43:35.000000000 -0700
2 | +++ digitemp-3.6.0/Makefile.rpm 2008-08-28 14:46:06.000000000 -0700
3 | @@ -12,7 +12,7 @@
4 | VERSION = 3.6.0
5 |
6 | CC = gcc
7 | -CFLAGS = -I./src -I./userial -O2 -Wall # -g
8 | +CFLAGS = -I./src -I./userial $(RPM_OPT_FLAGS)
9 |
10 | OBJS = src/digitemp.o src/device_name.o src/ds2438.o
11 | HDRS = src/digitemp.h src/device_name.h
12 |
--------------------------------------------------------------------------------
/src/digitemp/digitemp.spec:
--------------------------------------------------------------------------------
1 | %define with_libusb 1
2 |
3 | Summary: Dallas Semiconductor 1-wire device reading console application
4 | Name: digitemp
5 | Version: 3.6.0
6 | Release: 1%{?dist}
7 | License: GPLv2+
8 | Group: Applications/System
9 | URL: http://www.digitemp.com/
10 | Source0: http://www.digitemp.com/software/linux/%{name}-%{version}.tar.gz
11 | Source1: dthowto.txt
12 | Source2: DS9097_Schematic.gif
13 | Patch0: digitemp-cflags.patch
14 | %if %{with_libusb}
15 | BuildRequires: libusb-devel
16 | %endif
17 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
18 |
19 | %description
20 | DigiTemp is a simple to use console application for reading values from
21 | Dallas Semiconductor 1-wire devices. Its main use is for reading temperature
22 | sensors, but it also reads counters and understands the 1-wire hubs with
23 | devices on different branches of the network. DigiTemp now supports the
24 | following 1-wire temperature sensors: DS18S20 (and DS1820), DS18B20, DS1822,
25 | the DS2438 Smart Battery Monitor, DS2422 and DS2423 Counters, DS2409
26 | MicroLAN Coupler (used in 1-wire hubs) and the AAG TAI-8540 humidity sensor.
27 |
28 | %prep
29 | %setup -q
30 | %patch0 -p1 -b .cflags
31 | cp -f %{SOURCE1} %{SOURCE2} .
32 |
33 | %build
34 | make ds9097 %{?_smp_mflags}
35 | make ds9097u %{?_smp_mflags}
36 | %if %{with_libusb}
37 | make ds2490 %{?_smp_mflags}
38 | %endif
39 |
40 | %install
41 | rm -rf $RPM_BUILD_ROOT
42 | mkdir -p $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
43 | install -m 755 digitemp_DS9097 digitemp_DS9097U $RPM_BUILD_ROOT%{_bindir}
44 | %if %{with_libusb}
45 | install -m 755 digitemp_DS2490 $RPM_BUILD_ROOT%{_bindir}
46 | %endif
47 |
48 | iconv -f iso-8859-1 -t utf-8 -o digitemp.1.utf8 digitemp.1
49 | install -m 644 digitemp.1.utf8 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}.1
50 |
51 | %clean
52 | rm -rf $RPM_BUILD_ROOT
53 |
54 | %files
55 | %defattr(-,root,root)
56 | %doc ChangeLog COPYING COPYRIGHT CREDITS FAQ README TODO
57 | %doc dthowto.txt DS9097_Schematic.gif
58 | %{_bindir}/%{name}*
59 | %{_mandir}/man1/%{name}.*
60 |
61 | %changelog
62 | * Thu Aug 28 2008 Brian C. Lane 3.6.0-1
63 | - Releasing new version with these changes:
64 | - Updated to the .spec file from Fedora9
65 | - DS2490 now suppresses the 'Found usb ...' output
66 | - Support for compiling under DARWIN
67 | - Current reading added to DS2438
68 | - DS28EA00 support added
69 | - Tabbed output of 0.00 on CRC errors with log type -o2 or -o3
70 | - New manpage from Debian digitemp maintainer
71 |
72 | * Sun Feb 10 2008 Robert Scheck 3.5.0-3
73 | - Rebuilt against gcc 4.3
74 |
75 | * Tue Aug 28 2007 Robert Scheck 3.5.0-2
76 | - Updated the license tag according to the guidelines
77 |
78 | * Sun Jan 07 2007 Robert Scheck 3.5.0-1
79 | - Upgrade to 3.5.0
80 | - Initial spec file for Fedora and Red Hat Enterprise Linux
81 |
--------------------------------------------------------------------------------
/src/digitemp/dthowto.txt:
--------------------------------------------------------------------------------
1 |
2 | Howto build a Serial Adapter for Dallas DS1820 temperature sensors
3 |
4 | Copyright (c) 2001 by Brian C. Lane
5 | All Rights Reserved
6 |
7 |
8 |
9 | The DigiTemp program for Linux, DOS and Windows 95 uses a simple serial
10 | port adapter to communicate with the Dallas DS1820 digital temperature
11 | sensors. These sensors use a protocol called One-Wire or Micro LAN
12 | (depending on which Dallas documentation you are reading). This protocol
13 | requires only a ground and a data wire to the device. All power is derived
14 | from the data line while it is idle.
15 |
16 | The protocol is NOT RS232! The adapter converts the RS232 voltages into
17 | the +5v needed to communicate with the DS1820. Each byte sent to the serial
18 | port represents one data bit to the DS1820. See Dallas Semiconductor App
19 | Note #74 for more information, or the sourcecode for DigiTemp.
20 |
21 | How To build an adapter
22 | -----------------------
23 |
24 | If you want a schematic diagram you need to look at page 20 of App.
25 | Note #74 from Dallas Semiconductor ( )
26 |
27 |
28 | Parts List
29 | ----------
30 |
31 | 1 DB-25 connector or DB-9 connector
32 | 1 1.5k ohm resistor
33 | 2 1N5818 Schottky Diode
34 | 1 1N5228 3.9v Zener Diode
35 | 1 1N5234 6.2v Zener Diode
36 | 1 2 position terminal block (for connecting the sensors to adapter)
37 |
38 | Wire cutters and a soldering iron.
39 |
40 | In this document I will refer to the pin functions. The pin numbers for
41 | DB-25 and DB-9 are as follows:
42 |
43 | Name DB-25 DB-9
44 | ---- ----- ----
45 | DTR 20 4
46 | RXD 3 2
47 | TXD 2 3
48 | GND 1,7 5
49 |
50 | NOTE: I have not built a DB-9 version myself. Please let me know if you
51 | successfully build one or have problems with it.
52 |
53 | On the DB-25 pins 1 and 7 must BOTH be connected together.
54 |
55 |
56 | Step Description
57 | ------------------------------------------------------------------------
58 | 1. Solder the 1N5228 3.9v Zener between GND and DTR with the
59 | Cathode(the stripe) towards DTR.
60 |
61 | 2. Solder the 1.5k ohm resistor between RXD and TXD.
62 |
63 | 3. Solder one of the 1N5818 diodes between RXD and TXD with the
64 | Cathode(the stripe) towards RXD.
65 |
66 | 4. Solder the other 1N5818 diode between RXD and DTR with the
67 | Cathode(the stripe) towsrds DTR.
68 |
69 | 5. Solder the 1N5234 6.2v Zener between RXD and DTR with the
70 | Cathode(the stripe) towards DTR.
71 |
72 | 6. Solder RXD to one pin of the terminal block and paint it
73 | black. This is the GND connection for the sensors.
74 |
75 | 7. Solder DTR to the other pin of the terminal block and paint
76 | it red. This is the DATA connection for the sensors.
77 |
78 |
79 | There! Now you have an adapter.
80 |
81 | Connecting the sensors
82 | ----------------------
83 |
84 | You need to connect to wires to the sensor to attach to the terminal
85 | block. If you look at the sensor so that the label is towards you, with the
86 | pins facing down the pins are from left to right:
87 |
88 | 1. GND
89 | 2. DATA
90 | 3. +5v
91 |
92 | Solder your wires to GND and DATA and connect them to the terminal block
93 | and you're done! Be careful not to overheat the sensor while soldering to
94 | it. My method is to tin the legs quickly and let them cool off (while
95 | tinning the others) and then to tin the wires, then attach them quickly with
96 | a minimum of heat applied.
97 |
98 | One additional note: Because of the voltage(and current) drop across the
99 | resistor this adapter isn't capable of providing enough current to read
100 | temperatures above about +70C. This is a limitation of the design, not an
101 | error with the DS1820 or the software.
102 |
103 | If you have any questions or comments, email me at bcl@brianlane.com or
104 | subscribe to the digitemp mailing list by sending a blank email to
105 | digitemp-subscribe@brianlane.com
106 |
107 | Brian Lane
108 | bcl@brianlane.com
109 | http://www.brianlane.com
110 |
111 | March 13, 2001
112 |
--------------------------------------------------------------------------------
/src/digitemp/perl/README:
--------------------------------------------------------------------------------
1 | Digitemp v2.6
2 | Copyright 1996-2002 by Brian C. Lane
3 |
4 |
5 | Here are a few useful perl scripts for you to use with DigiTemp. Most of
6 | them need customization for your specific circumstances. Some these scripts
7 | are old, as I now use the RRD tool to graph and log data.
8 |
9 | The digitemp_sql.pl script is new, and has not been tested extensivly yet,
10 | but should work for users familiar with the MySQL database system.
11 |
12 |
13 | inc_temp Build a file suitable for including into a server side
14 | include webpage (or modify it to create the whole webpage.
15 | This script operates on a logfile output from digitemp when
16 | running with the -l option.
17 |
18 | rem_temp Create an include file as in inc_temp and then send it to
19 | a server via FTP.
20 | This script operates on a logfile output from digitemp when
21 | running with the -l option.
22 |
23 | maxplot Create a GIF image of the temperature graph.
24 | This script operates on a logfile output from digitemp when
25 | running with the -l option.
26 |
27 | check_digitemp.pl
28 | This is a NetSaint/Nagios (www.nagios.com) script that uses
29 | DigiTemp to check temperatures on monitored machines.
30 |
31 | digitemp_sql.pl MySQL database logging of temperatures.
32 |
33 | This is a new script, it logs the serial number and temperature
34 | in Fahrenheit to a MySQL database. I assume that you are
35 | familiar with the care and feeding of your database so that I
36 | can skip over the simple stuff and get to the point:
37 |
38 | Create a new database named digitemp:
39 | mysqladmin create digitemp -u root -p
40 |
41 | Edit the grant_mysql.sql file and change the password and
42 | optionally the username. Grant access to the new database:
43 |
44 | mysql mysql -u root -p < mysql_grant.sql
45 |
46 | Create the database table:
47 |
48 | mysql digitemp -u root -p < make_mysql.sql
49 |
50 | Edit the digitemp_mysql.pl script. Change the password to the
51 | one you used above, optionally change the username.
52 | Point the digitemp_rcfile variable to the DigiTemp config file
53 | that you have previously created using digitemp -i -c rcfile
54 |
55 | I recommend using one other than .digitemprc so that it isn't
56 | accidently erased when you run digitemp -i from your home
57 | directory.
58 |
59 | Make sure the path to the digitemp binary is correct. It is
60 | specified by the $digitemp_binary variable.
61 |
62 | Setup a cron job to log temperatures to the database at
63 | regular intervals:
64 |
65 | */5 * * * * /home/brian/bin/digitemp_mysql.pl
66 |
67 | At this time I have not written any logging or graphing
68 | scripts to deal with the MySQL temperature data.
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/digitemp/perl/digitemp_mysql.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -W
2 |
3 | # DigiTemp MySQL logging script
4 | # Copyright 2002 by Brian C. Lane
5 | # All Rights Reserved
6 | #
7 | # This program is free software; you can redistribute it and/or modify it
8 | # under the terms of the GNU General Public License as published by the Free
9 | # Software Foundation; either version 2 of the License, or (at your option)
10 | # any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but WITHOUT
13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 | # more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with this program; if not, write to the Free Software Foundation, Inc.,
19 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 | #
21 | # -------------------------[ HISTORY ]-------------------------------------
22 | # 01/08/2004 The storage definition should have been decimal(6,2) instead
23 | # bcl of decimal(3,2).
24 | # See http://www.mysql.com/doc/en/Numeric_types.html for a
25 | # good description of how decimal(a,b) works.
26 | #
27 | # 08/18/2002 Putting together this MySQL logging script for the new
28 | # bcl release of DigiTemp.
29 | #
30 | # -------------------------------------------------------------------------
31 | # CREATE table digitemp (
32 | # dtKey int(11) NOT NULL auto_increment,
33 | # time timestamp NOT NULL,
34 | # SerialNumber varchar(17) NOT NULL,
35 | # Fahrenheit decimal(6,2) NOT NULL,
36 | # PRIMARY KEY (dtKey),
37 | # KEY serial_key (SerialNumber),
38 | # KEY time_key (time)
39 | # );
40 | #
41 | # GRANT SELECT,INSERT ON digitemp.* TO dt_logger@localhost
42 | # IDENTIFIED BY 'TopSekRet';
43 | #
44 | # -------------------------------------------------------------------------
45 | use DBI;
46 |
47 |
48 | # Database info
49 | my $db_name = "digitemp";
50 | my $db_user = "dt_logger";
51 | my $db_pass = "TopSekRet";
52 |
53 | # The DigiTemp Configuration file to use
54 | my $digitemp_rcfile = "/home/brian/digitemp.cfg";
55 | my $digitemp_binary = "/home/brian/bin/digitemp";
56 |
57 |
58 | my $debug = 0;
59 |
60 | # Connect to the database
61 | my $dbh = DBI->connect("dbi:mysql:$db_name","$db_user","$db_pass")
62 | or die "I cannot connect to dbi:mysql:$db_name as $db_user - $DBI::errstr\n";
63 |
64 |
65 | # Gather information from DigiTemp
66 | # Read the output from digitemp
67 | # Output in form SerialNumberTemperature in Fahrenheit
68 | open( DIGITEMP, "$digitemp_binary -q -a -o\"%R %.2F\" -c $digitemp_rcfile |" );
69 |
70 | while( )
71 | {
72 | print "$_\n" if($debug);
73 | chomp;
74 |
75 | ($serialnumber,$temperature) = split(/ /);
76 |
77 | my $sql="INSERT INTO digitemp SET SerialNumber='$serialnumber',Fahrenheit=$temperature";
78 | print "SQL: $sql\n" if($debug);
79 | $dbh->do($sql) or die "Can't execute statement $sql because: $DBI::errstr";
80 | }
81 |
82 | close( DIGITEMP );
83 |
84 | $dbh->disconnect;
85 |
--------------------------------------------------------------------------------
/src/digitemp/perl/grant_mysql.sql:
--------------------------------------------------------------------------------
1 | GRANT SELECT,INSERT ON digitemp.* TO dt_logger@localhost
2 | IDENTIFIED BY 'TopSekRet';
3 |
--------------------------------------------------------------------------------
/src/digitemp/perl/inc_temp:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp webpage include script
4 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
5 | # All Rights Reserved
6 | #
7 | # This program is free software; you can redistribute it and/or modify it
8 | # under the terms of the GNU General Public License as published by the Free
9 | # Software Foundation; either version 2 of the License, or (at your option)
10 | # any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but WITHOUT
13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 | # more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with this program; if not, write to the Free Software Foundation, Inc.,
19 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 | #
21 |
22 | #
23 | # Read the temperature logfile, write an include file for the webpage.
24 | #
25 | # Sensor #0 is the Window
26 | # Sensor #1 is the inside of the Linux box
27 | #
28 | # Dec 18 21:46:47 Sensor 0 C: 8.81 F: 47.86
29 | # Dec 18 21:46:47 Sensor 1 C: 26.41 F: 79.54
30 | #
31 |
32 | # Directory and filename of the webpage include file to create
33 | $ftp_src_dir = "/tmp/";
34 | $ftp_src_file = "nexus_temp.inc";
35 |
36 | # Open the file for output
37 | open( INCFILE, ">$ftp_src_dir$ftp_src_file") || die "Can't open $ftp_src_dir$ftp_src_file";
38 |
39 | # Write the temperatures to the file
40 | print INCFILE "
\n";
41 | print INCFILE "\n";
42 | print INCFILE "The current temperatures are:\n";
43 |
44 | # Run tail -2 /var/log/temperature and parse the output
45 | # The -2 depends on the number of sensors that you have.
46 | open( TEMPLOG, "tail -2 /var/log/temperature |") || die "Can't fork: $!";
47 |
48 | while( )
49 | {
50 | # Get the time and date, sensor number, temperature in c and f
51 | ($month,$day,$time,$d1,$sensor,$d1,$centigrade,$d1,$fahrenheight) = split( " ", $_ );
52 |
53 | # Print sensor specific messages
54 | # The \xB0 is supposed to be a degree symbol. It seems to work for some
55 | # systems but not for others
56 | if( $sensor eq '0' )
57 | {
58 | print INCFILE "The modems are $fahrenheight\xB0 F ($centigrade\xB0 C)
\n";
59 | }
60 |
61 | if( $sensor eq '1' )
62 | {
63 | print INCFILE "The room is a ";
64 |
65 | if( $fahrenheight < 40.0 )
66 | {
67 | print INCFILE "Freezing";
68 | }
69 |
70 | if( $fahrenheight >= 40.0 and $fahrenheight < 70.0 )
71 | {
72 | print INCFILE "Chilly";
73 | }
74 |
75 | if( $fahrenheight >= 70.0 and $fahrenheight < 80.0 )
76 | {
77 | print INCFILE "Comfortable";
78 | }
79 |
80 | if( $fahrenheight >= 80.0 and $fahrenheight < 100.0 )
81 | {
82 | print INCFILE "Balmy";
83 | }
84 |
85 | if( $fahrenheight >= 100.0 )
86 | {
87 | print INCFILE "Blistering";
88 | }
89 |
90 |
91 | print INCFILE " $fahrenheight\xB0 F ($centigrade\xB0 C)
\n";
92 | }
93 | }
94 |
95 | print INCFILE "Last updated: $month $day $time
\n";
96 |
97 | print INCFILE "
\n";
98 |
99 | close( TEMPLOG );
100 | close( INCFILE );
101 |
102 | # done!
103 |
--------------------------------------------------------------------------------
/src/digitemp/perl/make_mysql.sql:
--------------------------------------------------------------------------------
1 | CREATE table digitemp (
2 | dtKey int(11) NOT NULL auto_increment,
3 | time timestamp NOT NULL,
4 | SerialNumber varchar(17) NOT NULL,
5 | Fahrenheit decimal(6,2) NOT NULL,
6 | PRIMARY KEY (dtKey),
7 | KEY serial_key (SerialNumber),
8 | KEY time_key (time)
9 | );
10 |
11 |
--------------------------------------------------------------------------------
/src/digitemp/perl/rem_temp:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp remote system update script
4 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
5 | # All Rights Reserved
6 | #
7 | # This program is free software; you can redistribute it and/or modify it
8 | # under the terms of the GNU General Public License as published by the Free
9 | # Software Foundation; either version 2 of the License, or (at your option)
10 | # any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but WITHOUT
13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 | # more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with this program; if not, write to the Free Software Foundation, Inc.,
19 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 | #
21 |
22 | #
23 | # Read the temperature logfile, write it to an include file for the webpage,
24 | # then ftp the files to the destination server.
25 | #
26 | # The following perl extensions are required :
27 | # libnet package from http://www.perl.com/CPAN-local/modules/by-module/Net/
28 | # I used libnet-1.0506.tar.gz
29 | #
30 | # Data-Dumper package from: CPAN/modules/by-module/Data/Data-Dumper-x.x.tar.gz
31 | # I used Data-Dumper-2.07.tar.gz
32 |
33 | #
34 | # Sensor #0 is the Window
35 | # Sensor #1 is the inside of the Linux box
36 | #
37 | # Dec 18 21:46:47 Sensor 0 C: 8.81 F: 47.86
38 | # Dec 18 21:46:47 Sensor 1 C: 26.41 F: 79.54
39 | #
40 | use Net::FTP;
41 |
42 | # Include file for the webpage (included from the main page)
43 | $inc_file = "/tmp/temp.inc";
44 |
45 | # Temperature logfile updated by seperate DigiTemp daemon
46 | $log_file = "/var/log/temperature";
47 |
48 | # Script to run to bring up the link
49 | # I use diald, you probably use something different.
50 | $ip_up = "/usr/sbin/dialdc up";
51 |
52 | # Your username for the destination ftp server
53 | $ftp_user = "username";
54 |
55 | # Your password for the destination ftp server
56 | $ftp_pass = "password";
57 |
58 | # Destination ftp server's address
59 | $ftp_host = "ftp.host.com";
60 |
61 | # Directory on the destination ftp server to place $inc_file
62 | $dest_dir = "/home/login/public_html";
63 |
64 | # Create a new include file, overwrite the old one
65 | open( INCFILE, ">$inc_file") || die "Can't open $inc_file";
66 |
67 | # Include a break line and center the text
68 | print INCFILE "
\n";
69 | print INCFILE "\n";
70 |
71 | # You should customize this!
72 | print INCFILE "The current temperatures are\n";
73 |
74 | # Run tail -2 /var/log/temperature and parse the output
75 | # The -2 is the number of sensors you have (last 2 lines from logfile)
76 | open( TEMPLOG, "tail -2 $log_file |") || die "Can't fork: $!";
77 |
78 | # Parse the output of the tail program
79 | while( )
80 | {
81 | # Get the time and date, sensor number, temperature in c and f
82 | ($month,$day,$time,$d1,$sensor,$d1,$centigrade,$d1,$fahrenheight) = split( " ", $_ );
83 |
84 | # Print some custom messages for the sensors
85 | # The \xB0 is supposed to be a degree symbol. This works on some systems
86 | # but not on others.
87 | if( $sensor eq '0' )
88 | {
89 | print INCFILE "The modems are at $fahrenheight\xB0 F ($centigrade\xB0 C)
\n";
90 | }
91 |
92 | if( $sensor eq '1' )
93 | {
94 | print INCFILE "The room is a ";
95 |
96 | if( $fahrenheight < 40.0 )
97 | {
98 | print INCFILE "freezing";
99 | }
100 |
101 | if( $fahrenheight >= 40.0 and $fahrenheight < 70.0 )
102 | {
103 | print INCFILE "chilly";
104 | }
105 |
106 | if( $fahrenheight >= 70.0 and $fahrenheight < 80.0 )
107 | {
108 | print INCFILE "comfortable";
109 | }
110 |
111 | if( $fahrenheight >= 80.0 and $fahrenheight < 100.0 )
112 | {
113 | print INCFILE "balmy";
114 | }
115 |
116 | if( $fahrenheight >= 100.0 )
117 | {
118 | print INCFILE "blistering";
119 | }
120 |
121 | print INCFILE " $fahrenheight\xB0 F ($centigrade\xB0 C)
\n";
122 | }
123 | }
124 |
125 | print INCFILE "Last updated: $month $day $time
\n";
126 |
127 | # Blantant advertisement
128 | print INCFILE "These temperatures generated with ";
129 | print INCFILE "";
130 | print INCFILE "DigiTemp
\n";
131 | print INCFILE "
\n";
132 |
133 | close( TEMPLOG );
134 | close( INCFILE );
135 |
136 | # Send it to the server
137 | # Fire up the link
138 | system $ip_up;
139 |
140 | # Wait a little bit to let ppp0 come up
141 | sleep 60;
142 |
143 | # Send it to the server
144 | $ftp = Net::FTP->new($ftp_host);
145 | $ftp->login($ftp_user,$ftp_pass);
146 | $ftp->cwd($dest_dir);
147 | $ftp->binary();
148 | $ftp->put($inc_file);
149 | $ftp->quit;
150 |
151 | # Shut down the link
152 | system $ip_down;
153 |
154 | # done!
155 |
--------------------------------------------------------------------------------
/src/digitemp/python/gui/.digitemprc:
--------------------------------------------------------------------------------
1 | TTY /dev/ttyUSB0
2 | READ_TIME 1000
3 | LOG_TYPE 0
4 | LOG_FORMAT "T %R %N %.2C"
5 | CNT_FORMAT "C %R %N %n %C"
6 | SENSORS 1
7 | ROM 0 0x10 0x4C 0x4D 0x55 0x00 0x08 0x00 0xD9
8 |
--------------------------------------------------------------------------------
/src/digitemp/python/gui/digitemp_gui.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # DigiTemp temperature and 1-wire home weather station graphing
4 | # Copyright 2003 by Brian C. Lane
5 | # http://www.digitemp.com
6 | #
7 | # Requires DigiTemp v3.1.0 or later for counter support
8 | #
9 |
10 | import string, os, sys, time
11 |
12 | timefmt = '%Y-%m-%d %H:%M:%S'
13 |
14 | # 1. Read the output of DigiTemp
15 | cmd = '/home/brian/temperature/digitemp -c/home/brian/temperature/digitemp.cfg -a -q'
16 |
17 | for outline in os.popen(cmd).readlines():
18 | outline = outline[:-1]
19 | # print outline
20 |
21 | if outline[0:1] == 'T':
22 | # Parse the temperature sensor line
23 | S = string.split(outline, " ")
24 | # print S
25 |
26 | # Add the reading to the database
27 | sql = "INSERT INTO temperature VALUES(NULL, %s, %s, %s)"
28 | sqltime = time.strftime( timefmt, time.localtime(int(S[2])))
29 | cursor.execute( sql, (S[1], sqltime, S[3]) );
30 |
31 | if outline[0:1] == 'C':
32 | # Parse the counter line
33 | S = string.split(outline, " ")
34 | # print S
35 |
36 | # Add the reading to the database
37 | sql = "INSERT INTO counter VALUES(NULL, %s, %s, %s, %s)"
38 | sqltime = time.strftime( timefmt, time.localtime(int(S[2])))
39 | cursor.execute( sql, (S[1], sqltime, S[3], S[4]) );
40 |
41 | # -----------------------------------------------------------------------
42 | # Do interesting things with the just-logged information
43 | # =======================================================================
44 | # Brian's Sensor Map:
45 | #
46 | #10E8A00E00000055 Room (grey wire)
47 | #10B95E05000800AA Attic
48 | #10575A050008008F Desk
49 | #22B9B20500000049 DS1822
50 | #286D1D2D000000EA DS18B20 (kermit)
51 | #1092B9330008002E Drink
52 | #1D9CB900000000B3 Rain Gauge
53 | #1DFA15010000005F Wind Speed
54 | #1009212E0008004B DT-1A passive sensor
55 | #
56 |
57 | # Dict of serial numbers and what to name them
58 | sensors = {'10E8A00E00000055':'Office',
59 | '10B95E05000800AA':'Attic',
60 | '10575A050008008F':'Desk',
61 | '22B9B20500000049':'DS1822',
62 | '286D1D2D000000EA':'DS18B20',
63 | '1092B9330008002E':'Drink',
64 | '1009212E0008004B':'DT1A'
65 | }
66 |
67 | counters= {'1D9CB900000000B3':'Rain',
68 | '1DFA15010000005F':'Wind'
69 | }
70 |
71 | def c2f( c ):
72 | f = 32.0 + ((c * 9.0) / 5.0)
73 | return f
74 |
75 |
--------------------------------------------------------------------------------
/src/digitemp/python/gui/dttest.py:
--------------------------------------------------------------------------------
1 | #!/bin/env python
2 |
3 | # Initalize the indicated serial port and continuously read the temperatures
4 | # and graph them in a window. Show the discovered sensors and allow the user
5 | # to select the color associated with it.
6 | # Also allow them to control the refresh rate.
7 |
8 | """ DigiTemp PyGTK Graph display """
9 |
10 | import string, os, sys, time, gtk
11 |
12 |
13 | dt = {}
14 |
15 | # Initalize the 1-wire network, print out whatever it says
16 | def init_1wire():
17 | cmd = "digitemp -i -q -o\"T %R %N %.2C\" -O\"C %R %N %n %C\""
18 | for outline in os.popen(cmd).readlines()
19 | outline = outline[:-1];
20 | print outline
21 |
22 | # Ought to be able to check return code for success/failure
23 |
24 |
25 | # Read all attached sensors
26 | def read_sensors():
27 | cmd = "digitemp -a -q -o1"
28 | for outline in os.popen(cmd).readlines():
29 | outline = outline[:-1]
30 | S = string.split( outline, " " )
31 |
32 | if S[0] == 'T':
33 | # Add the temperature reading to a dictionary
34 | dt[S[1]] = S[3]
35 |
36 | if S[0] == 'C':
37 | # Add the counter reading to a dictionary
38 | dt[S[1]] = S[3]
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/digitemp/python/mysql/README:
--------------------------------------------------------------------------------
1 | This script is pretty rough at the moment. I haven't made any attempt to
2 | clean it up and make it more user friendly yet. But it does work if you're
3 | willing to take the time to tweak it. It reads temps, logs them to a MySQL
4 | database named weather as a user named weather, logs the data to a RRD and
5 | writes a new sigfile.
6 |
7 | Requirements are:
8 | DigiTemp v3.1.x+ http://www.digitemp.com
9 | MySQL database http://www.mysql.org
10 | Round Robin Database http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/
11 | Python MySQLdb module http://www.mysql.com/downloads/api-python.html
12 |
13 | If you find any problems, let me know. I may have forgotten something.
14 |
15 | The windspeed calculation isn't correct. I'm still working on graphs that
16 | are based on the MySQL database data.
17 |
18 |
--------------------------------------------------------------------------------
/src/digitemp/python/mysql/make_rain_rrd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | /usr/local/rrdtool/bin/rrdtool create rain.rrd \
4 | DS:Rain:COUNTER:600:U:U \
5 | RRA:AVERAGE:0.5:1:600 \
6 | RRA:AVERAGE:0.5:6:700 \
7 | RRA:AVERAGE:0.5:24:775 \
8 | RRA:AVERAGE:0.5:288:797 \
9 | RRA:MAX:0.5:1:600 \
10 | RRA:MAX:0.5:6:700 \
11 | RRA:MAX:0.5:24:775 \
12 | RRA:MAX:0.5:288:797
13 |
--------------------------------------------------------------------------------
/src/digitemp/python/mysql/make_sensor_rrd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | /usr/local/rrdtool/bin/rrdtool create sensor.rrd \
4 | DS:Temperature:GAUGE:600:U:U \
5 | RRA:AVERAGE:0.5:1:600 \
6 | RRA:AVERAGE:0.5:6:700 \
7 | RRA:AVERAGE:0.5:24:775 \
8 | RRA:AVERAGE:0.5:288:797 \
9 | RRA:MAX:0.5:1:600 \
10 | RRA:MAX:0.5:6:700 \
11 | RRA:MAX:0.5:24:775 \
12 | RRA:MAX:0.5:288:797 \
13 | RRA:MIN:0.5:1:600 \
14 | RRA:MIN:0.5:6:700 \
15 | RRA:MIN:0.5:24:775 \
16 | RRA:MIN:0.5:288:797
17 |
--------------------------------------------------------------------------------
/src/digitemp/python/mysql/make_wind_rrd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | /usr/local/rrdtool/bin/rrdtool create wind.rrd \
4 | DS:WindSpeed:DERIVE:600:0:U \
5 | RRA:AVERAGE:0.5:1:600 \
6 | RRA:AVERAGE:0.5:6:700 \
7 | RRA:AVERAGE:0.5:24:775 \
8 | RRA:AVERAGE:0.5:288:797 \
9 | RRA:MAX:0.5:1:600 \
10 | RRA:MAX:0.5:6:700 \
11 | RRA:MAX:0.5:24:775 \
12 | RRA:MAX:0.5:288:797
13 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/README:
--------------------------------------------------------------------------------
1 | DigiTemp v2.4 rrdb scripts
2 | Copyright 1999-2002 by Brian C. Lane www.brianlane.com
3 | All Rights Reserved
4 |
5 | The Round Robin Database is a great way to store data that you want to
6 | graph. You can get it from:
7 | http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/
8 |
9 | log_temps calls digitemp and adds the current temperature readings to the
10 | RRD database. It should be called from a crontab at regular intervals.
11 |
12 | log-temperature.pl is a Perl script that runs digitemp and inserts the
13 | new samples into the RRDB, optionally it can create a text file for use
14 | in an email signature.
15 |
16 | make_temps creates a RRD database suitable for logging 3 sensors of data.
17 |
18 | temp-all.cgi
19 | temp-one.cgi are scripts to generate .png graphs of temperature data.
20 | Insert them into your webpage with:
21 |
22 | temp-minmax.cgi generates a graph with minimum and maximum printed on the
23 | graph.
24 |
25 | The suggested initialization sets up digitemp to output the temperature in
26 | Centigrade and the conversion to Fahrenheit. The -o option passed to
27 | digitemp when it is initalized controls how the temperature is output.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/log-temperature.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp v2.3 RRDB Temperature logger
4 | #
5 | # Copyright 1997-2002 by Brian C. Lane www.brianlane.com
6 | # All Rights Reserved
7 | #
8 | # This program is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License as published by the Free
10 | # Software Foundation; either version 2 of the License, or (at your option)
11 | # any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but WITHOUT
14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 | # more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 | #
22 |
23 | # This require the RRDB pipe module for Perl, available with the RRDB source
24 | # from http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/
25 | use RRDp;
26 |
27 | # Convert centigrade to fahrenheit
28 | sub ctof
29 | {
30 | ($temp_c) = @_;
31 |
32 | return 32 + (($temp_c * 9)/5);
33 | }
34 |
35 |
36 |
37 | # Find the RRD executable, look in the standard locations
38 | # If your rrdtool is installed someplace else, fill in the proper location
39 | # below:
40 | if ( -x "/usr/bin/rrdtool")
41 | {
42 | RRDp::start "/usr/bin/rrdtool";
43 | } elsif ( -x "/usr/local/bin/rrdtool") {
44 | RRDp::start "/usr/local/bin/rrdtool";
45 | } elsif ( -x "/usr/local/rrdtool/bin/rrdtool" ) {
46 | RRDp::start "/usr/local/rrdtool/bin/rrdtool";
47 | } else {
48 | die "Could not find rrdtool binary\n";
49 | }
50 |
51 | # The RRD database to put the data into
52 | $wx_rrd = "/tmp/digitemp.rrd";
53 |
54 | # Read the output from digitemp
55 | # Output in form 0\troom\tattic\tdrink
56 | open( DIGITEMP, "digitemp -a -q -o2 |" );
57 |
58 | while( )
59 | {
60 | # print "$_\n";
61 | chomp;
62 |
63 | if( $_ =~ /^nanosleep/i )
64 | {
65 | $now = localtime;
66 | open( ERRLOG, ">>/tmp/dt-error") or die "Error opening dt-error";
67 | print ERRLOG "nanosleep error at $now\n";
68 | close( ERRLOG );
69 | die "nanosleep error";
70 | } else {
71 |
72 | ($null,$desk_DS18S20,$attic_DS18S20,$room) = split(/\t/);
73 | }
74 | }
75 |
76 | close( DIGITEMP );
77 |
78 | # Put the info into the weather rrd database room:drink:attic
79 | RRDp::cmd "update $wx_rrd N:$room:$attic_DS18S20:$desk_DS18S20";
80 | #$answer=RRDp::read;
81 |
82 |
83 |
84 | # This section was used to create up to date email signature files
85 |
86 | # Create the email header in Fahrenheit
87 | #open( HEADER, ">/tmp/.header") or die "Error opening .header";
88 |
89 | #$now = localtime;
90 | #print HEADER "[$now]--[Inside ";
91 | #printf HEADER "%0.2f",ctof( $room );
92 | #print HEADER "F]--[Outside ";
93 | #printf HEADER "%0.2f",ctof( $attic_DS18S20 );
94 | #print HEADER"F]--[Drink ";
95 | #printf HEADER "%0.2f",ctof( $desk_DS18S20 );
96 | #print HEADER "F]--\n";
97 | #close( HEADER );
98 |
99 | exit;
100 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/log_temp:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # DigiTemp RRD logging script
4 | # Copyright 1997-2002 by Brian C. Lane www.brianlane.com
5 | # All Rights Reserved
6 | #
7 | # This program is free software; you can redistribute it and/or modify it
8 | # under the terms of the GNU General Public License as published by the Free
9 | # Software Foundation; either version 2 of the License, or (at your option)
10 | # any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but WITHOUT
13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 | # more details.
16 | #
17 | # You should have received a copy of the GNU General Public License along
18 | # with this program; if not, write to the Free Software Foundation, Inc.,
19 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 | #
21 |
22 | # Call this from crontab every 5 minutes. Make sure the .digitemprc is in
23 | # your root directory or specify the configuration file using -c filename
24 | # on the digitemp command line in the reading variable below.
25 |
26 | # Get the current temperatures, digitemp has been previously initalized with
27 | # digitemp -i -s /dev/ttyS0 -o2 -a
28 |
29 | # Run it in quiet mode, output is 0\tsensor#1\tsensor#2\tsensor#3
30 | reading=`/usr/local/bin/digitemp -a -q`
31 |
32 | # Diagnostic output
33 | room=`echo $reading | gawk '{print $2}'`
34 | attic=`echo $reading | gawk '{print $3}'`
35 | drink=`echo $reading | gawk '{print $4}'`
36 |
37 | # Update the database
38 | /usr/local/rrdtool/bin/rrdtool update /root/rrdb/digitemp.rrd N:$room:$drink:$attic
39 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/make_temps:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp v2.1 RRDB database Creation
4 | #
5 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
6 | # All Rights Reserved
7 | #
8 | # This program is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License as published by the Free
10 | # Software Foundation; either version 2 of the License, or (at your option)
11 | # any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but WITHOUT
14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 | # more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 |
22 | use Time::Local;
23 | use RRDp;
24 |
25 | RRDp::start "/usr/local/rrdtool/bin/rrdtool";
26 |
27 | # Create the database
28 |
29 | RRDp::cmd "create digitemp.rrd \
30 | DS:room:GAUGE:600:U:U \
31 | DS:attic:GAUGE:600:U:U \
32 | DS:desk:GAUGE:600:U:U \
33 | RRA:AVERAGE:0.5:1:600 \
34 | RRA:AVERAGE:0.5:6:700 \
35 | RRA:AVERAGE:0.5:24:775 \
36 | RRA:AVERAGE:0.5:288:797 \
37 | RRA:MIN:0.5:1:600 \
38 | RRA:MIN:0.5:6:700 \
39 | RRA:MIN:0.5:24:775 \
40 | RRA:MIN:0.5:288:797 \
41 | RRA:MAX:0.5:1:600 \
42 | RRA:MAX:0.5:6:700 \
43 | RRA:MAX:0.5:24:775 \
44 | RRA:MAX:0.5:288:797";
45 |
46 | $answer = RRDp::read;
47 | #print $$answer;
48 |
49 | RRDp::end;
50 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/temp-all.cgi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp v2.1 RRDB Temperature Graph
4 | #
5 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
6 | # All Rights Reserved
7 | #
8 | # This program is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License as published by the Free
10 | # Software Foundation; either version 2 of the License, or (at your option)
11 | # any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but WITHOUT
14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 | # more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 | #
22 |
23 | # REQUIRES:
24 | # RRD tool binary
25 | # CGI (comes with perl5)
26 |
27 | use RRDp;
28 | use CGI;
29 |
30 | $cgi = new CGI; # Load the CGI routines
31 |
32 | # Find the RRD executable, look in the standard locations
33 | # If your rrdtool is installed someplace else, fill in the proper location
34 | # below:
35 | if ( -x "/usr/bin/rrdtool")
36 | {
37 | RRDp::start "/usr/bin/rrdtool";
38 | } elsif ( -x "/usr/local/bin/rrdtool") {
39 | RRDp::start "/usr/local/bin/rrdtool";
40 | } elsif ( -x "/usr/local/rrdtool/bin/rrdtool" ) {
41 | RRDp::start "/usr/local/rrdtool/bin/rrdtool";
42 | } else {
43 | die "Could not find rrdtool binary\n";
44 | }
45 |
46 | # The RRD database to get the data from
47 | $rrd = "/tmp/digitemp.rrd";
48 |
49 |
50 | # Make the variables easier to use and assign defaults if not set
51 | if( !$cgi->param('starttime') )
52 | {
53 | $starttime = "-1day";
54 | } else {
55 | $starttime = $cgi->param('starttime');
56 | }
57 | if( !$cgi->param('endtime') )
58 | {
59 | $endtime = time;
60 | } else {
61 | $endtime = $cgi->param('endtime');
62 | }
63 | if( !$cgi->param('width') )
64 | {
65 | $width = "400";
66 | } else {
67 | $width = $cgi->param('width');
68 | }
69 | if( !$cgi->param('height') )
70 | {
71 | $height = "100";
72 | } else {
73 | $height = $cgi->param('height');
74 | }
75 | if( !$cgi->param('label') )
76 | {
77 | $label="";
78 | } else {
79 | $label = $cgi->param('label');
80 | }
81 | $var = $cgi->param('var');
82 |
83 | # Diagnostic output
84 | #print STDERR "start = $starttime\n";
85 | #print STDERR "end = $endtime\n";
86 | #print STDERR "width = $width\n";
87 | #print STDERR "height = $height\n";
88 | #print STDERR "var = $var\n";
89 | #print STDERR "label = $label\n";
90 |
91 |
92 | # Output a HTML header for the PNG image to follow
93 | print $cgi->header('image/png');
94 |
95 | # Generate the graph
96 | RRDp::cmd "graph - --imgformat PNG",
97 | "--start '$starttime' --end '$endtime'",
98 | "--width $width --height $height",
99 | "DEF:room_c=$rrd:room:AVERAGE",
100 | "DEF:attic_c=$rrd:attic:AVERAGE",
101 | "DEF:desk_c=$rrd:desk:AVERAGE",
102 | "CDEF:room_f=room_c,9,*,5,/,32,+",
103 | "CDEF:attic_f=attic_c,9,*,5,/,32,+",
104 | "CDEF:desk_f=drink_c,9,*,5,/,32,+",
105 | "LINE1:room_f#00FF00:'Computer Room'",
106 | "LINE1:attic_f#FF0000:'Attic'",
107 | "LINE1:desk_f#0000FF:'Desk'";
108 |
109 | $answer=RRDp::read;
110 |
111 | print $$answer;
112 |
113 | RRDp::end;
114 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/temp-minmax.cgi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp v2.1 RRDB Temperature Graph with Min/Max
4 | #
5 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
6 | # All Rights Reserved
7 | #
8 | # This program is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License as published by the Free
10 | # Software Foundation; either version 2 of the License, or (at your option)
11 | # any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but WITHOUT
14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 | # more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 |
22 | # REQUIRES:
23 | # RRD tool binary
24 | # CGI (comes with perl5)
25 |
26 | use RRDp;
27 | use CGI;
28 |
29 | $cgi = new CGI; # Load the CGI routines
30 |
31 | # Find the RRD executable, look in the standard locations
32 | # If your rrdtool is installed someplace else, fill in the proper location
33 | # below:
34 | if ( -x "/usr/bin/rrdtool")
35 | {
36 | RRDp::start "/usr/bin/rrdtool";
37 | } elsif ( -x "/usr/local/bin/rrdtool") {
38 | RRDp::start "/usr/local/bin/rrdtool";
39 | } elsif ( -x "/usr/local/rrdtool/bin/rrdtool" ) {
40 | RRDp::start "/usr/local/rrdtool/bin/rrdtool";
41 | } else {
42 | die "Could not find rrdtool binary\n";
43 | }
44 |
45 | # The RRD database to get the data from
46 | $rrd = "/tmp/digitemp.rrd";
47 |
48 |
49 | # Make the variables easier to use and assign defaults if not set
50 | if( !$cgi->param('starttime') )
51 | {
52 | $starttime = "-1day";
53 | } else {
54 | $starttime = $cgi->param('starttime');
55 | }
56 | if( !$cgi->param('endtime') )
57 | {
58 | $endtime = time;
59 | } else {
60 | $endtime = $cgi->param('endtime');
61 | }
62 | if( !$cgi->param('width') )
63 | {
64 | $width = "400";
65 | } else {
66 | $width = $cgi->param('width');
67 | }
68 | if( !$cgi->param('height') )
69 | {
70 | $height = "100";
71 | } else {
72 | $height = $cgi->param('height');
73 | }
74 | if( !$cgi->param('label') )
75 | {
76 | $label="";
77 | } else {
78 | $label = $cgi->param('label');
79 | }
80 | $var = $cgi->param('var');
81 |
82 | # Diagnostic output
83 | #print STDERR "start = $starttime\n";
84 | #print STDERR "end = $endtime\n";
85 | #print STDERR "width = $width\n";
86 | #print STDERR "height = $height\n";
87 | #print STDERR "var = $var\n";
88 | #print STDERR "label = $label\n";
89 |
90 | RRDp::cmd "last $rrd";
91 | $lastupdate = RRDp::read;
92 |
93 | # Output a HTML header for the PNG image to follow
94 | print $cgi->header('image/png');
95 |
96 | # Generate the graph
97 | RRDp::cmd "graph - --imgformat PNG",
98 | "--start '$starttime' --end '$endtime'",
99 | "--width $width --height $height",
100 | "DEF:room_c=$rrd:room:AVERAGE",
101 | "DEF:attic_c=$rrd:attic:AVERAGE",
102 | "DEF:desk__c=$rrd:desk:AVERAGE",
103 | "CDEF:room_f=room_c,9,*,5,/,32,+",
104 | "CDEF:attic_f=attic_c,9,*,5,/,32,+",
105 | "CDEF:desk_f=desk_c,9,*,5,/,32,+",
106 | "COMMENT:\" \"",
107 | "COMMENT:\" Min Max Avg Last\\n\"",
108 | "COMMENT:\" \"",
109 | "GPRINT:attic_f:MIN:\"Attic %5.2lf F\"",
110 | "GPRINT:attic_f:MAX:\" %5.2lf F\"",
111 | "GPRINT:attic_f:AVERAGE:\" %5.2lf F\"",
112 | "GPRINT:attic_f:LAST:\" %5.2lf F\\n\"",
113 | "COMMENT:\" \"",
114 | "GPRINT:room_f:MIN:\"Room %5.2lf F\"",
115 | "GPRINT:room_f:MAX:\" %5.2lf F\"",
116 | "GPRINT:room_f:AVERAGE:\" %5.2lf F\"",
117 | "GPRINT:room_f:LAST:\" %5.2lf F\\n\"",
118 | "COMMENT:\" \"",
119 | "GPRINT:desk_f:MIN:\"Desk %5.2lf F\"",
120 | "GPRINT:desk_f:MAX:\" %5.2lf F\"",
121 | "GPRINT:desk_f:AVERAGE:\" %5.2lf F\"",
122 | "GPRINT:desk_f:LAST:\" %5.2lf F\\n\"",
123 | "COMMENT:\"\\s\"",
124 | "LINE1:room_f#FF8000:'Computer Room'",
125 | "LINE1:attic_DS18S20_f#8080F0:'Attic'",
126 | "LINE2:desk_DS18S20_f#008000:'Desk\\c'",
127 | "COMMENT:\"Last Updated ". localtime($$lastupdate) . "\\c\"";
128 |
129 | $answer=RRDp::read;
130 |
131 | print $$answer;
132 |
133 | RRDp::end;
134 |
--------------------------------------------------------------------------------
/src/digitemp/rrdb/temp-one.cgi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 | #
3 | # DigiTemp v2.1 RRDB Temperature Graph (single sensor)
4 | #
5 | # Copyright 1997-2001 by Brian C. Lane www.brianlane.com
6 | # All Rights Reserved
7 | #
8 | # This program is free software; you can redistribute it and/or modify it
9 | # under the terms of the GNU General Public License as published by the Free
10 | # Software Foundation; either version 2 of the License, or (at your option)
11 | # any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but WITHOUT
14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 | # more details.
17 | #
18 | # You should have received a copy of the GNU General Public License along
19 | # with this program; if not, write to the Free Software Foundation, Inc.,
20 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 | #
22 |
23 | # REQUIRES:
24 | # RRD tool binary
25 | # CGI (comes with perl5)
26 |
27 | use RRDp;
28 | use CGI;
29 |
30 | $cgi = new CGI; # Load the CGI routines
31 |
32 | # Find the RRD executable, look in the standard locations
33 | # If your rrdtool is installed someplace else, fill in the proper location
34 | # below:
35 | if ( -x "/usr/bin/rrdtool")
36 | {
37 | RRDp::start "/usr/bin/rrdtool";
38 | } elsif ( -x "/usr/local/bin/rrdtool") {
39 | RRDp::start "/usr/local/bin/rrdtool";
40 | } elsif ( -x "/usr/local/rrdtool/bin/rrdtool" ) {
41 | RRDp::start "/usr/local/rrdtool/bin/rrdtool";
42 | } else {
43 | die "Could not find rrdtool binary\n";
44 | }
45 |
46 | # The RRD database to get the data from
47 | $rrd = "/tmp/digitemp.rrd";
48 |
49 |
50 | # Make the variables easier to use and assign defaults if not set
51 | if( !$cgi->param('starttime') )
52 | {
53 | $starttime = "-1day";
54 | } else {
55 | $starttime = $cgi->param('starttime');
56 | }
57 | if( !$cgi->param('endtime') )
58 | {
59 | $endtime = time;
60 | } else {
61 | $endtime = $cgi->param('endtime');
62 | }
63 | if( !$cgi->param('width') )
64 | {
65 | $width = "400";
66 | } else {
67 | $width = $cgi->param('width');
68 | }
69 | if( !$cgi->param('height') )
70 | {
71 | $height = "100";
72 | } else {
73 | $height = $cgi->param('height');
74 | }
75 | if( !$cgi->param('label') )
76 | {
77 | $label="";
78 | } else {
79 | $label = $cgi->param('label');
80 | }
81 | $var = $cgi->param('var');
82 |
83 | if( !$cgi->param('color') )
84 | {
85 | $color = "#000000";
86 | } else {
87 | $color = $cgi->param('color');
88 | }
89 |
90 | # Diagnostic output
91 | #print STDERR "start = $starttime\n";
92 | #print STDERR "end = $endtime\n";
93 | #print STDERR "width = $width\n";
94 | #print STDERR "height = $height\n";
95 | #print STDERR "var = $var\n";
96 | #print STDERR "label = $label\n";
97 | #print STDERR "color = $color\n";
98 |
99 |
100 | # Output a HTML header for the PNG image to follow
101 | print $cgi->header('image/png');
102 |
103 | # Generate the graph
104 | RRDp::cmd "graph - --imgformat PNG",
105 | "--start '$starttime' --end '$endtime'",
106 | "--width $width --height $height",
107 | "DEF:temp_c=$rrd:$var:AVERAGE",
108 | "CDEF:temp_f=temp_c,9,*,5,/,32,+",
109 | "LINE1:temp_f$color:'$label'";
110 |
111 | $answer=RRDp::read;
112 |
113 | print $$answer;
114 |
115 | RRDp::end;
116 |
--------------------------------------------------------------------------------
/src/digitemp/src/device_name.h:
--------------------------------------------------------------------------------
1 | /* ------------------------------------------------------------------------
2 | DigiTemp
3 |
4 | Copyright 1996-2005 by Brian C. Lane
5 | All Rights Reserved
6 |
7 | This program is free software; you can redistribute it and/or modify it
8 | under the terms of the GNU General Public License as published by the Free
9 | Software Foundation; either version 2 of the License, or (at your option)
10 | any later version.
11 |
12 | This program is distributed in the hope that it will be useful, but WITHOUT
13 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 | more details.
16 |
17 | You should have received a copy of the GNU General Public License along
18 | with this program; if not, write to the Free Software Foundation, Inc.,
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 | ------------------------------------------------------------------------ */
21 | char *device_name( unsigned int family );
22 |
23 |
--------------------------------------------------------------------------------
/src/digitemp/src/ds2438.c:
--------------------------------------------------------------------------------
1 | /* -----------------------------------------------------------------------
2 | DS2438 routines
3 | Copyright 2007 by Brian C. Lane
4 | All Rights Reserved
5 | Licensed under GPL v2
6 | ----------------------------------------------------------------------- */
7 | #include
8 | #include "ownet.h"
9 | #include "ad26.h"
10 |
11 | extern int owBlock(int,int,uchar *,int);
12 | extern void setcrc8(int,uchar);
13 | extern uchar docrc8(int,uchar);
14 | extern int owReadByte(int);
15 | extern int owWriteByte(int,int);
16 | extern void output_status(int, char *);
17 | extern void msDelay(int);
18 | extern void owSerialNum(int,uchar *,int);
19 | extern int owAccess(int);
20 |
21 |
22 | /* -----------------------------------------------------------------------
23 | ----------------------------------------------------------------------- */
24 | int get_ibl_type(int portnum, uchar page, int offset)
25 | {
26 | uchar send_block[50];
27 | int send_cnt=0;
28 | int i;
29 | ushort lastcrc8=255;
30 |
31 | /* 01/08/2004 [bcl] DigiTemp does this before calling the function
32 | * owSerialNum(portnum,SNum,FALSE);
33 | */
34 |
35 | // Recall the Status/Configuration page
36 | // Recall command
37 | send_block[send_cnt++] = 0xB8;
38 |
39 | // Page to Recall
40 | send_block[send_cnt++] = page;
41 |
42 | if(!owBlock(portnum,FALSE,send_block,send_cnt))
43 | return FALSE;
44 |
45 | send_cnt = 0;
46 |
47 | if(owAccess(portnum))
48 | {
49 | // Read the Status/Configuration byte
50 | // Read scratchpad command
51 | send_block[send_cnt++] = 0xBE;
52 |
53 | // Page for the Status/Configuration byte
54 | send_block[send_cnt++] = page;
55 |
56 | for(i=0;i<9;i++)
57 | send_block[send_cnt++] = 0xFF;
58 |
59 | if(owBlock(portnum,FALSE,send_block,send_cnt))
60 | {
61 | setcrc8(portnum,0);
62 |
63 | for(i=2;i> 8);
89 | docrc16(portnum,(ushort)(address >> 8));
90 | // now add the read bytes for data byte,counter,zero bits, crc16
91 | for (i = 0; i < 11; i++)
92 | send_block[send_cnt++] = 0xFF;
93 |
94 | // now send the block
95 | if (owBlock(portnum,FALSE,send_block,send_cnt))
96 | {
97 | // perform the CRC16 on the last 11 bytes of packet
98 | for (i = send_cnt - 11; i < send_cnt; i++)
99 | lastcrc16 = docrc16(portnum,send_block[i]);
100 |
101 | // verify CRC16 is correct
102 | if (lastcrc16 == 0xB001)
103 | {
104 | // success
105 | rt = TRUE;
106 | // extract the counter value
107 | *Count = 0;
108 | for (i = send_cnt - 7; i >= send_cnt - 10; i--)
109 | {
110 | *Count <<= 8;
111 | *Count |= send_block[i];
112 | }
113 | }
114 | }
115 | }
116 |
117 | // return the result flag rt
118 | return rt;
119 | }
120 |
--------------------------------------------------------------------------------
/src/digitemp/userial/ds2490/usblnk.h:
--------------------------------------------------------------------------------
1 |
2 | #define CONTROL_CMD 0x00
3 | #define COMM_CMD 0x01
4 | #define MODE_CMD 0x02
5 | #define TEST_CMD 0x03
6 |
7 | #define CTL_RESET_DEVICE 0x0000
8 | #define CTL_START_EXE 0x0001
9 | #define CTL_RESUME_EXE 0x0002
10 | #define CTL_HALT_EXE_IDLE 0x0003
11 | #define CTL_HALT_EXE_DONE 0x0004
12 | #define CTL_FLUSH_COMM_CMDS 0x0007
13 | #define CTL_FLUSH_CV_BUFFER 0x0008
14 | #define CTL_FLUSH_CMT_BUFFER 0x0009
15 | #define CTL_GET_COMM_CMDS 0x000A
16 |
17 | #define MOD_PULSE_EN 0x0000
18 | #define MOD_SPEED_CHANGE_EN 0x0001
19 | #define MOD_1WIRE_SPEED 0x0002
20 | #define MOD_STRONG_PU_DURATION 0x0003
21 | #define MOD_PULLDOWN_SLEWRATE 0x0004
22 | #define MOD_PROG_PULSE_DURATION 0x0005
23 | #define MOD_WRITE1_LOWTIME 0x0006
24 | #define MOD_DSOW0_TREC 0x0007
25 |
26 |
--------------------------------------------------------------------------------
/src/digitemp/userial/ds9097/linuxses.c:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2003, Erik Rigtorp
2 | * All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | * 3. Neither the name of Erik Rigtorp nor the names of his contributors
13 | * may be used to endorse or promote products derived from this software
14 | * without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 | * SUCH DAMAGE.
27 | *
28 | *
29 | * linuxses.c (0.20)
30 | *
31 | * * Cleaned up everything.
32 | *
33 | * * Added printing of error messages.
34 | *
35 | * -- Erik Rigtorp Thu, 05 Jun 2003 00:57:44 +0200
36 | */
37 |
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | /* local function prototypes */
44 | SMALLINT owAcquire(int,char *);
45 | void owRelease(int);
46 |
47 |
48 | int fd[MAX_PORTNUM]; /* a list of filedescriptors for serial ports */
49 | struct termios term[MAX_PORTNUM]; /* Current termios settings */
50 | struct termios term_orig[MAX_PORTNUM]; /* backup termios settings */
51 |
52 |
53 | /* Attempt to acquire a 1-Wire net. Associate 'portnum' with the serial port
54 | * with name 'port_zstr'. Returns TRUE on success. */
55 | SMALLINT owAcquire(int portnum, char *port_zstr)
56 | {
57 | /* Open the serial port */
58 | if ((fd[portnum] = open(port_zstr, O_RDWR)) == -1)
59 | {
60 | OWERROR(OWERROR_GET_SYSTEM_RESOURCE_FAILED);
61 | perror("owAcquire: failed to open device");
62 | return FALSE;
63 | }
64 |
65 | /* Get device settings */
66 | if(tcgetattr(fd[portnum], &term[portnum] ) < 0 )
67 | {
68 | OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
69 | perror("owAcquire: failed to set attributes");
70 | close(fd[portnum]);
71 | return FALSE;
72 | }
73 |
74 | /* Save a backup */
75 | term_orig[portnum] = term[portnum];
76 |
77 | /* Reset all settings */
78 | term[portnum].c_iflag = 0;
79 | term[portnum].c_oflag = 0;
80 | term[portnum].c_lflag = 0;
81 | term[portnum].c_cflag = 0;
82 |
83 | /* 1 byte at a time, no timer */
84 | term[portnum].c_cc[VMIN] = 1;
85 | term[portnum].c_cc[VTIME] = 0;
86 |
87 | /* 6 data bits, Receiver enabled, Hangup, Dont change "owner" */
88 | term[portnum].c_cflag |= CS6 | CREAD | HUPCL | CLOCAL;
89 |
90 | /* Set input and output speed to 115.2k */
91 | cfsetispeed(&term[portnum], B115200);
92 | cfsetospeed(&term[portnum], B115200);
93 |
94 | /* set the attributes */
95 | if(tcsetattr(fd[portnum], TCSANOW, &term[portnum]) < 0 )
96 | {
97 | OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
98 | perror("owAcquire: failed to set attributes");
99 | close(fd[portnum]);
100 | return FALSE;
101 | }
102 |
103 | /* Flush the input and output buffers */
104 | tcflush(fd[portnum], TCIOFLUSH);
105 |
106 | return TRUE;
107 | }
108 |
109 | /* Release port 'portnum' */
110 | void owRelease(int portnum)
111 | {
112 | /* Restore original settings */
113 | if(tcsetattr(fd[portnum], TCSANOW, &term_orig[portnum]) < 0 )
114 | {
115 | /* We failed doing that */
116 | OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
117 | perror("owAcquire: failed to set attributes");
118 | close(fd[portnum]);
119 | }
120 |
121 | /* Close the port */
122 | if (close(fd[portnum]) < 0)
123 | {
124 | /* We failed closing the port */
125 | OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED);
126 | perror("owAcquire: failed to close port");
127 | }
128 |
129 | /* we should return an error condition here but MAXIMS API is
130 | * badly designed */
131 | }
132 |
133 |
134 |
--------------------------------------------------------------------------------
/src/digitemp/userial/ds9097u/owsesu.c:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------
2 | // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included
12 | // in all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 | // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
18 | // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 | // OTHER DEALINGS IN THE SOFTWARE.
21 | //
22 | // Except as contained in this notice, the name of Dallas Semiconductor
23 | // shall not be used except as stated in the Dallas Semiconductor
24 | // Branding Policy.
25 | //---------------------------------------------------------------------------
26 | //
27 | // owSesU.C - Acquire and release a Session on the 1-Wire Net.
28 | //
29 | // Version: 2.01
30 | //
31 | // History: 1.03 -> 2.00 Changed 'MLan' to 'ow'. Added support for
32 | // multiple ports.
33 | // 2.00 -> 2.01 Added error handling. Added circular-include check.
34 | // 2.01 -> 2.10 Added raw memory error handling and SMALLINT
35 | // 2.10 -> 3.00 Added memory bank functionality
36 | // Added file I/O operations
37 | //
38 |
39 | #include "ownet.h"
40 |
41 | // external functions defined in system specific link file
42 | extern SMALLINT OpenCOM(int,char *);
43 | extern void CloseCOM(int);
44 |
45 | // external functions defined in ds248ut.c
46 | extern SMALLINT DS2480Detect(int);
47 |
48 | // exportable functions defined in owsesu.c
49 | SMALLINT owAcquire(int,char *);
50 | void owRelease(int);
51 |
52 | //---------------------------------------------------------------------------
53 | // Attempt to acquire a 1-Wire net using a com port and a DS2480 based
54 | // adapter.
55 | //
56 | // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
57 | // OpenCOM to indicate the port number.
58 | // 'port_zstr' - zero terminated port name. For this platform
59 | // use format COMX where X is the port number.
60 | //
61 | // Returns: TRUE - success, COM port opened
62 | //
63 | // exportable functions defined in ownetu.c
64 | SMALLINT owAcquire(int portnum, char *port_zstr)
65 | {
66 | // attempt to open the communications port
67 | if (!OpenCOM(portnum,port_zstr))
68 | {
69 | OWERROR(OWERROR_OPENCOM_FAILED);
70 | return FALSE;
71 | }
72 |
73 | // detect DS2480
74 | if (!DS2480Detect(portnum))
75 | {
76 | CloseCOM(portnum);
77 | OWERROR(OWERROR_DS2480_NOT_DETECTED);
78 | return FALSE;
79 | }
80 |
81 | return TRUE;
82 | }
83 |
84 | //---------------------------------------------------------------------------
85 | // Release the previously acquired a 1-Wire net.
86 | //
87 | // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
88 | // OpenCOM to indicate the port number.
89 | //
90 | void owRelease(int portnum)
91 | {
92 | CloseCOM(portnum);
93 | }
94 |
--------------------------------------------------------------------------------
/src/digitemp/userial/owproto.h:
--------------------------------------------------------------------------------
1 | /* Prototypes for userial driver functions */
2 |
3 | /* From other low level userial files */
4 | SMALLINT owAccess(int);
5 |
6 | #ifndef OWUSB
7 | SMALLINT owAcquire(int,char *);
8 | #else
9 | SMALLINT owAcquire(int,char *, char *);
10 | #endif /* OWUSB */
11 |
12 | void owSerialNum(int,uchar *,SMALLINT);
13 | SMALLINT owWriteBytePower(int,SMALLINT);
14 | SMALLINT owWriteByte(int,SMALLINT);
15 | SMALLINT owReadByte(int);
16 | SMALLINT owLevel(int,SMALLINT);
17 | void msDelay(int);
18 | SMALLINT owBlock(int,SMALLINT,uchar *,SMALLINT);
19 | SMALLINT owTouchReset(int);
20 |
21 | #ifndef OWUSB
22 | void owRelease(int);
23 | #else
24 | void owRelease(int, char *);
25 | #endif /* OWUSB */
26 |
27 | SMALLINT owFirst(int,SMALLINT,SMALLINT);
28 | SMALLINT owNext(int,SMALLINT,SMALLINT);
29 |
30 |
31 | /* From owerr.c */
32 | int owGetErrorNum(void);
33 | void owClearError(void);
34 | int owHasErrors(void);
35 | #ifdef DEBUG
36 | void owRaiseError(int,int,char*);
37 | #else
38 | void owRaiseError(int);
39 | #endif
40 | #ifndef SMALL_MEMORY_TARGET
41 | void owPrintErrorMsg(FILE *);
42 | void owPrintErrorMsgStd();
43 | char *owGetErrorMsg(int);
44 | #endif
45 |
46 |
47 |
48 | /* From ioutil.c */
49 | int EnterString(char *, char *, int, int);
50 | int EnterNum(char *, int, long *, long, long);
51 | int EnterHex(char *, int, ulong *);
52 | int ToHex(char ch);
53 | int getkeystroke(void);
54 | int key_abort(void);
55 | void ExitProg(char *, int);
56 | int getData(uchar*, int, SMALLINT);
57 | void PrintHex(uchar*, int);
58 | void PrintChars(uchar*, int);
59 | void PrintSerialNum(uchar*);
60 |
61 |
62 | /* From crcutil.c */
63 | void setcrc16(int,ushort);
64 | ushort docrc16(int,ushort);
65 | void setcrc8(int,uchar);
66 | uchar docrc8(int,uchar);
67 |
68 |
69 | /* From swt1f.c */
70 | int SetSwitch1F(int,uchar *,int,int,uchar *,int);
71 | int SwitchStateToString1F(int, char *);
72 | int FindBranchDevice(int,uchar *,uchar BranchSN[][8],int,int);
73 | int owBranchFirst(int,uchar *,int,int);
74 | int owBranchNext(int,uchar *,int,int);
75 |
76 | /* From cnt1d.c */
77 | SMALLINT ReadCounter(int,int,ulong *);
78 |
79 | /* From ad26.c */
80 | double Get_Temperature(int portnum);
81 | float Volt_Reading(int portnum, int vdd, int *cad);
82 | int PIO_Reading(int portnum, int pionum /* TS ignored so far */ );
83 |
84 | /* From XXXlnk.c */
85 | SMALLINT owTouchBit(int,SMALLINT);
86 | SMALLINT owSpeed(int,SMALLINT);
87 | SMALLINT owTouchByte(int portnum, SMALLINT sendbyte);
88 | SMALLINT owProgramPulse(int portnum);
89 |
90 |
--------------------------------------------------------------------------------
/src/ether-wake/Makefile:
--------------------------------------------------------------------------------
1 | #******************************************************************
2 | #** File: Makefile
3 | #** Description: the makefile for ether-wake project
4 | #******************************************************************
5 |
6 | CROSS = /usr/bin/
7 |
8 | CFLAGS = -O3 -Wall -pedantic -std=gnu99
9 | CC = $(CROSS)gcc
10 | STRIP = $(CROSS)strip --strip-unneeded
11 |
12 | all: ether-wake
13 |
14 | ether-wake: ether-wake.c
15 | $(CC) $(CFLAGS) -o ether-wake ether-wake.c
16 | $(STRIP) ether-wake
17 |
18 | clean:
19 | rm -f ether-wake
20 |
--------------------------------------------------------------------------------
/src/logfilter/Makefile:
--------------------------------------------------------------------------------
1 | #******************************************************************
2 | #** File: Makefile
3 | #** Description: the makefile for logfilter project
4 | #******************************************************************
5 |
6 | CROSS = /usr/bin/
7 |
8 | CFLAGS = -O3 -Wall -pedantic -std=gnu99
9 | CC = $(CROSS)gcc
10 | STRIP = $(CROSS)strip --strip-unneeded
11 |
12 | all: logfilter
13 |
14 | logfilter: logfilter.c Makefile
15 | $(CC) $(CFLAGS) -o logfilter logfilter.c
16 | $(STRIP) logfilter
17 |
18 | clean:
19 | rm -f logfilter
20 |
--------------------------------------------------------------------------------
/src/update_addon/Makefile:
--------------------------------------------------------------------------------
1 | #******************************************************************
2 | #** File: Makefile
3 | #** Description: the makefile for update_addon project
4 | #******************************************************************
5 |
6 | CROSS = /usr/bin/
7 |
8 | CFLAGS = -O3 -Wall -pedantic -std=gnu99
9 | CC = $(CROSS)gcc
10 | STRIP = $(CROSS)strip --strip-unneeded
11 |
12 | all: update_addon
13 |
14 | update_addon: update_addon.c
15 | $(CC) $(CFLAGS) -o update_addon update_addon.c
16 | $(STRIP) update_addon
17 |
18 | clean:
19 | rm -f update_addon
20 |
--------------------------------------------------------------------------------
/src/update_addon/update_addon.c:
--------------------------------------------------------------------------------
1 | /*
2 | update_addon (C) '2013 by Uwe Langhammer
3 | ./update_addon []
4 | */
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #define VERSION "1.0"
19 | #define HM_CONFIG "/usr/local/etc/config/hm_addons.cfg"
20 |
21 | char *read_configfile(char *configfile) {
22 | char *buffer = NULL;
23 | FILE *f;
24 | //printf("read(%s)\n",configfile);
25 | if (configfile) {
26 | if ((f = fopen(configfile,"rb"))) {
27 | int size,len;
28 | fseek(f,0,SEEK_END);
29 | size = ftell(f);
30 | rewind(f);
31 | buffer = malloc(size+2);
32 | len = fread(buffer,1,size,f);
33 | fclose(f);
34 | if (len == size) {
35 | char c1,c2,c,ws = 1;
36 | int i,j = 0;
37 | buffer[len] = 0;
38 | //printf("in: (%s)\n",buffer);
39 | for (i=0;i<=len;i++) {
40 | c1 = buffer[i];
41 | c2 = buffer[i+1];
42 |
43 | if (c1 > ' ') {
44 | if (c1 == '{') ws=1;
45 | else ws=0;
46 | c=1;
47 | } else {
48 | c1 = ' ';
49 | if (ws || (c2 <= ' ') || (c2 == '}')) c = 0;
50 | else c = 1;
51 | if (c) ws = 1;
52 | }
53 |
54 | if (c) buffer[j++] = c1;
55 | }
56 | while (j && (buffer[j-1] == ' ')) j--;
57 | buffer[j] = 0;
58 | //printf("out: (%s) %d:%d\n",buffer,size,j);
59 | } else {
60 | fprintf(stderr,"ERR: read(%s) len(%d)\n",configfile,len);
61 | free(buffer);
62 | buffer = NULL;
63 | }
64 | } else {
65 | fprintf(stderr,"ERR: open(%s) %s\n",configfile,strerror(errno));
66 | }
67 | } else {
68 | buffer = malloc(1);
69 | *buffer = 0;
70 | }
71 | return buffer;
72 | }
73 |
74 | void del_addon(char *hmconfig,char *id) {
75 | char *p3,*p2,*p1 = hmconfig;
76 | char fid[30];
77 | while (*p1) {
78 | while (*p1 && (*p1 <= ' ')) p1++;
79 | p2 = p1;
80 | while ((*p2 > ' ') && (*p2 != '{')) p2++;
81 | memcpy(fid,p1,p2-p1);
82 | fid[p2-p1] = 0;
83 | //printf("del1(%s)?\n",fid);
84 | p3 = p2;
85 | while (*p3 && (*p3 <= ' ')) p3++;
86 | if (*p3 == '{') {
87 | int n = 1;
88 | p3++;
89 | while (n && *p3) {
90 | switch (*p3) {
91 | case '{':
92 | n++;
93 | break;
94 | case '}':
95 | n--;
96 | break;
97 | }
98 | p3++;
99 | }
100 | while (*p3 && (*p3 <= ' ')) p3++;
101 | if (!strcmp(fid,id)) {
102 | printf("del(%s)\n",fid);
103 | memmove(p1,p3,strlen(p3)+1);
104 | break;
105 | }
106 | }
107 | p1 = p3;
108 | }
109 | }
110 |
111 | char *add_addon(char *hmconfig,char *id,char *addon) {
112 | hmconfig = realloc(hmconfig,strlen(hmconfig)+strlen(id)+strlen(addon)+10);
113 | if (strlen(hmconfig) && (hmconfig[strlen(hmconfig)-1] > ' ')) strcat(hmconfig," ");
114 | strcat(hmconfig,id);
115 | strcat(hmconfig," ");
116 | strcat(hmconfig,addon);
117 | printf("set(%s)\n",id);
118 | return hmconfig;
119 | }
120 |
121 | int write_hmconfig(char *cfgfile,char *hmconfig) {
122 | FILE *f;
123 | if ((f = fopen(cfgfile,"wb"))) {
124 | int len = strlen(hmconfig);
125 | if (len && (hmconfig[len-1] == ' ')) len--;
126 | fwrite(hmconfig,1,len,f);
127 | // fwrite("\n",1,1,f);
128 | fclose(f);
129 | } else return 1;
130 | return 0;
131 | }
132 |
133 | int set_addon(char *id,char *addon) {
134 | int ret = 0;
135 | char *buffer = read_configfile(addon);
136 | if (buffer) {
137 | char *hmconfig = read_configfile(HM_CONFIG);
138 | if (hmconfig) {
139 | //printf("del(%s): %s\n",id,hmconfig);
140 | del_addon(hmconfig,id);
141 | //printf("add(%s): %s\n",id,hmconfig);
142 | if (strlen(buffer)) hmconfig = add_addon(hmconfig,id,buffer);
143 | //printf("write(%s): %s\n",HM_CONFIG,hmconfig);
144 | ret = write_hmconfig(HM_CONFIG,hmconfig);
145 | free(hmconfig);
146 | } else ret = 1;
147 | free(buffer);
148 | } else ret = 1;
149 | return ret;
150 | }
151 |
152 | int main(int argc, char *argv[]) {
153 | int ret = 0;
154 | if (argc > 2) {
155 | ret = set_addon(argv[1],argv[2]);
156 | } else if (argc > 1) {
157 | ret = set_addon(argv[1],NULL);
158 | } else {
159 | fprintf(stderr,"update_addon Version %s (C) by Uwe Langhammer\n",VERSION);
160 | fprintf(stderr,"usage: %s []\n",argv[0]);
161 | ret = 1;
162 | }
163 | return ret;
164 | }
165 |
--------------------------------------------------------------------------------