From 71e1f1ed660b248392a4052e6b6302c675e7c147 Mon Sep 17 00:00:00 2001 From: johanknol Date: Thu, 8 Mar 2001 19:49:29 +0000 Subject: [PATCH] Fixed some bug, added the humidity sensor git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@676 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/examples/ds390/ow390/Makefile | 8 +- device/examples/ds390/ow390/ad26.c | 265 ++++++++++++++++++++++++++ device/examples/ds390/ow390/ad26.h | 33 ++++ device/examples/ds390/ow390/gethumd.c | 111 +++++++++++ device/examples/ds390/ow390/owfile.c | 24 ++- device/examples/ds390/ow390/owllu.c | 17 +- device/examples/ds390/ow390/ownet.h | 2 + device/examples/ds390/ow390/ownetu.c | 31 ++- device/examples/ds390/ow390/owsesu.c | 2 +- device/examples/ds390/ow390/owtrnu.c | 105 ++++++++-- device/examples/ds390/ow390/temp.c | 2 +- device/examples/ds390/ow390/time.c | 24 --- device/examples/ds390/ow390/time.h | 17 -- device/examples/ds390/ow390/tinilnk.c | 29 ++- device/examples/ds390/ow390/tstow.c | 25 ++- 15 files changed, 607 insertions(+), 88 deletions(-) create mode 100755 device/examples/ds390/ow390/ad26.c create mode 100755 device/examples/ds390/ow390/ad26.h create mode 100755 device/examples/ds390/ow390/gethumd.c delete mode 100755 device/examples/ds390/ow390/time.c delete mode 100644 device/examples/ds390/ow390/time.h diff --git a/device/examples/ds390/ow390/Makefile b/device/examples/ds390/ow390/Makefile index 6519e97f..b20dc5b0 100755 --- a/device/examples/ds390/ow390/Makefile +++ b/device/examples/ds390/ow390/Makefile @@ -1,18 +1,18 @@ #CC = sdcc CC = /home/johan/sdcc/bin/sdcc -MFLAGS = -mds390 --model-flat24 --stack-10bit +MFLAGS = -mds390 LFLAGS = --xram-loc 0x180080 --code-loc 0x10000 -Wl-r TARGETS = tstfind.hex temp.hex swtloop.hex swtoper.hex counter.hex \ - tstow.hex thermodl.hex + tstow.hex thermodl.hex gethumd.hex OW_OBJECTS = ownetu.rel owsesu.rel owllu.rel owlli.rel owtrnu.rel \ crcutil.rel tinilnk.rel findtype.rel ds2480ut.rel owfile.rel -SENSOR_OBJECTS = temp10.rel swt12.rel cnt1d.rel thermo21.rel +SENSOR_OBJECTS = temp10.rel swt12.rel cnt1d.rel thermo21.rel ad26.rel -TINI_TEST_OBJECTS = time.rel +TINI_TEST_OBJECTS = all: ow.lib sensors.lib $(TINI_TEST_OBJECTS) $(TARGETS) diff --git a/device/examples/ds390/ow390/ad26.c b/device/examples/ds390/ow390/ad26.c new file mode 100755 index 00000000..703bdc89 --- /dev/null +++ b/device/examples/ds390/ow390/ad26.c @@ -0,0 +1,265 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +//-------------------------------------------------------------------------- +// +// ad26.c - Reads the voltage on the 1-Wire +// version 1.00 +// + +// Include Files +#include +#include "ownet.h" +#include "ad26.h" + +int Volt_AD(int portnum, int vdd, uchar *SNum) +{ + uchar send_block[50]; + uchar test; + int send_cnt=0; + int i; + ushort lastcrc8; + int busybyte; + + owSerialNum(portnum,SNum,FALSE); + // Recall the Status/Configuration page + // Recall command + send_block[send_cnt++] = 0xB8; + + // Page to Recall + send_block[send_cnt++] = 0x00; + + if(!owBlock(portnum,FALSE,send_block,send_cnt)) + return FALSE; + + send_cnt = 0; + + if(owAccess(portnum)) + { + // Read the Status/Configuration byte + // Read scratchpad command + send_block[send_cnt++] = 0xBE; + + // Page for the Status/Configuration byte + send_block[send_cnt++] = 0x00; + + for(i=0;i<9;i++) + send_block[send_cnt++] = 0xFF; + + if(owBlock(portnum,FALSE,send_block,send_cnt)) + { + setcrc8(portnum,0); + + for(i=2;i> 3) * 0.03125; + }//Access + + return ret; +} + diff --git a/device/examples/ds390/ow390/ad26.h b/device/examples/ds390/ow390/ad26.h new file mode 100755 index 00000000..ae3fb693 --- /dev/null +++ b/device/examples/ds390/ow390/ad26.h @@ -0,0 +1,33 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +//--------------------------------------------------------------------------- +// +// ad26.h - Include file for Smart Battery Monitor demo. +// +// Version: 2.00 + +int Volt_AD(int portnum, int vdd, uchar *); +float Volt_Reading(int portnum, int vdd, uchar *); +double Get_Temperature(int portnum,uchar *); diff --git a/device/examples/ds390/ow390/gethumd.c b/device/examples/ds390/ow390/gethumd.c new file mode 100755 index 00000000..074e9a11 --- /dev/null +++ b/device/examples/ds390/ow390/gethumd.c @@ -0,0 +1,111 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +//--------------------------------------------------------------------------- +// +// getV.c - This utility gets the Volts for pins Vad and Vdd from the DS2438. +// +// Version: 2.00 +// History: + +#include +#include "ownet.h" +#include "ad26.h" + +#define MAXDEVICES 5 + +// Global necessary for screenio +int VERBOSE; + +// tini hack +int argc=2; +char *argv[]={__FILE__, "exow"}; + +//---------------------------------------------------------------------- +// This is the Main routine for debit +// +int main() //short argc, char **argv) +{ + char msg[200]; + int portnum = 0; + float Vdd,Vad; + double humid,temp; + int i; + int numbat; + uchar famvolt[MAXDEVICES][8]; + + // check for required port name + if (argc != 2) + { + sprintf(msg,"1-Wire Net name required on command line!\n" + " (example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" " + "(Linux DS2480),\"1\" (Win32 TMEX)\n"); + //output_status(LV_ALWAYS,msg); + printf (msg); + return 0; + } + + if(!owAcquire(portnum,argv[1],msg)) + { + //output_status(LV_ALWAYS,msg); + printf (msg); + return 0; + } + else + { + + do + { + numbat = FindDevices(portnum,&famvolt[0],SBATTERY_FAM,MAXDEVICES); + if (numbat==0) { + printf ("No device found.\n"); + } + + for(i=0;i +#endif //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // @@ -55,9 +59,13 @@ // int owReadFile(int portnum, uchar *filename, uchar *buf) { - uchar dirpg=0,pgbuf[32],filepg=0,pglen; - short bufcnt=0,i; + uchar dirpg=0,pgbuf[32],filepg=0; + char pglen; + ushort bufcnt=0,i; +#if DEBUG_OW_FILE + printf ("owReadFile: %s\n", filename); +#endif // loop read directory pages until the file entry is found do { @@ -88,6 +96,9 @@ int owReadFile(int portnum, uchar *filename, uchar *buf) { // get the file starting page number filepg = pgbuf[i+5]; +#if DEBUG_OW_FILE + printf ("owReadFile: file %s starts at %d\n", filename, filepg); +#endif break; } } @@ -108,14 +119,16 @@ int owReadFile(int portnum, uchar *filename, uchar *buf) pglen = owReadPacketStd(portnum,TRUE,filepg,pgbuf); // check result of read - if (pglen <= 0) - return READ_ERROR; + if (pglen <= 0) { + return READ_ERROR; + } // append the page data to the buffer for (i = 0; i < (pglen - 1); i++) buf[bufcnt++] = pgbuf[i]; // get the next file page (from page pointer) + _asm ;johan _endasm; filepg = pgbuf[pglen-1]; } while (filepg); @@ -154,6 +167,9 @@ int owFormatWriteFile(int portnum, uchar *filename, int fllen, uchar *buf) bmpg2[] = { 0,0,0,0,0 }, pgbuf[32]; int i,numdirpgs,flpg,bmpg1len,bmpg2len,cntleft,pos,numpgs; +#if DEBUG_OW_FILE + printf ("owFormatWriteFile: %s %d\n", filename, fllen); +#endif // calculate the number of pages needed to write the file numpgs = (fllen / 28) + ((fllen % 28) ? 1 : 0); diff --git a/device/examples/ds390/ow390/owllu.c b/device/examples/ds390/ow390/owllu.c index 4030cf1a..63242ea2 100755 --- a/device/examples/ds390/ow390/owllu.c +++ b/device/examples/ds390/ow390/owllu.c @@ -1,3 +1,7 @@ +#define DEBUG_OW_LLU 0 +#if DEBUG_OW_LLU +#include +#endif //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // @@ -61,6 +65,9 @@ int owTouchReset(int portnum) uchar readbuffer[10],sendpacket[10]; int sendlen=0; +#if DEBUG_OW_LLU + printf ("owTouchReset\n"); +#endif // make sure normal level owLevel(portnum,MODE_NORMAL); @@ -261,6 +268,9 @@ int owSpeed(int portnum, int new_speed) short sendlen=0; int rt = FALSE; +#if DEBUG_OW_LLU + printf ("starting owSpeed: %d\n", new_speed); +#endif // check if change from current mode if (((new_speed == MODE_OVERDRIVE) && (USpeed[portnum] != SPEEDSEL_OD)) || @@ -308,7 +318,9 @@ int owSpeed(int portnum, int new_speed) } } } - +#if DEBUG_OW_LLU + printf ("owSpeed: %d\n", rt); +#endif // return the current speed return (USpeed[portnum] == SPEEDSEL_OD) ? MODE_OVERDRIVE : MODE_NORMAL; } @@ -333,6 +345,9 @@ int owLevel(int portnum, int new_level) short sendlen=0; short rt=FALSE; +#if DEBUG_OW_LLU + printf ("owLevel: %d\n", new_level); +#endif // check if need to change level if (new_level != ULevel[portnum]) { diff --git a/device/examples/ds390/ow390/ownet.h b/device/examples/ds390/ow390/ownet.h index 96b4ef02..7c183628 100755 --- a/device/examples/ds390/ow390/ownet.h +++ b/device/examples/ds390/ow390/ownet.h @@ -67,10 +67,12 @@ // family codes of devices #define DIR_FAMILY 0x01 #define TEMP_FAMILY 0x10 +#define NVRAM64K_FAMILY 0x0c #define SWITCH_FAMILY 0x12 #define COUNT_FAMILY 0x1D #define ATOD_FAMILY 0X20 #define THERMO_FAM 0x21 +#define SBATTERY_FAM 0x26 // this is weird, the DS2502 should be 0x09 #define DS2502_FAMILY 0x89 diff --git a/device/examples/ds390/ow390/ownetu.c b/device/examples/ds390/ow390/ownetu.c index e96016a4..8629d430 100755 --- a/device/examples/ds390/ow390/ownetu.c +++ b/device/examples/ds390/ow390/ownetu.c @@ -1,3 +1,7 @@ +#define DEBUG_OW_NETU 0 +#if DEBUG_OW_NETU +#include +#endif //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // @@ -111,7 +115,10 @@ int owNext(int portnum, int do_reset, int alarm_only) // reset the search LastDiscrepancy[portnum] = 0; LastDevice[portnum] = FALSE; - LastFamilyDiscrepancy[portnum] = 0; + LastFamilyDiscrepancy[portnum] = 0; +#if DEBUG_OW_NETU + printf ("owNext: no (more) devices\n"); +#endif return FALSE; } @@ -231,7 +238,10 @@ int owNext(int portnum, int do_reset, int alarm_only) // reset the search LastDiscrepancy[portnum] = 0; LastDevice[portnum] = FALSE; - LastFamilyDiscrepancy[portnum] = 0; + LastFamilyDiscrepancy[portnum] = 0; +#if DEBUG_OW_NETU + printf ("owNext: check results failed\n"); +#endif return FALSE; } // successful search @@ -249,7 +259,15 @@ int owNext(int portnum, int do_reset, int alarm_only) LastDiscrepancy[portnum] = tmp_last_desc; return TRUE; } + } else { +#if DEBUG_OW_NETU + printf ("owNext: ReadCOM failed\n"); +#endif } + } else { +#if DEBUG_OW_NETU + printf ("owNext: WriteCOM failed\n"); +#endif } // an error occured so re-sync with DS2480 @@ -473,6 +491,9 @@ int owOverdriveAccess(int portnum) uchar sendpacket[8]; int i, bad_echo = FALSE; +#if DEBUG_OW_NETU + printf ("owOverdriveAccess\n"); +#endif // make sure normal level owLevel(portnum,MODE_NORMAL); @@ -501,8 +522,12 @@ int owOverdriveAccess(int portnum) if (sendpacket[i] != SerialNum[portnum][i]) bad_echo = TRUE; // if echo ok then success - if (!bad_echo) + if (!bad_echo) { +#if DEBUG_OW_NETU + printf ("owOverdriveAccess success\n"); +#endif return TRUE; + } } } } diff --git a/device/examples/ds390/ow390/owsesu.c b/device/examples/ds390/ow390/owsesu.c index 508c3cd3..2a4adf79 100755 --- a/device/examples/ds390/ow390/owsesu.c +++ b/device/examples/ds390/ow390/owsesu.c @@ -64,7 +64,7 @@ int owAcquire(int portnum, char *port_zstr, char *return_msg) " aborting.\nClosing port %s.\n",port_zstr,port_zstr); return FALSE; } - //printf (return_msg); // TODO: tini bug + printf (return_msg); // TODO: tini bug // detect DS2480 if (DS2480Detect(portnum)) diff --git a/device/examples/ds390/ow390/owtrnu.c b/device/examples/ds390/ow390/owtrnu.c index bf67642b..abd2e841 100755 --- a/device/examples/ds390/ow390/owtrnu.c +++ b/device/examples/ds390/ow390/owtrnu.c @@ -1,3 +1,7 @@ +#define DEBUG_OW_TRNU 0 +#if DEBUG_OW_TRNU +#include +#endif //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // @@ -107,8 +111,9 @@ int owBlock(int portnum, int do_reset, uchar *tran_buf, int tran_len) if (WriteCOM(portnum,sendlen,sendpacket)) { // read back the response - if (ReadCOM(portnum,tran_len,tran_buf) == tran_len) - return TRUE; + if (ReadCOM(portnum,tran_len,tran_buf) == tran_len) { + return TRUE; + } } // an error occured so re-sync with DS2480 @@ -155,6 +160,9 @@ int owReadPacketStd(int portnum, int do_access, int start_page, uchar *read_buf) uchar sendpacket[50]; ushort lastcrc16; +#if DEBUG_OW_TRNU + printf ("owReadPacketStd: %d %d\n", do_access, start_page); +#endif // check if access header is done // (only use if in sequention read with one access at begining) if (do_access) @@ -205,9 +213,14 @@ int owReadPacketStd(int portnum, int do_access, int start_page, uchar *read_buf) // verify the CRC16 is correct if (lastcrc16 == 0xB001) return length; // return number of byte in record +#if DEBUG_OW_TRNU + printf ("owReadPacketStd: crc error in page %d\n", start_page); +#endif } } - +#if DEBUG_OW_TRNU + printf ("owReadPacketStd: block>29 : %d\n", length); +#endif // failed block or incorrect CRC return -1; } @@ -254,9 +267,16 @@ int owWritePacketStd(int portnum, int start_page, uchar *write_buf, int i,buffer_cnt=0,start_address,do_access; ushort lastcrc16; +#if DEBUG_OW_TRNU + printf ("owWritePacketStd: %d %d\n", start_page, write_len); +#endif // check to see if data too long to fit on device - if (write_len > 29) + if (write_len > 29) { +#if DEBUG_OW_TRNU + printf ("owWritePacketStd: too long\n"); +#endif return FALSE; + } // seed crc with page number setcrc16(portnum,(ushort)start_page); @@ -280,12 +300,20 @@ int owWritePacketStd(int portnum, int start_page, uchar *write_buf, if (!is_eprom) { // write the page - if (!Write_Scratchpad(portnum,construct_buffer,start_page,buffer_cnt)) - return FALSE; + if (!Write_Scratchpad(portnum,construct_buffer,start_page,buffer_cnt)) { +#if DEBUG_OW_TRNU + printf ("owWritePacketStd: couldn't Write_Scratchpad\n"); +#endif + return FALSE; + } // copy the scratchpad - if (!Copy_Scratchpad(portnum,start_page,buffer_cnt)) - return FALSE; + if (!Copy_Scratchpad(portnum,start_page,buffer_cnt)) { +#if DEBUG_OW_TRNU + printf ("owWritePacketStd: couldn't Copy_Scratchpad\n"); +#endif + return FALSE; + } // copy scratch pad was good then success return TRUE; @@ -428,6 +456,9 @@ int Write_Scratchpad(int portnum, uchar *write_buf, int start_page, int write_le int i,sendlen=0; uchar sendpacket[50]; +#if DEBUG_OW_TRNU + printf ("Write_Scratchpad: %d %d\n", start_page, write_len); +#endif // match command sendpacket[sendlen++] = 0x55; for (i = 0; i < 8; i++) @@ -436,6 +467,7 @@ int Write_Scratchpad(int portnum, uchar *write_buf, int start_page, int write_le sendpacket[sendlen++] = 0x0F; // write the target address sendpacket[sendlen++] = ((start_page << 5) & 0xFF); + _asm ;johan 1 _endasm; sendpacket[sendlen++] = (start_page >> 3); // write packet bytes @@ -461,20 +493,31 @@ int Write_Scratchpad(int portnum, uchar *write_buf, int start_page, int write_le if (owBlock(portnum,TRUE,sendpacket,sendlen)) { // check address and offset of scratchpad read - if ((sendpacket[10] != (int)((start_page << 5) & 0xFF)) || - (sendpacket[11] != (int)(start_page >> 3)) || - (sendpacket[12] != (int)(write_len - 1))) - return FALSE; + if ((sendpacket[10] != (int)((start_page << 5) & 0xFF)) || + (sendpacket[11] != (int)(start_page >> 3)) || + (sendpacket[12] != (int)(write_len - 1))) { +#if DEBUG_OW_TRNU + printf ("\nWrite_Scratchpad: check failed\n"); +#endif + //return FALSE; + } // verify each data byte for (i = 0; i < write_len; i++) - if (sendpacket[i+13] != write_buf[i]) - return FALSE; + if (sendpacket[i+13] != write_buf[i]) { +#if DEBUG_OW_TRNU + printf ("\nWrite_Scratchpad: data check failed\n"); +#endif + return FALSE; + } // must have verified return TRUE; } - } + } +#if DEBUG_OW_TRNU + printf ("\nWrite_Scratchpad: owBlock failed\n"); +#endif // failed a block tranfer return FALSE; @@ -497,6 +540,10 @@ int Copy_Scratchpad(int portnum, int start_page, int write_len) { int i,sendlen=0; uchar sendpacket[50]; + +#if DEBUG_OW_TRNU + printf ("Copy_Scratchpad: %d %d\n", start_page, write_len); +#endif // match command sendpacket[sendlen++] = 0x55; @@ -506,11 +553,16 @@ int Copy_Scratchpad(int portnum, int start_page, int write_len) sendpacket[sendlen++] = 0x55; // write the target address sendpacket[sendlen++] = ((start_page << 5) & 0xFF); + _asm ;johan 2 _endasm; sendpacket[sendlen++] = (start_page >> 3); sendpacket[sendlen++] = write_len - 1; // read copy result sendpacket[sendlen++] = 0xFF; - + +#if DEBUG_OW_TRNU + printf ("Copy_Scratchpad: %d, %02x %02x %02x %02x\n", sendlen, + sendpacket[10],sendpacket[11],sendpacket[12],sendpacket[13]); +#endif // send/recieve the transfer buffer if (owBlock(portnum,TRUE,sendpacket,sendlen)) { @@ -518,12 +570,25 @@ int Copy_Scratchpad(int portnum, int start_page, int write_len) if ((sendpacket[10] != (int)((start_page << 5) & 0xFF)) || (sendpacket[11] != (int)(start_page >> 3)) || (sendpacket[12] != (int)(write_len - 1)) || - (sendpacket[13] & 0xF0)) - return FALSE; - else + (sendpacket[13] & 0xF0)) { +#if DEBUG_OW_TRNU + printf ("Copy_Scratchpad: %d, check failed: %02x %02x %02x %02x\n", + sendlen, + sendpacket[10],sendpacket[11],sendpacket[12],sendpacket[13]); +#endif + return FALSE; + } + else { +#if DEBUG_OW_TRNU + printf ("Copy_Scratchpad: %02x %02x %02x %02x\n", + sendpacket[10],sendpacket[11],sendpacket[12],sendpacket[13]); +#endif return TRUE; + } } - +#if DEBUG_OW_TRNU + printf ("Copy_Scratchpad: owBlock failed\n"); +#endif // failed a block tranfer return FALSE; } diff --git a/device/examples/ds390/ow390/temp.c b/device/examples/ds390/ow390/temp.c index a9c62a28..52b4d0f5 100755 --- a/device/examples/ds390/ow390/temp.c +++ b/device/examples/ds390/ow390/temp.c @@ -121,7 +121,7 @@ int main() //short argc, char **argv) if (ReadTemperature(portnum, FamilySN[i],¤t_temp)) { PrintSerialNum(FamilySN[i]); - printf(" %5.1f \n", current_temp); + printf(" %5.2f \n", current_temp); } else printf(" Error reading temperature, verify device present:%d\n", diff --git a/device/examples/ds390/ow390/time.c b/device/examples/ds390/ow390/time.c deleted file mode 100755 index 3b613539..00000000 --- a/device/examples/ds390/ow390/time.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "time.h" - -// let's just pretend it's 01 jan 1970 00.00:00 for now - -time_t time(time_t *t) { - *t=0; - return *t; -} - -struct tm lastTime; - -struct tm *localtime(const time_t *timep) { - timep; // hush the compiler - lastTime.tm_sec=0; - lastTime.tm_min=0; - lastTime.tm_hour=0; - lastTime.tm_mday=1; - lastTime.tm_mon=0; - lastTime.tm_year=101; - lastTime.tm_wday=0; - lastTime.tm_yday=0; - lastTime.tm_isdst=0; - return &lastTime; -} diff --git a/device/examples/ds390/ow390/time.h b/device/examples/ds390/ow390/time.h deleted file mode 100644 index 54dd1504..00000000 --- a/device/examples/ds390/ow390/time.h +++ /dev/null @@ -1,17 +0,0 @@ -struct tm -{ - int tm_sec; /* Seconds. [0-60] (1 leap second) */ - int tm_min; /* Minutes. [0-59] */ - int tm_hour; /* Hours. [0-23] */ - int tm_mday; /* Day. [1-31] */ - int tm_mon; /* Month. [0-11] */ - int tm_year; /* Year - 1900. */ - int tm_wday; /* Day of week. [0-6] */ - int tm_yday; /* Days in year.[0-365] */ - int tm_isdst; /* Daylight saving time */ -}; - -typedef unsigned long time_t; - -time_t time(time_t *t); -struct tm *localtime(time_t *timep); diff --git a/device/examples/ds390/ow390/tinilnk.c b/device/examples/ds390/ow390/tinilnk.c index 95e95e90..d1b1669f 100644 --- a/device/examples/ds390/ow390/tinilnk.c +++ b/device/examples/ds390/ow390/tinilnk.c @@ -1,3 +1,7 @@ +#define DEBUG_OW_COM 0 +#if DEBUG_OW_COM +#include +#endif //--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // @@ -146,16 +150,22 @@ int WriteCOM(int portnum, int outlen, uchar *outbuf) { int i; - //printf ("WriteCOM(%d, %d,...): ", portnum, outlen, outbuf); +#if DEBUG_OW_COM + printf ("WriteCOM(%d, %d,...): ", portnum, outlen, outbuf); +#endif // hush the compiler portnum; for (i=0; i