Det är möjligt att göra, det fungerar både i OWFS och i den mjukvara Maxim/Dallas erbjuder. Var ett tag sedan jag körde mitt 1-wire med C-kod, men en idé är ju att studera 1-Wire Public Domain Kit (http://www.maxim-ic.com/products/ibutto ... irekit.cfm) och se hur man gör i den mjukvaran.
//status.c - used to read status of DS2405's
// Include files
#include <stdio.h>
#include <stdlib.h>
#include "ownet.h"
#include "swt05.h"
#include "findtype.h"
// Constant definitions
#define MAXDEVICES 15
//
int main(int argc, char **argv)
{
uchar SwitchSN[MAXDEVICES]∞; //the serial numbers for the devices
short i,j; //loop counters
int num; //for the number of DS2405s
int lev;
int portnum=0;
// check for required port name
if (argc != 2)
{
printf("1-Wire Net name required on command line!\n"
" (example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" "
"(Linux DS2480),\"1\" (Win32 TMEX)\n");
exit(1);
}
// attempt to acquire the 1-Wire Net
if (!owAcquire(portnum,argv[1]))
{
OWERROR_DUMP(stdout);
exit(1);
}
// this is to get the number of the devices and the serial numbers
num = FindDevices(portnum, &SwitchSN[0], SWITCH_FAMILY, MAXDEVICES);
for( i=0; i<num; i++)
{
if(ReadSwitch05(portnum, SwitchSN[i], &lev))
{
printf("Device ");
for(j=7; j>=0; j--)
printf("%02X", SwitchSN[i][j]);
if(lev)
printf(" is active and is high.\n");
else
printf(" is active and is low.\n");
}
else
printf("Error reading active device\n");
if(!ReadSwitch05(portnum, SwitchSN[i], &lev))
{
printf("Device ");
for(j=7; j>=0; j--)
printf("%02X", SwitchSN[i][j]);
if(lev)
printf(" is not active and is high.\n");
else
printf(" is not active and is low.\n");
}
else
printf("Error reading nonactive device\n");
}
if(num == 0)
printf("DS2405 not found on the 1-Wire Network.\n");
owRelease(portnum);
printf("Closing port %s.\n", argv[1]);
exit(0);
return 0;
}
If Search ROM returns read-0 time slots (PIO=logical 0) for a
given device, it may be due to that particular DS2405 driving its PIO pin low, or under certain conditions
the logical 0 may be caused by some other device holding PIO low. If that same device is found using an
active-only search, CONTROL must be a logical 1 and the PIO pin is being held low by the DS2405. If
that same device is not found using an active-only search, CONTROL must be a logical 0 and the PIO pin
is being held low by some other device or perhaps a fault condition such as a PIO shorted to ground.
Att en enhet är aktiv betyder att den interna MosFet'en är aktiverad (open drain utgång). Om den sedan är high eller low beror på den verkliga nivån på Pio'n. Det kan ju vara så att 2405'an är aktiverad men att annan elektronik drar Pio hög, enheten blir då 'active and high' trots att 2405an försöker dra Pio till 0.
Dock undrar jag fortfarande vad jag ska skicka till den för att inte trigga på eller av... Om jag idag sänder serialnr och när sista biten är skickad (eller byten...minns inte nu) så triggar den direkt på eller av.
Skickar jag nått direkt efter detta innan jag kör reset o sånt, så visar den sin status.
men efter en reset så måste jag skicka matchrom igen...
EDIT: En fundering är, ska jag skicka en "RESET" i början av programmet, sen under programmets gång så skickas inte reset alls?
Om jag tex skickar reset, sen matchrom, så "togglar" den, skickar jag valfritt efter detta så talar den endast om status.
Om jag sen ska åt en annan ds2405:a så skickar jag matchrom till denna rakt av o får dennes status, men om jag då vill "toggla" den så den ändrar status så måste jag skicka en reset för att sen skicka matchrom.
Om jag sen ska åt ds2405 nr 1 så har ju den fått en reset och då ser jag inte status utan att den "togglar" igen...
"Search ROM" och "Active only Search ROM" kan läsa av pinnen *om* mastern lägger till "additional read time slots".
Du kan ju köra "Search ROM" med dina kända ROM koder direkt, så behöver man inte gå igenom hela avscanningen av bussen. Du vet ju redan vilka ROM koder det finns.
Match ROM - The DS2405 that exactly matches the 64-bit ROM sequence will toggle the state of its PIO
pin after the 64th bit of the match is entered.
Search ROM - The
DS2405 that was discovered by the search process will not toggle the state of its PIO pin at the end of the
search, but additional read time slots issued by the bus master after the search is completed will cause the
DS2405 to output the logic state of its PIO pin onto the 1-Wire bus. If the pulldown is on and the PIO pin
is a logical 0, the DS2405 will respond with read-0 time slots. If the pulldown is off and the PIO pin is a
logical 1 (external pullup is required), the DS2405 will respond with read-1 time slots. Each additional
read time slot issued by the bus master will continue to indicate the state of the PIO pin until a Reset
Pulse is received from the bus master. The combination of Match ROM and Search ROM allows the user
to change the state of the PIO pin and report the current state (Match ROM) or simply report the current
state of the PIO pin without changing it (Search ROM).
En sak kan man säga, och det är att Maxim skulle kunna ha skrivet en lite mer samanfattande del i databladen där man kort beskriver hur man gör vissa "typiska" operationer. Eller som tydligt markerade "notes" i texten. Nu får man lusläsa en stor textmassa för att hitta den där viktiga lilla detaljen. I alla fall så har det varit så i de flesta Maxim datablad jag har sett...