Programs Written to Test the 1-Wire Network
Makefile
Reading from 1-Wire Devices
- dev-read2.c:
Reads data repeatedly from 1-wire devices to stdout.
- dev-read3.c:
Reads data repeatedly from 1-wire devices to a
POSTGRESQL
database.
- add-devices.c:
Adds 1-wire devices to the POSTGRESQL database.
Creates the database if it does not exist.
- DS2490-settings.dat:
Seven hexadecimal bytes that control the timing of the pulses created by the DS2490 chip.
Used by dev-read2 and dev-read3. These are the first seven hexadecimal bytes
of the DS2490's
state registers. The adapter-state program retrieves
the current value of the state registers from the DS2490 and prints them in both
hexadecimal and human-readable form.
Libraries
In these functions, errors are reported by negative return values. Whenever an error
is returned, the function prints not only the cause of the error, but a message such
as "One-wire bit read/write failed," indicating which function was returning the error,
and thus implementing something like a stack trace. The function that handles the error
writes a blank line to stderr.
- ow-functions.c,
ow-functions.h:
Low-level functions for reading to and from the 1-Wire bus, used in all of the newer
test programs, as a replacement for the
1-Wire Public Domain Kit, which I used in earlier test code. This was written
because the search functions in the 1-Wire Public Domain Kit didn't report errors
in searches, and because I wanted to be able to adjust the timing of the pulses created
by the DS2490 chip.
- dev-functions.c,
dev-functions.h:
Functions to read from specific devices, used in dev-read2
and dev-read3.
- pq-wrapper.c,
pq-wrapper.h:
Wrappers for functions in the POSTGRESQL
libpq library. Mostly they call the function and print any errors that occur.
- posix-sleep.c:
Contains sleepSeconds function, which causes the process to sleep for a number of seconds.
Used in dev-read2 and dev-read3.
Separated because it is non-portable.
- borland-sleep.c:
This file was used instead of posix-sleep.c when compiling with
Borland's C compiler on a Windows machine.
Low-level diagnostic tools
Most of these programs simply call a specific function in
ow-functions.c.
- adapter-state.c:
Returns information about the current state of the
DS2490
USB to 1-Wire bridge chip.
- buffer-read.c:
Reads and prints buffered data from the DS2490 chip.
If no data is in the buffer, gives an error message.
- buffer-write.c:
Syntax: buffer-write byte repetitions
Writes the byte-length hexadecimal value byte to the DS2490 chip
repetitions times.
- cmd-send.c:
Syntax: cmd-send bRequest wValue wIndex
Sends a vendor-specific USB command to the DS2490 chip.
- ow-rw.c:
Sends data to and reads data from the 1-Wire bus.
Commands can be given at command prompt or typed at stdin.
Here is a list of commands / responses.
- reset-adapter.c:
Resets the state of the DS2490 chip to the state it powers up in.
- search-adapter.c:
Searches for all 1-Wire devices on the network and prints their serial numbers.
- setup-adapter.c:
This program takes as parameters seven hexadecimal bytes that control the timing of
the pulses created by the DS2490 chip.
These are the first seven hexadecimal bytes
of the DS2490's
state registers. The adapter-state program retrieves
the current value of the state registers from the DS2490 and prints them in both
hexadecimal and human-readable form. Useful in conjunction with the other low-level
diagnostic tools, which do not read the settings in
DS2490-settings.txt. An adapter reset, caused either by
adapter-reset or an error, will change the settings back to the DS2490's
default values.
Simple conversion routines
Single-use test programs
(1-Wire Public Domain Kit build for Linux / USB / libusb / GNU C)
Return to index