From: Tobias Date: Fri, 17 Feb 2017 09:28:51 +0000 (+0100) Subject: Remove tools - Create extra repository X-Git-Url: https://git.smho.de/?a=commitdiff_plain;h=5398c69061a72e7a6ad3423c4e17516ee6d09de6;p=owSlave2.git Remove tools - Create extra repository --- diff --git a/programmer/programmer/programmer.asmproj b/programmer/programmer/programmer.asmproj index 432687f..a077c58 100644 --- a/programmer/programmer/programmer.asmproj +++ b/programmer/programmer/programmer.asmproj @@ -28,15 +28,15 @@ 1 - - - - - - - - - + + + + + + + + + com.atmel.avrdbg.tool.atmelice diff --git a/tools/chowid.py b/tools/chowid.py deleted file mode 100644 index 0eed2c5..0000000 --- a/tools/chowid.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# * All advertising materials mentioning features or use of this -# software must display the following acknowledgement: This product -# includes software developed by tm3d.de and its contributors. -# * Neither the name of tm3d.de nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -import time -import subprocess - -def owcom(dev,send,rc): - res=[] - f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0) - f.write("".join(map(chr, send))) - if (rc!=0): - res=map(ord,f.read(rc)) - f.close() - return res - - -def crc8(arr): - lscrc=0x0; - for v in arr: - bit=1; - while bit<256: - if (v&bit)==bit: - lb=1 - else: - lb=0 - if (lscrc&1)!=lb: - lscrc=(lscrc>>1)^0x8c - else: - lscrc=(lscrc>>1) - bit=bit*2 - return lscrc - -def testnr(s): - for c in s.lower()[:]: - if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']): - return False - return True - -def addid(id,val): - for i in range(7): - id[i+1]=id[i+1]+val - if id[i+1]>254: - id[i+1]=id[i+1]-254 - val=1 - else: - return id - return id -# - -l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) -dc=0 -dl=[] -for g in (l.split("\n")): - if len(g)>2: - if testnr(g[0:2]): - dl.append(g) - dc=dc+1 - print dc,") ",g -if dc==0: - print "No 1-Wire Device found" - exit(0) -n=int(raw_input("No. of Device: ")) -n=n-1 -if (n>dc-1)or(n<0): - exit(0) -print dl[n], "will be changed" -s=dl[n] -nr=[int(s[0:2],16),int(s[13:15],16),int(s[11:13],16),int(s[9:11],16),int(s[7:9],16),int(s[5:7],16),int(s[3:5],16)] -nr.append(crc8(nr)) -onr=nr[:] -re=1 -while re: - re=0 - print "Number: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nr) - print "1) Increment the old ID" - print "2) Add a value to the old ID (value < 255)" - print "3) Input 6 hex numbers like AA,B5,00,32,12,F1" - print "4) Exit" - cho=int(raw_input("Press the number of your choice: ")) - if cho==1: - nr=addid(nr,1) - elif cho==2: - val=int(raw_input("Add value <255: ")) - nr=addid(nr,val) - elif cho==3: - hn=raw_input("Input six numbers in hex (like AA,B5,00,32,12,F1): ") - i=1 - for hnt in hn.split(","): - nr[i]=int(hnt,16) - i=i+1 - elif cho==4: - exit() - else: - re=1 -nr[7]=crc8(nr[:-1]) -print "New ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nr) -cho=raw_input("Set this ID? [Y/n): ") -if (cho!='Y'): - exit() - - -owcom(s,[0x75]+nr,0) -nnr=owcom(s,[0xA7],8) -print "New ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(nnr) -if nr!=nnr: - print "ERROR writing new ID\nMaybe it's no simulatet ow device from tm3d.de" - exit(0) -print "Old ID: %02X %02X %02X %02X %02X %02X %02X %02X" % tuple(onr) -owcom(s,[0x79,onr[1],onr[5],onr[6]],0) -print "Done.\nWait for a new Searchrom from Master\nSometimes the old nr keeps in the directory" diff --git a/tools/owReadBMP.py b/tools/owReadBMP.py deleted file mode 100644 index 00eac22..0000000 --- a/tools/owReadBMP.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# * All advertising materials mentioning features or use of this -# software must display the following acknowledgement: This product -# includes software developed by tm3d.de and its contributors. -# * Neither the name of tm3d.de nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -import time -import subprocess -import sys - -def owcom(dev,send,rc): - res=[] - f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0) - f.write("".join(map(chr, send))) - if (rc!=0): - res=map(ord,f.read(rc)) - f.close() - return res - - -def crc8(arr): - lscrc=0x0; - for v in arr: - bit=1; - while bit<256: - if (v&bit)==bit: - lb=1 - else: - lb=0 - if (lscrc&1)!=lb: - lscrc=(lscrc>>1)^0x8c - else: - lscrc=(lscrc>>1) - bit=bit*2 - return lscrc - -def testnr(s): - for c in s.lower()[:]: - if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']): - return False - return True - -def addid(id,val): - for i in range(7): - id[i+1]=id[i+1]+val - if id[i+1]>254: - id[i+1]=id[i+1]-254 - val=1 - else: - return id - return id -# - - -l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) -dc=0 -dl=[] -for g in (l.split("\n")): - if len(g)>2: - if testnr(g[0:2]): - if (g[0:2]=="26"): - dl.append(g) - dc=dc+1 - print dc,") ",g -if dc==0: - print "No 26 1-Wire Device found" - exit(0) -n=int(raw_input("No. of Device (28-Device will get automatically): ")) -n=n-1 -if (n>dc-1)or(n<0): - exit(0) -s=dl[n] -config=owcom(s,[0x85],17) -print(config) -s2="%02x-%02x%02x%02x%02x%02x%02x" % (config[9],config[15],config[14],config[13],config[12],config[11],config[10]) -print("Second Device: %s" %( s2)) -f=open("/sys/bus/w1/devices/%s/w1_slave" %(s2),"rb",0) -res=f.read().split(" ") -f.close() -Press=((int(res[0],16)+int(res[1],16)*256)/16.0*3.2+700) -owcom(s,[0x4E,0x00,0x01],0) -owcom(s,[0x44],0) -time.sleep(1) -owcom(s,[0xB4],0) -time.sleep(1) - -p=owcom(s,[0xBE,0x00],10) -print (p) -T=((p[1]+p[2]*256)/256.0) -if (config[5]==8): - RH=((p[3]+p[4]*256)/100.0) -if (config[5]==7): - RH=(((p[3]+p[4]*256)/ 500.0 - 0.16) / 0.0062) / (1.0546 - 0.00216*T); - -print("Temperatur: %f °C" %(T)); -print("Luftfeuchte: %f %%" %(RH)); -print("Druck (absolut): %f hPa" %(Press)); -h=float(raw_input("Höhe über Meerespiegel in m: ")) -P0=Press/((1-h/44330)**5.255) -print("Druck (normalisiert): %f hPa" %(P0)); diff --git a/tools/owflash.py b/tools/owflash.py deleted file mode 100644 index 0d37e84..0000000 --- a/tools/owflash.py +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# * All advertising materials mentioning features or use of this -# software must display the following acknowledgement: This product -# includes software developed by tm3d.de and its contributors. -# * Neither the name of tm3d.de nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -import time -import subprocess -import sys - -def owcom(dev,send,rc): - res=[] - f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0) - f.write("".join(map(chr, send))) - if (rc!=0): - res=map(ord,f.read(rc)) - f.close() - return res - - -def crc8(arr): - lscrc=0x0; - for v in arr: - bit=1; - while bit<256: - if (v&bit)==bit: - lb=1 - else: - lb=0 - if (lscrc&1)!=lb: - lscrc=(lscrc>>1)^0x8c - else: - lscrc=(lscrc>>1) - bit=bit*2 - return lscrc - -def testnr(s): - for c in s.lower()[:]: - if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']): - return False - return True - -def addid(id,val): - for i in range(7): - id[i+1]=id[i+1]+val - if id[i+1]>254: - id[i+1]=id[i+1]-254 - val=1 - else: - return id - return id -# - - - -#start search -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("-1") -f.close() - - -print "Open Hex File ...", -fi=open(sys.argv[1],"r") -data=[] -for l in fi.readlines(): - sys.stdout.write(".") - sys.stdout.flush() - bc=int(l[1:3],16) - fw=int(l[3:7],16) - ty=int(l[7:9],16) - chsm=bc+(fw>>8)+(fw&0xFF)+ty - for i in range(bc): - p=9+(i*2) - d=int(l[p:p+2],16) - chsm=(chsm+d)&0xFF - data.append(d) - chsm=(chsm+int(l[9+bc*2:11+bc*2],16))&0xFF - if (chsm!=0): - print "Error Checksum...." - exit() - #print bc,fw,ty,chsm -fi.close() -print - -l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) -dc=0 -dl=[] -for g in (l.split("\n")): - if len(g)>2: - if testnr(g[0:2]): - if (g[0:2]!="28"): - dl.append(g) - dc=dc+1 - print dc,") ",g -if dc==0: - print "No 1-Wire Device found" - exit(0) -n=int(raw_input("No. of Device: ")) -n=n-1 -if (n>dc-1)or(n<0): - exit(0) -s=dl[n] -if (s!="a3-55aa55aa55aa"): - sys.stdout.write('Go to Flashmode....') - sys.stdout.flush() - owcom(s,[0x88],0) - owcom(s,[0x88],0) - owcom(s,[0x88],0) - for i in range (20): - l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) - dc=0 - dl=[] - sys.stdout.write(".") - sys.stdout.flush() - for g in (l.split("\n")): - if (g[0:15]=="a3-55aa55aa55aa"): - break - if (g[0:15]!="a3-55aa55aa55aa"): - time.sleep(1) - if (g[0:15]=="a3-55aa55aa55aa"): - print "found" - else: - print "ERROR Enter Flashmode!" - exit() - f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0) - f.write(s) - f.close() - time.sleep(5) - -#stop search -print("Disable Device Search (Wait 15s)") -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("0") -f.close() -time.sleep(15) - -s="a3-55aa55aa55aa" -prog=data -l=len(prog) -if (l>7551): - print "Code to big ... Max 7552 Byte (118 Pages)" - exit() -pages= l/64 -for i in range(64-(l%64)): - #print i - prog.append(0xFF) -pages= len(prog)/64 -if (pages>118): - print "Code to big ... Max 7552 Byte (118 Pages)" - exit() - - -print "Programm Page (of ", pages,")" - -for i in range(pages): - sys.stdout.write("%i " % (i+1) ) - sys.stdout.flush() - - h=i*64; - hl=h&0xFF - hh=h>>8 - #print hh, hl - mem=[hl,hh]+prog[h:h+64] - erroc=0 - while (1): - owcom(s,[0x0F]+mem,0) - rmem=owcom(s,[0xAA],66) - if (rmem!=mem): - print rmem - erroc=erroc+1 - if erroc>5: - print "WRITING ERROR ... " - exit() - continue - owcom(s,[0x55],0) - time.sleep(0.05) - owcom(s,[0xB8,hl,hh],0) - time.sleep(0.05) - rmem=owcom(s,[0xAA],66) - if (rmem!=mem): - print "error in flash" - print mem - print rmem - erroc=erroc+1 - if erroc>5: - print "WRITING ERROR ... " - exit() - continue - #for v in rmem: - # print "%02X " % (v), - break -print "\nReset AVR" -owcom(s,[0x89],0) -time.sleep(1) -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0) -f.write("a3-55aa55aa55aa") -f.close() - -print("Enable Device Search") -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("-1") -f.close() - - - - - - -#mem=[0x00,0x2] -#for i in range (64): -# mem.append(i) -#owcom(s,[0x0F]+mem,0) -#rmem=owcom(s,[0xAA],70) -#print rmem -#owcom(s,[0x55],0) -#time.sleep(0.05) -#owcom(s,[0xB8,0x00,0x02],0) -#time.sleep(0.05) -#rmem=owcom(s,[0xAA],70) -#print rmem -#for v in rmem: -# print "%02X " % (v) - - - diff --git a/tools/owflashtest.py b/tools/owflashtest.py deleted file mode 100644 index 5e0b1a6..0000000 --- a/tools/owflashtest.py +++ /dev/null @@ -1,241 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# * All advertising materials mentioning features or use of this -# software must display the following acknowledgement: This product -# includes software developed by tm3d.de and its contributors. -# * Neither the name of tm3d.de nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -import time -import subprocess -import sys - -def owcom(dev,send,rc): - res=[] - f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0) - f.write("".join(map(chr, send))) - if (rc!=0): - res=map(ord,f.read(rc)) - f.close() - return res - - -def crc8(arr): - lscrc=0x0; - for v in arr: - bit=1; - while bit<256: - if (v&bit)==bit: - lb=1 - else: - lb=0 - if (lscrc&1)!=lb: - lscrc=(lscrc>>1)^0x8c - else: - lscrc=(lscrc>>1) - bit=bit*2 - return lscrc - -def testnr(s): - for c in s.lower()[:]: - if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']): - return False - return True - -def addid(id,val): - for i in range(7): - id[i+1]=id[i+1]+val - if id[i+1]>254: - id[i+1]=id[i+1]-254 - val=1 - else: - return id - return id -# - - - -#start search -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("-1") -f.close() - - -print "Open Hex File ...", -fi=open(sys.argv[1],"r") -data=[] -for l in fi.readlines(): - sys.stdout.write(".") - sys.stdout.flush() - bc=int(l[1:3],16) - fw=int(l[3:7],16) - ty=int(l[7:9],16) - chsm=bc+(fw>>8)+(fw&0xFF)+ty - for i in range(bc): - p=9+(i*2) - d=int(l[p:p+2],16) - chsm=(chsm+d)&0xFF - data.append(d) - chsm=(chsm+int(l[9+bc*2:11+bc*2],16))&0xFF - if (chsm!=0): - print "Error Checksum...." - exit() - #print bc,fw,ty,chsm -fi.close() -print - -l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) -dc=0 -dl=[] -for g in (l.split("\n")): - if len(g)>2: - if testnr(g[0:2]): - if (g[0:2]!="28"): - dl.append(g) - dc=dc+1 - print dc,") ",g -if dc==0: - print "No 1-Wire Device found" - exit(0) -n=int(raw_input("No. of Device: ")) -n=n-1 -if (n>dc-1)or(n<0): - exit(0) -s=dl[n] -if (s!="a3-55aa55aa55aa"): - sys.stdout.write('Go to Flashmode....') - sys.stdout.flush() - owcom(s,[0x88],0) - owcom(s,[0x88],0) - owcom(s,[0x88],0) - for i in range (20): - l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) - dc=0 - dl=[] - sys.stdout.write(".") - sys.stdout.flush() - for g in (l.split("\n")): - if (g[0:15]=="a3-55aa55aa55aa"): - break - if (g[0:15]!="a3-55aa55aa55aa"): - time.sleep(1) - if (g[0:15]=="a3-55aa55aa55aa"): - print "found" - else: - print "ERROR Enter Flashmode!" - exit() - f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0) - f.write(s) - f.close() - time.sleep(5) - -#stop search -print("Disable Device Search (Wait 15s)") -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("0") -f.close() -time.sleep(15) - -s="a3-55aa55aa55aa" -prog=data -l=len(prog) -if (l>7551): - print "Code to big ... Max 7552 Byte (118 Pages)" - exit() -pages= l/64 -for i in range(64-(l%64)): - #print i - prog.append(0xFF) -pages= len(prog)/64 -if (pages>118): - print "Code to big ... Max 7552 Byte (118 Pages)" - exit() - - -print "Programm Page (of ", pages,")" - -for i in range(pages): - sys.stdout.write("%i " % (i+1) ) - sys.stdout.flush() - - h=i*64; - hl=h&0xFF - hh=h>>8 - #print hh, hl - mem=[hl,hh]+prog[h:h+64] - erroc=0 - while (1): - owcom(s,[0x0F]+mem,0) - rmem=owcom(s,[0xAA],66) - if (rmem!=mem): - print rmem - erroc=erroc+1 - if erroc>5: - print "WRITING ERROR ... " - exit() - continue - #for v in rmem: - # print "%02X " % (v), - break -print "\nReset AVR" -owcom(s,[0x89],0) -time.sleep(1) -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_remove","r+b",0) -f.write("a3-55aa55aa55aa") -f.close() - -print("Enable Device Search") -f=open("/sys/bus/w1/devices/w1_bus_master1/w1_master_search","r+b",0) -f.write("-1") -f.close() - - - - - - -#mem=[0x00,0x2] -#for i in range (64): -# mem.append(i) -#owcom(s,[0x0F]+mem,0) -#rmem=owcom(s,[0xAA],70) -#print rmem -#owcom(s,[0x55],0) -#time.sleep(0.05) -#owcom(s,[0xB8,0x00,0x02],0) -#time.sleep(0.05) -#rmem=owcom(s,[0xAA],70) -#print rmem -#for v in rmem: -# print "%02X " % (v) - - - diff --git a/tools/readTempHum.py b/tools/readTempHum.py deleted file mode 100644 index d129db6..0000000 --- a/tools/readTempHum.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the -# distribution. -# * All advertising materials mentioning features or use of this -# software must display the following acknowledgement: This product -# includes software developed by tm3d.de and its contributors. -# * Neither the name of tm3d.de nor the names of its contributors may -# be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -import time -import subprocess -import sys - -def owcom(dev,send,rc): - res=[] - f=open("/sys/bus/w1/devices/%s/rw" %(dev),"r+b",0) - f.write("".join(map(chr, send))) - if (rc!=0): - res=map(ord,f.read(rc)) - f.close() - return res - - -def crc8(arr): - lscrc=0x0; - for v in arr: - bit=1; - while bit<256: - if (v&bit)==bit: - lb=1 - else: - lb=0 - if (lscrc&1)!=lb: - lscrc=(lscrc>>1)^0x8c - else: - lscrc=(lscrc>>1) - bit=bit*2 - return lscrc - -def testnr(s): - for c in s.lower()[:]: - if not((c) in ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','-']): - return False - return True - -def addid(id,val): - for i in range(7): - id[i+1]=id[i+1]+val - if id[i+1]>254: - id[i+1]=id[i+1]-254 - val=1 - else: - return id - return id -# - -def readDS18B20(s): - f=open("/sys/bus/w1/devices/%s/w1_slave" %(s),"rb",0) - res=f.read().split(" ") - f.close() - T=((int(res[0],16)+int(res[1],16)*256)/16.0) - print("Temperatur: %f °C" %(T)); - -def readDS2438(s): - owcom(s,[0x4E,0x00,0x01],0) - owcom(s,[0x44],0) - time.sleep(1) - owcom(s,[0xB4],0) - time.sleep(1) - owcom(s,[0xB8,0x00],0) - crc=1 - while crc: - p=owcom(s,[0xBE,0x00],9) - crc=crc8(p) - #print (p) - T=((p[1]+p[2]*256)/256.0) - RH=(((p[3]+p[4]*256)/ 500.0 - 0.16) / 0.0062) / (1.0546 - 0.00216*T); - print("Temperatur: %f °C" %(T)); - print("Luftfeuchte: %f %%" %(RH)); - - - -l=subprocess.check_output("ls /sys/bus/w1/devices/", shell=True) -dc=0 -dl=[] -for g in (l.split("\n")): - if len(g)>2: - if testnr(g[0:2]): - if (g[0:2]=="26"): - print dc,") ",g - readDS2438(g) - dl.append(g) - dc=dc+1 - if (g[0:2]=="28"): - print dc,") ",g - readDS18B20(g) - dl.append(g) - dc=dc+1 diff --git a/tools_cmd/bin/ib90usb.dll b/tools_cmd/bin/ib90usb.dll deleted file mode 100644 index ca0f069..0000000 Binary files a/tools_cmd/bin/ib90usb.dll and /dev/null differ diff --git a/tools_cmd/bin/ib97e32.dll b/tools_cmd/bin/ib97e32.dll deleted file mode 100644 index 6e6db4b..0000000 Binary files a/tools_cmd/bin/ib97e32.dll and /dev/null differ diff --git a/tools_cmd/bin/ib97u32.dll b/tools_cmd/bin/ib97u32.dll deleted file mode 100644 index c08f1f4..0000000 Binary files a/tools_cmd/bin/ib97u32.dll and /dev/null differ diff --git a/tools_cmd/bin/ibfs32.dll b/tools_cmd/bin/ibfs32.dll deleted file mode 100644 index bced541..0000000 Binary files a/tools_cmd/bin/ibfs32.dll and /dev/null differ diff --git a/tools_cmd/bin/ibusb32.dll b/tools_cmd/bin/ibusb32.dll deleted file mode 100644 index 772fa8d..0000000 Binary files a/tools_cmd/bin/ibusb32.dll and /dev/null differ diff --git a/tools_cmd/rwOW/crcutil.c b/tools_cmd/rwOW/crcutil.c deleted file mode 100644 index cf1bef8..0000000 --- a/tools_cmd/rwOW/crcutil.c +++ /dev/null @@ -1,119 +0,0 @@ -//--------------------------------------------------------------------------- -// 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. -//-------------------------------------------------------------------------- -// -// crcutil.c - Keeps track of the CRC for 16 and 8 bit operations -// version 2.00 - -// Include files -#include "ownet.h" - -// Local global variables -ushort utilcrc16[MAX_PORTNUM]; -uchar utilcrc8[MAX_PORTNUM]; -static short oddparity[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; -static uchar dscrc_table[] = { - 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, - 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, - 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, - 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, - 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, - 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, - 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, - 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, - 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, - 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, - 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, - 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, - 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, - 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, - 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, - 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; - -//-------------------------------------------------------------------------- -// Reset crc16 to the value passed in -// -// 'reset' - data to set crc16 to. -// -void setcrc16(int portnum, ushort reset) -{ - utilcrc16[portnum&0x0FF] = reset; - return; -} - -//-------------------------------------------------------------------------- -// Reset crc8 to the value passed in -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'reset' - data to set crc8 to -// -void setcrc8(int portnum, uchar reset) -{ - utilcrc8[portnum&0x0FF] = reset; - return; -} - -//-------------------------------------------------------------------------- -// Calculate a new CRC16 from the input data short. Return the current -// CRC16 and also update the global variable CRC16. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'data' - data to perform a CRC16 on -// -// Returns: the current CRC16 -// -ushort docrc16(int portnum, ushort cdata) -{ - cdata = (cdata ^ (utilcrc16[portnum&0x0FF] & 0xff)) & 0xff; - utilcrc16[portnum&0x0FF] >>= 8; - - if (oddparity[cdata & 0xf] ^ oddparity[cdata >> 4]) - utilcrc16[portnum&0x0FF] ^= 0xc001; - - cdata <<= 6; - utilcrc16[portnum&0x0FF] ^= cdata; - cdata <<= 1; - utilcrc16[portnum&0x0FF] ^= cdata; - - return utilcrc16[portnum&0x0FF]; -} - -//-------------------------------------------------------------------------- -// Update the Dallas Semiconductor One Wire CRC (utilcrc8) from the global -// variable utilcrc8 and the argument. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'x' - data byte to calculate the 8 bit crc from -// -// Returns: the updated utilcrc8. -// -uchar docrc8(int portnum, uchar x) -{ - utilcrc8[portnum&0x0FF] = dscrc_table[utilcrc8[portnum&0x0FF] ^ x]; - return utilcrc8[portnum&0x0FF]; -} diff --git a/tools_cmd/rwOW/ibfs32.lib b/tools_cmd/rwOW/ibfs32.lib deleted file mode 100644 index a856f6e..0000000 Binary files a/tools_cmd/rwOW/ibfs32.lib and /dev/null differ diff --git a/tools_cmd/rwOW/ibtmexcw.h b/tools_cmd/rwOW/ibtmexcw.h deleted file mode 100644 index 8729c7c..0000000 --- a/tools_cmd/rwOW/ibtmexcw.h +++ /dev/null @@ -1,234 +0,0 @@ -/*--------------------------------------------------------------------------- -* Copyright © 1992-2008 Maxim Integrated Products, 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 MAXIM INTEGRATED PRODUCTS 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 Maxim Integrated Products -* shall not be used except as stated in the Maxim Integrated Products -* Branding Policy. -*--------------------------------------------------------------------------- -* Version 4.01 -*/ - -/* includes */ -#include -#include -#include -#include -#ifndef _WIN32_WCE -#include -#include -#include -#include -#include -#include -#endif - -/* type defs */ -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned long ulong; - -/* typedef structure sent back by TMEX routines */ -typedef struct -{ -uchar name[4]; -uchar extension; -uchar startpage; -uchar numpages; -uchar attrib; -uchar bitmap[32]; -} FileEntry; - -/* structure to hold directory path */ -typedef struct -{ -uchar NumEntries; /* number of entries in path 0-10 */ -char Ref; /* reference character '\' or '.' */ -char Entries[10][4]; /* sub-directory entry names */ -} DirectoryPath; - -/* Holds info of each object in the Directory list */ -struct DirNumInfo -{ -unsigned char Name[4]; -unsigned char Extension; -char Attrib; -}; - -/* structure to hold exportable device parameters by family code (3.11) */ -typedef struct -{ -short features[32]; -char dscrptn[255]; -} Specification; - - -/* Error codes from TMEX functions */ -#define NO_DEVICE -1 -#define WRONG_TYPE -2 -#define FILE_READ_ERR -3 -#define BUFFER_TOO_SMALL -4 -#define HANDLE_NOT_AVAIL -5 -#define FILE_NOT_FOUND -6 -#define REPEAT_FILE -7 -#define HANDLE_NOT_USED -8 -#define FILE_WRITE_ONLY -9 -#define OUT_OF_SPACE -10 -#define FILE_WRITE_ERR -11 -#define TMFILE_READ_ONLY -12 -#define FUNC_NOT_SUP -13 -#define BAD_FILENAME -14 -#define CANT_DEL_READ_ONLY -15 -#define HANDLE_NOT_EXIST -16 -#define ONE_WIRE_PORT_ERROR -17 -#define INVALID_DIRECTORY -18 -#define DIRECTORY_NOT_EMPTY -19 -#define UNABLE_TO_CREATE_DIR -20 -#define NO_PROGRAM_JOB -21 -#define PROGRAM_WRITE_PROTECT -22 -#define NON_PROGRAM_PARTS -23 -#define ADDFILE_TERMINATED -24 -#define TIMEOUT -25 -#define INVALID_ARGUMENT -26 -#define BAD_ACK -27 -#define INVALID_SESSION -200 -#define NO_BASDRV_FOUND -201 - -/* Basic physical level error codes */ -#define BPORT_NOT_INITIALIZED -1 -#define BPORT_NOT_EXIST -2 -#define BNO_SUCH_FUNCTION -3 - -/* Transport level error codes */ -#define TERROR_READ_WRITE -4 -#define TBUFFER_TOO_SMALL -5 -#define TDEVICE_TOO_SMALL -6 -#define TNO_DEVICE -7 -#define TBLOCK_TOO_BIG -8 -#define TWRONG_TYPE -9 -#define TPAGE_REDIRECTED -10 -#define TPROGRAM_NOT_POSSIBLE -11 -#define BCOM_FAILURE -12 -#define BCOM_EVENT -13 - -/* for TMOneWireLevel */ -#define LEVEL_NORMAL 0 -#define LEVEL_STRONG_PULLUP 1 -#define LEVEL_BREAK 2 -#define LEVEL_PROGRAM 3 -#define PRIMED_NONE 0 -#define PRIMED_BIT 1 -#define PRIMED_BYTE 2 -#define LEVEL_READ 1 -#define LEVEL_SET 0 - -/* misc */ -#define GENERAL_FAIL -2 -#define BAD_ARGUMENT 50 -#define NO_DRIVERS 51 -#define KEY_ABORT 52 -#define OUT_MEMORY 53 -#define NORMAL_EXIT 0 - -#define TRUE 1 -#define FALSE 0 -#define DIR_READ 1 -#define DIR_SET 0 -#define DIR_REMOVE 1 -#define DIR_MAKE 0 - -/* for specification */ -#define NOMEM 0 -#define NVRAM 1 -#define EPROM1 2 -#define EPROM2 3 -#define EPROM3 4 -#define EEPROM1 5 -#define MNVRAM 6 -#define EEPROM2 7 -#define NVRAM2 8 -#define NVRAM3 9 -#define FTR_REG_PAGES 0 -#define FTR_REG_LEN 1 -#define FTR_STAT_PAGES 2 -#define FTR_STAT_LEN 3 -#define FTR_MAX_COM 4 -#define FTR_MEM_TYPE 5 - -// session -extern long __fastcall TMExtendedStartSession(short, short, void far *); -extern short __fastcall TMValidSession(long); -extern short __fastcall TMEndSession(long); -extern short __fastcall Get_Version(char far *); -// file_operations -extern short __fastcall TMFirstFile(long, void far *, FileEntry far *); -extern short __fastcall TMNextFile(long, void far *, FileEntry far *); -extern short __fastcall TMOpenFile(long, void far *, FileEntry far *); -extern short __fastcall TMCreateFile(long, void far *, short far *, FileEntry far *); -extern short __fastcall TMCloseFile(long, void far *, short); -extern short __fastcall TMReadFile(long, void far *, short, uchar far *, short); -extern short __fastcall TMWriteFile(long, void far *, short, uchar far *, short); -extern short __fastcall TMDeleteFile(long, void far *, FileEntry far *); -extern short __fastcall TMFormat(long, void far *); -extern short __fastcall TMAttribute(long, void far *, short, FileEntry far *); -extern short __fastcall TMReNameFile(long, void far *, short, FileEntry far *); -extern short __fastcall TMChangeDirectory(long, void far *, short, DirectoryPath far *); -extern short __fastcall TMDirectoryMR(long, void far *, short, FileEntry far *); -extern short __fastcall TMCreateProgramJob(long, void far *); -extern short __fastcall TMDoProgramJob(long, void far *); -extern short __fastcall TMWriteAddFile(long, void far *, short, short, short, uchar far *, short); -extern short __fastcall TMTerminateAddFile(long, void far *, FileEntry far *); -extern short __fastcall TMGetFamilySpec(long, void far *, Specification *); -// transport -extern short __fastcall TMReadPacket(long, void far *, short, uchar far *, short); -extern short __fastcall TMWritePacket(long, void far *, short, uchar far *, short); -extern short __fastcall TMBlockIO(long, uchar far *, short); -extern short __fastcall TMExtendedReadPage(long, void far *, short, uchar far *, short); -extern short __fastcall TMProgramByte(long, void far *, short, short, short, short far *, short); -extern short __fastcall TMProgramBlock(long, void far *, uchar far *, short, short, short far *); /* (3.11) */ -extern long __fastcall TMCRC(short, uchar far *, ushort, short); -// network -extern short __fastcall TMSkipFamily(long, void far *); -extern short __fastcall TMFamilySearchSetup(long, void far *, short); -extern short __fastcall TMFirst(long, void far *); -extern short __fastcall TMNext(long, void far *); -extern short __fastcall TMAccess(long, void far *); -extern short __fastcall TMOverAccess(long, void far *); -extern short __fastcall TMStrongAccess(long, void far *); -extern short __fastcall TMStrongAlarmAccess(long, void far *); -extern short __fastcall TMRom(long, void far *, short far *); -extern short __fastcall TMFirstAlarm(long, void far *); -extern short __fastcall TMNextAlarm(long, void far *); -extern short __fastcall TMAutoOverDrive(long, void far *, short); -extern short __fastcall TMSearch(short, short, short, short); -// hardware_specific -extern short __fastcall TMSetup(long); -extern short __fastcall TMTouchByte(long, short); -extern short __fastcall TMTouchReset(long); -extern short __fastcall TMTouchBit(long, short); -extern short __fastcall TMClose(long); -extern short __fastcall TMProgramPulse(long); -extern short __fastcall TMOneWireCom(long, short, short); -extern short __fastcall TMOneWireLevel(long, short, short, short); -extern short __fastcall TMGetTypeVersion(short,char far *); -extern short __fastcall TMBlockStream(long, uchar far *, short); -extern short __fastcall TMGetAdapterSpec(long, Specification far *); -extern short __fastcall TMReadDefaultPort(short far *, short far *); - diff --git a/tools_cmd/rwOW/main.cpp b/tools_cmd/rwOW/main.cpp deleted file mode 100644 index fa6df19..0000000 --- a/tools_cmd/rwOW/main.cpp +++ /dev/null @@ -1,391 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS 1 -extern "C" { -#include "ownet.h" -} -#include -#include -#include - -FILE *fio; -char s[100], fname[254]; - - -SMALLINT ReadDS2430(int portnum, uchar SerialNum[8]) { - uchar rt = FALSE; - uchar send_block[145]; - uchar send_cnt = 0, i; - int address; - char s[100]; - FILE *f; - sprintf(s, "%02X%02X%02X%02X%02X%02X%02X%02X.bin", SerialNum[7], SerialNum[6], SerialNum[5], SerialNum[4], SerialNum[3], SerialNum[2], SerialNum[1], SerialNum[0]); - fprintf(fio, ">14\n"); - send_cnt = 0; - printf("Read Data MEM \n"); - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[send_cnt++] = 0xF0; - send_block[send_cnt++] = 0x00; - for (i = 0; i<32; i++) send_block[send_cnt++] = 0xFF; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - for (i = 2; i TEST DS2433 \n"); - fprintf(fio, ">23\n"); - - send_cnt = 0; - printf("\nRead MEM ALL \n"); - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[send_cnt++] = 0xF0; - send_block[send_cnt++] = 0x00; - send_block[send_cnt++] = 0x00; - for (j = 0; j<16; j++) { - for (i = 0; i<32; i++) send_block[send_cnt++] = 0xFF; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - for (i = j?0:3; i < send_cnt; i++) { printf("%02X ", send_block[i]); fprintf(fio, "%02X ", send_block[i]); } - send_cnt = 0; - printf("\n"); - fprintf(fio, "\n"); - } - -} - - -int findDev(uchar code) { - int find = 0; - fio = fopen(fname, "r"); - while (!feof(fio)) { - s[0] = fgetc(fio); - if (s[0] == '>') { - s[0] = fgetc(fio); - s[1] = fgetc(fio); - s[2] = 0; - uchar w = strtol(s, NULL, 16); - if (code ==w) return 1; - } - } - fclose(fio); - return 0; -} - - - -SMALLINT WriteDS2433(int portnum, uchar SerialNum[8]) { - uchar rt = FALSE; - uchar send_block[145]; - uchar send_cnt = 0, i, j; - int address; - send_cnt = 0; - printf("-----> TEST DS2433 \n"); - if (findDev(0x23)) { - for (j = 0; j < 16; j++) { - for (i = 0; i < 32; i++) { - fscanf(fio, "%02X", &send_block[i + 3]); - } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[0] = 0x0F; - send_block[1] = j << 5; - send_block[2] = j >> 3; - if (!owBlock(portnum, FALSE, send_block, 32 + 3)) { printf("ERROR RUN COMMAND \n"); return 1; } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_cnt = 0; - send_block[send_cnt++] = 0xAA; - for (i = 0; i < 32 + 3; i++) send_block[send_cnt++] = 0xFF; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - for (i = 0; i < send_cnt; i++) { printf("%02X ", send_block[i]); } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_cnt = 0; - send_block[send_cnt++] = 0x55; - send_cnt += 3; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - msDelay(100); - printf("\n"); - } - - } - fclose(fio); - return 0; - - -} - - -SMALLINT WriteDS2430(int portnum, uchar SerialNum[8]) { - uchar rt = FALSE; - uchar send_block[145]; - uchar send_cnt = 0, i, j; - int address; - send_cnt = 0; - printf("-----> TEST DS2430 \n"); - if (findDev(0x14)) { - for (i = 0; i < 32; i++) { - fscanf(fio, "%02X", &send_block[i + 2]); - } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[0] = 0x0F; - send_block[1] = 0; - if (!owBlock(portnum, FALSE, send_block, 32 + 2)) { printf("ERROR RUN COMMAND \n"); return 1; } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_cnt = 0; - send_block[send_cnt++] = 0xAA; - send_block[send_cnt++] = 0x00; - for (i = 0; i < 32 + 2; i++) send_block[send_cnt++] = 0xFF; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - for (i = 0; i < send_cnt; i++) { printf("%02X ", send_block[i]); } - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_cnt = 0; - send_block[send_cnt++] = 0x55; - send_block[send_cnt++] = 0xA5; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - msDelay(100); - printf("\n"); - } - fclose(fio); - -} -/* -SMALLINT WriteDS2430(int portnum, uchar SerialNum[8], const char *fname) { - uchar rt = FALSE; - uchar send_block[145]; - uchar send_cnt = 0, i; - int address; - uchar readbl[64]; - FILE *f; - f = fopen(fname, "rb"); - fread(readbl, 1, 32 + 16, f); - fclose(f); - ResetDS2430(portnum, SerialNum); - msDelay(1000); - send_cnt = 0; - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[send_cnt++] = 0x0F; - send_block[send_cnt++] = 0x00; - for (i = 0; i<32; i++) send_block[send_cnt++] = readbl[i + 8]; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - send_cnt = 0; - if (!owAccess(portnum)) { printf("ERROR MATCH ROM \n"); return 1; } - send_block[send_cnt++] = 0xAA; - send_block[send_cnt++] = 0x00; - for (i = 0; i<32; i++) send_block[send_cnt++] = 0xFF; - if (!owBlock(portnum, FALSE, send_block, send_cnt)) { printf("ERROR RUN COMMAND \n"); return 1; } - for (i = 0; i= '0') && (s[i] <= '9')) { - b += s[i] - '0'; - } else - if ((s[i] >= 'A') && (s[i] <= 'F')) { - b += s[i] - 'A'+10; - } else - if ((s[i] >= 'a') && (s[i] <= 'f')) { - b += s[i] - 'a'+10; - } - - } - return b; -} - -void strcpys(char *s, const char* d,bool up) { - if (strlen(d) > 7990) { - strncpy(s, d, 7990); - s[200] = 0; - } - else strcpy(s, d); - if (up) { - for (int i = 0; i= 'a') && (s[i] <= 'z')) - s[i] += 'A' - 'a'; - } -} - -int main(int argc, char *argv[]) { - uchar SNum[8]; - int rslt, cnt, i; - uchar send_block[256]; - uchar send_cnt = 0; - int portnum; - char adapter[20]; - int found = 0; - int rw = 0; - int err = 0; - char s[8000]; - int adt = 0; - int mod = 0; - if (argc >= 2) { - strcpys(s, argv[1],true); - - - if (strncmp(s,"USB",3)==0) {adt = 6;} - if (strncmp(s, "COM", 3) == 0) { adt = 5; } - if (adt != 0) { - strcpy(s, argv[1] + 3); - sprintf(adapter, "{%s,%i}\0",s,adt); - printf("Open Port %s\n", argv[1]); - if ((portnum = owAcquireEx(adapter)) < 0) { - printf("ERROR \n", adt); - } - else mod = 1; - - } - if ((argc == 2) && (mod == 1)) mod = 2; - if (argc > 2) { - strcpys(s, argv[2],true); - if (strncmp(s, "DC", 2) == 0) { - if (argc > 3) { - if (strlen(argv[3])>=16) - for (int i = 0; i < 16; i += 2) { - SNum[7 - (i / 2)] = conf2(argv[3] + i); - - } - printf("Select: %02X%02X%02X%02X%02X%02X%02X%02X\n", SNum[7], SNum[6], SNum[5], SNum[4], SNum[3], SNum[2], SNum[1], SNum[0]); - mod = 3; - } - - } - } - if ((mod == 3) && (argc>4)) { - strcpys(s, argv[4], true); - mod = 4; - } - - } - - if (mod == 2) { - rslt = owFirst(portnum, TRUE, FALSE); - cnt = 0; - while (rslt) { - cnt++; - owSerialNum(portnum, &SNum[0], TRUE); - printf("%02X%02X%02X%02X%02X%02X%02X%02X\n", SNum[7], SNum[6], SNum[5], SNum[4], SNum[3], SNum[2], SNum[1], SNum[0]); - // fprintf(ft,"%02X%02X%02X%02X%02X%02X%02X%02X\n",SNum[7],SNum[6],SNum[5],SNum[4],SNum[3],SNum[2],SNum[1],SNum[0]); -/* switch (SNum[0]) { - - - case 0x14: { - //TestDS2430(portnum,&SNum[0]); - //scanf("%i",&i); - //ResetDS2430(portnum,&SNum[0]); - //uchar id[]={0x14,0xF5 ,0xEA ,0x24 ,0x06 ,0x00 ,0x00 ,0x5E}; - //SetIDDS2430(portnum,&SNum[0],id); - if (rw) WriteDS2430(portnum, &SNum[0]); else ReadDS2430(portnum, &SNum[0]); - //WriteDS2430(portnum,&SNum[0],"5E00000624EAF514.bin"); - break; - } - case 0x23: { - //TestDS2433(portnum,&SNum[0]); - //TestDS2433_reset(portnum,&SNum[0]); - //scanf("%i",&i); - if (rw) WriteDS2433(portnum, &SNum[0]); else ReadDS2433(portnum, &SNum[0]); - break; - } - }*/ - rslt = owNext(portnum, TRUE, FALSE); - } - } - if (mod == 4) { - owSerialNum(portnum, SNum, FALSE); - strcat(s, "_R"); - int len = strlen(s); - int i = 0; - while (i < len) { - if (s[i] == '_') { - if (s[i + 1] == 'R') { - if (owAccess(portnum)) { - if (owBlock(portnum, FALSE, send_block, send_cnt)) { - for (int j = 0; j < send_cnt; j++) { - printf("%02X", send_block[j]); - } - printf("\n"); - } - else printf("ERROR RESET\n"); - } - else printf("ERROR SEND\n"); - send_cnt = 0; - } - if (s[i + 1] == 'P') { - if (i + 2 < len) { - i += 2; - msDelay(conf2(s + i)); - - } - } - } - else { - send_block[send_cnt++] = conf2(s + i); - } - i += 2; - - - } - } - if (mod>0) owRelease(portnum); - - return 0; -} \ No newline at end of file diff --git a/tools_cmd/rwOW/owerr.c b/tools_cmd/rwOW/owerr.c deleted file mode 100644 index 76c5176..0000000 --- a/tools_cmd/rwOW/owerr.c +++ /dev/null @@ -1,348 +0,0 @@ -//--------------------------------------------------------------------------- -// 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. -//--------------------------------------------------------------------------- -// -// owerr.c - Library functions for error handling with 1-Wire library -// -// Version: 1.00 -// - -#include -#ifndef _WIN32_WCE -#include -#endif -#ifdef _WIN64 -#include -#endif -#include "ownet.h" - -#ifndef SIZE_OWERROR_STACK - #ifdef SMALL_MEMORY_TARGET - //for small memory, only hole 1 error - #define SIZE_OWERROR_STACK 1 - #else - #define SIZE_OWERROR_STACK 10 - #endif -#endif - -//--------------------------------------------------------------------------- -// Variables -//--------------------------------------------------------------------------- - -// Error Struct for holding error information. -// In DEBUG, this will also hold the line number and filename. -typedef struct -{ - int owErrorNum; -#ifdef DEBUG - int lineno; - char *filename; -#endif -} owErrorStruct; - -// Ring-buffer used for stack. -// In case of overflow, deepest error is over-written. -static owErrorStruct owErrorStack[SIZE_OWERROR_STACK]; - -// Stack pointer to top-most error. -static int owErrorPointer = 0; - - -//--------------------------------------------------------------------------- -// Functions Definitions -//--------------------------------------------------------------------------- -int owGetErrorNum(void); -void owClearError(void); -int owHasErrors(void); -#ifdef DEBUG - void owRaiseError(int,int,char*); -#else - void owRaiseError(int); -#endif -#ifndef SMALL_MEMORY_TARGET - void owPrintErrorMsg(FILE *); - void owPrintErrorMsgStd(); - char *owGetErrorMsg(int); -#endif - - -//-------------------------------------------------------------------------- -// The 'owGetErroNum' returns the error code of the top-most error on the -// error stack. NOTE: This function has the side effect of popping the -// current error off the stack. All successive calls to 'owGetErrorNum' -// will further clear the error stack. -// -// For list of error codes, see 'ownet.h' -// -// Returns: int : The error code of the top-most error on the stack -// -int owGetErrorNum(void) -{ - int i = owErrorStack[ owErrorPointer ].owErrorNum; - owErrorStack[ owErrorPointer ].owErrorNum = 0; - if(!owErrorPointer) - owErrorPointer = SIZE_OWERROR_STACK - 1; - else - owErrorPointer = (owErrorPointer - 1); - return i; -} - -//-------------------------------------------------------------------------- -// The 'owClearError' clears all the errors. -// -void owClearError(void) -{ - owErrorStack[ owErrorPointer ].owErrorNum = 0; -} - -//-------------------------------------------------------------------------- -// The 'owHasErrors' is a boolean test function which tests whether or not -// a valid error is waiting on the stack. -// -// Returns: TRUE (1) : When there are errors on the stack. -// FALSE (0): When stack's errors are set to 0, or NO_ERROR_SET. -// -int owHasErrors(void) -{ - if(owErrorStack[ owErrorPointer ].owErrorNum) - return 1; //TRUE - else - return 0; //FALSE -} - -#ifdef DEBUG - //-------------------------------------------------------------------------- - // The 'owRaiseError' is the method for raising an error onto the error - // stack. - // - // Arguments: int err - the error code you wish to raise. - // int lineno - DEBUG only - the line number where it was raised - // char* filename - DEBUG only - the file name where it occured. - // - void owRaiseError(int err, int lineno, char* filename) - { - owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK; - owErrorStack[ owErrorPointer ].owErrorNum = err; - owErrorStack[ owErrorPointer ].lineno = lineno; - owErrorStack[ owErrorPointer ].filename = filename; - } -#else - //-------------------------------------------------------------------------- - // The 'owRaiseError' is the method for raising an error onto the error - // stack. - // - // Arguments: int err - the error code you wish to raise. - // - void owRaiseError(int err) - { - owErrorPointer = (owErrorPointer + 1) % SIZE_OWERROR_STACK; - owErrorStack[ owErrorPointer ].owErrorNum = err; - } -#endif - - -// SMALL_MEMORY_TARGET - embedded microcontrollers, where these -// messaging functions might not make any sense. -#ifndef SMALL_MEMORY_TARGET - //Array of meaningful error messages to associate with codes. - //Not used on targets with low memory (i.e. PIC). - static char *owErrorMsg[125] = - { - /*000*/ "No Error Was Set", - /*001*/ "No Devices found on 1-Wire Network", - /*002*/ "1-Wire Net Reset Failed", - /*003*/ "Search ROM Error: Couldn't locate next device on 1-Wire", - /*004*/ "Access Failed: Could not select device", - /*005*/ "DS2480B Adapter Not Detected", - /*006*/ "DS2480B: Wrong Baud", - /*007*/ "DS2480B: Bad Response", - /*008*/ "Open COM Failed", - /*009*/ "Write COM Failed", - /*010*/ "Read COM Failed", - /*011*/ "Data Block Too Large", - /*012*/ "Block Transfer failed", - /*013*/ "Program Pulse Failed", - /*014*/ "Program Byte Failed", - /*015*/ "Write Byte Failed", - /*016*/ "Read Byte Failed", - /*017*/ "Write Verify Failed", - /*018*/ "Read Verify Failed", - /*019*/ "Write Scratchpad Failed", - /*020*/ "Copy Scratchpad Failed", - /*021*/ "Incorrect CRC Length", - /*022*/ "CRC Failed", - /*023*/ "Failed to acquire a necessary system resource", - /*024*/ "Failed to initialize system resource", - /*025*/ "Data too long to fit on specified device.", - /*026*/ "Read exceeds memory bank end.", - /*027*/ "Write exceeds memory bank end.", - /*028*/ "Device select failed", - /*029*/ "Read Scratch Pad verify failed.", - /*030*/ "Copy scratchpad complete not found", - /*031*/ "Erase scratchpad complete not found", - /*032*/ "Address read back from scrachpad was incorrect", - /*033*/ "Read page with extra-info not supported by this memory bank", - /*034*/ "Read page packet with extra-info not supported by this memory bank", - /*035*/ "Length of packet requested exceeds page size", - /*036*/ "Invalid length in packet", - /*037*/ "Program pulse required but not available", - /*038*/ "Trying to access a read-only memory bank", - /*039*/ "Current bank is not general purpose memory", - /*040*/ "Read back from write compare is incorrect, page may be locked", - /*041*/ "Invalid page number for this memory bank", - /*042*/ "Read page with CRC not supported by this memory bank", - /*043*/ "Read page with CRC and extra-info not supported by this memory bank", - /*044*/ "Read back from write incorrect, could not lock page", - /*045*/ "Read back from write incorrect, could not lock redirect byte", - /*046*/ "The read of the status was not completed.", - /*047*/ "Page redirection not supported by this memory bank", - /*048*/ "Lock Page redirection not supported by this memory bank", - /*049*/ "Read back byte on EPROM programming did not match.", - /*050*/ "Can not write to a page that is locked.", - /*051*/ "Can not lock a redirected page that has already been locked.", - /*052*/ "Trying to redirect a locked redirected page.", - /*053*/ "Trying to lock a page that is already locked.", - /*054*/ "Trying to write to a memory bank that is write protected.", - /*055*/ "Error due to not matching MAC.", - /*056*/ "Memory Bank is write protected.", - /*057*/ "Secret is write protected, can not Load First Secret.", - /*058*/ "Error in Reading Scratchpad after Computing Next Secret.", - /*059*/ "Load Error from Loading First Secret.", - /*060*/ "Power delivery required but not available", - /*061*/ "Not a valid file name.", - /*062*/ "Unable to Create a Directory in this part.", - /*063*/ "That file already exists.", - /*064*/ "The directory is not empty.", - /*065*/ "The wrong type of part for this operation.", - /*066*/ "The max len for this file is too small.", - /*067*/ "This is not a write once bank.", - /*068*/ "The file can not be found.", - /*069*/ "There is not enough space available.", - /*070*/ "There is not a page to match that bit in the bitmap.", - /*071*/ "There are no jobs for EPROM parts.", - /*072*/ "Function not supported to modify attributes.", - /*073*/ "Handle is not in use.", - /*074*/ "Tring to read a write only file.", - /*075*/ "There is no handle available for use.", - /*076*/ "The directory provided is an invalid directory.", - /*077*/ "Handle does not exist.", - /*078*/ "Serial Number did not match with current job.", - /*079*/ "Can not program EPROM because a non-EPROM part on the network.", - /*080*/ "Write protect redirection byte is set.", - /*081*/ "There is an inappropriate directory length.", - /*082*/ "The file has already been terminated.", - /*083*/ "Failed to read memory page of iButton part.", - /*084*/ "Failed to match scratchpad of iButton part.", - /*085*/ "Failed to erase scratchpad of iButton part.", - /*086*/ "Failed to read scratchpad of iButton part.", - /*087*/ "Failed to execute SHA function on SHA iButton.", - /*088*/ "SHA iButton did not return a status completion byte.", - /*089*/ "Write data page failed.", - /*090*/ "Copy secret into secret memory pages failed.", - /*091*/ "Bind unique secret to iButton failed.", - /*092*/ "Could not install secret into user token.", - /*093*/ "Transaction Incomplete: signature did not match.", - /*094*/ "Transaction Incomplete: could not sign service data.", - /*095*/ "User token did not provide a valid authentication response.", - /*096*/ "Failed to answer a challenge on the user token.", - /*097*/ "Failed to create a challenge on the coprocessor.", - /*098*/ "Transaction Incomplete: service data was not valid.", - /*099*/ "Transaction Incomplete: service data was not updated.", - /*100*/ "Unrecoverable, catastrophic service failure occured.", - /*101*/ "Load First Secret from scratchpad data failed.", - /*102*/ "Failed to match signature of user's service data.", - /*103*/ "Subkey out of range for the DS1991.", - /*104*/ "Block ID out of range for the DS1991", - /*105*/ "Password is enabled", - /*106*/ "Password is invalid", - /*107*/ "This memory bank has no read only password", - /*108*/ "This memory bank has no read/write password", - /*109*/ "1-Wire is shorted", - /*110*/ "Error communicating with 1-Wire adapter", - /*111*/ "CopyScratchpad failed: Ending Offset must go to end of page", - /*112*/ "WriteScratchpad failed: Ending Offset must go to end of page", - /*113*/ "Mission can not be stopped while one is not in progress", - /*114*/ "Error stopping the mission", - /*115*/ "Port number is outside (0,MAX_PORTNUM) interval", - /*116*/ "Level of the 1-Wire was not changed", - /*117*/ "Both the Read Only and Read Write Passwords must be set", - /*118*/ "Failure to change latch state." - /*119*/ "Could not open usb port through libusb", - /*120*/ "Libusb DS2490 port already opened", - /*121*/ "Failed to set libusb configuration", - /*122*/ "Failed to claim libusb interface", - /*123*/ "Failed to set libusb altinterface", - /*124*/ "No adapter found at this port number" - }; - - char *owGetErrorMsg(int err) - { - return owErrorMsg[err]; - } - -#ifndef __C51__ - //-------------------------------------------------------------------------- - // The 'owPrintErrorMsg' is the method for printing an error from the stack. - // The destination for the print is specified by the argument, fileno, which - // can be stderr, stdout, or a log file. In non-debug mode, the output is - // of the form: - // Error num: Error msg - // - // In debug-mode, the output is of the form: - // Error num: filename line#: Error msg - // - // NOTE: This function has the side-effect of popping the error off the stack. - // - // Arguments: FILE*: the destination for printing. - // - void owPrintErrorMsg(FILE *filenum) - { - #ifdef DEBUG - int l = owErrorStack[ owErrorPointer ].lineno; - char *f = owErrorStack[ owErrorPointer ].filename; - int err = owGetErrorNum(); - fprintf(filenum,"Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]); - #else - int err = owGetErrorNum(); - fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]); - #endif - } -#endif //__C51__ - - // Same as above, except uses default printf output - void owPrintErrorMsgStd() - { - #ifdef DEBUG - int l = owErrorStack[ owErrorPointer ].lineno; - char *f = owErrorStack[ owErrorPointer ].filename; - int err = owGetErrorNum(); - printf("Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]); - #else - int err = owGetErrorNum(); - printf("Error %d: %s\r\n",err,owErrorMsg[err]); - #endif - } -#endif - diff --git a/tools_cmd/rwOW/ownet.h b/tools_cmd/rwOW/ownet.h deleted file mode 100644 index 7c0c144..0000000 --- a/tools_cmd/rwOW/ownet.h +++ /dev/null @@ -1,422 +0,0 @@ -//--------------------------------------------------------------------------- -// 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. -//--------------------------------------------------------------------------- -// -// ownet.h - Include file for 1-Wire Net library -// -// Version: 2.10 -// -// History: 1.02 -> 1.03 Make sure uchar is not defined twice. -// 1.03 -> 2.00 Changed 'MLan' to 'ow'. -// 2.00 -> 2.01 Added error handling. Added circular-include check. -// 2.01 -> 2.10 Added raw memory error handling and SMALLINT -// 2.10 -> 3.00 Added memory bank functionality -// Added file I/O operations -// - -#ifndef OWNET_H -#define OWNET_H - -//--------------------------------------------------------------// -// Common Includes to ownet applications -//--------------------------------------------------------------// -#include - - -//--------------------------------------------------------------// -// Target Specific Information -//--------------------------------------------------------------// -//--------------------------------------------------------------// -// Handhelds (PalmOS, WinCE) -//--------------------------------------------------------------// -#ifdef __MC68K__ - //MC68K is the type of processor in the PILOT - //Metrowerk's CodeWarrior defines this symbol - #include - #ifndef strcmp - #include - #define strcmp StrCompare - #endif - #include -#endif - -#ifdef _WIN32_WCE - //All of our projects had this flag defined by default (_WIN32_WCE), - //but I'm not 100% positive that this is _the_ definitive - //flag to use to identify a WinCE system. - #include "WinCElnk.h" - #ifndef FILE - #define FILE int - extern int sprintf(char *buffer, char *format,...); - extern void fprintf(FILE *fp, char *format,...); - extern void printf(char *format,...); - #endif -#endif - -#if !defined(_WIN32_WCE) && !defined(__MC68K__) - #include -#endif - -#ifdef __C51__ - #define FILE int - #define exit(c) return - typedef unsigned int ushort; - typedef unsigned long ulong; - #define SMALLINT uchar -#endif - -#ifdef __ICCMAXQ__ - #define FILE int - #define stdout 0 - #define stdin 1 - #define stderr 2 - typedef unsigned int ushort; - typedef unsigned long ulong; - #define SMALLINT short - #define main micro_main - #define real_main main - #define SMALL_MEMORY_TARGET -#endif - - -//--------------------------------------------------------------// -// Typedefs -//--------------------------------------------------------------// -#ifndef SMALLINT - // - // purpose of smallint is for compile-time changing of formal - // parameters and return values of functions. For each target - // machine, an integer is alleged to represent the most "simple" - // number representable by that architecture. This should, in - // most cases, produce optimal code for that particular arch. - // BUT... The majority of compilers designed for embedded - // processors actually keep an int at 16 bits, although the - // architecture might only be comfortable with 8 bits. - // The default size of smallint will be the same as that of - // an integer, but this allows for easy overriding of that size. - // - // NOTE: - // In all cases where a smallint is used, it is assumed that - // decreasing the size of this integer to something as low as - // a single byte _will_not_ change the functionality of the - // application. e.g. a loop counter that will iterate through - // several kilobytes of data should not be SMALLINT. The most - // common place you'll see smallint is for boolean return types. - // - #define SMALLINT int -#endif - -// setting max baud -#ifdef _WINDOWS - // 0x02 = PARAMSET_19200 -#define MAX_BAUD 0x02 -#else - // 0x06 = PARMSET_115200 -#define MAX_BAUD 0x06 -#endif - -#ifndef OW_UCHAR - #define OW_UCHAR - typedef unsigned char uchar; - #if !defined(__MINGW32__) && (defined(__CYGWIN__) || defined(__GNUC__)) - typedef unsigned long ulong; - //ushort already defined in sys/types.h - #include - #else - #if defined(_WIN32) || defined(WIN32) || defined(__MC68K__) || defined(_WIN32_WCE) || defined(_DOS) || defined(_WINDOWS) || defined(__MINGW32__) - typedef unsigned short ushort; - typedef unsigned long ulong; - #endif - #endif - #ifdef __sun__ - #include - #endif - #ifdef SDCC - //intent of ushort is 2 bytes unsigned. - //for ds390 in sdcc, an int, not a short, - //is 2 bytes. - typedef unsigned int ushort; - #endif -#endif - -// general defines -#define WRITE_FUNCTION 1 -#define READ_FUNCTION 0 - -// error codes -// todo: investigate these and replace with new Error Handling library -#define READ_ERROR -1 -#define INVALID_DIR -2 -#define NO_FILE -3 -#define WRITE_ERROR -4 -#define WRONG_TYPE -5 -#define FILE_TOO_BIG -6 - -// Misc -#define FALSE 0 -#define TRUE 1 - -#ifndef MAX_PORTNUM - #define MAX_PORTNUM 16 -#endif - -// mode bit flags -#define MODE_NORMAL 0x00 -#define MODE_OVERDRIVE 0x01 -#define MODE_STRONG5 0x02 -#define MODE_PROGRAM 0x04 -#define MODE_BREAK 0x08 - -// Output flags -#define LV_ALWAYS 2 -#define LV_OPTIONAL 1 -#define LV_VERBOSE 0 - -//--------------------------------------------------------------// -// Error handling -//--------------------------------------------------------------// -extern int owGetErrorNum(void); -extern int owHasErrors(void); - -//Clears the stack. -#define OWERROR_CLEAR() while(owHasErrors()) owGetErrorNum(); - -#ifdef DEBUG - //Raises an exception with extra debug info - #define OWERROR(err) owRaiseError(err,__LINE__,__FILE__) - extern void owRaiseError(int,int,char*); - #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err),__LINE__,__FILE__);return (ret);} -#else - //Raises an exception with just the error code - #define OWERROR(err) owRaiseError(err) - extern void owRaiseError(int); - #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err));return (ret);} -#endif - -#ifdef SMALL_MEMORY_TARGET - #define OWERROR_DUMP(fileno) /*no-op*/; -#else - //Prints the stack out to the given file. - #define OWERROR_DUMP(fileno) while(owHasErrors()) owPrintErrorMsg(fileno); - extern void owPrintErrorMsg(FILE *); - extern void owPrintErrorMsgStd(); - extern char *owGetErrorMsg(int); -#endif - -#define OWERROR_NO_ERROR_SET 0 -#define OWERROR_NO_DEVICES_ON_NET 1 -#define OWERROR_RESET_FAILED 2 -#define OWERROR_SEARCH_ERROR 3 -#define OWERROR_ACCESS_FAILED 4 -#define OWERROR_DS2480_NOT_DETECTED 5 -#define OWERROR_DS2480_WRONG_BAUD 6 -#define OWERROR_DS2480_BAD_RESPONSE 7 -#define OWERROR_OPENCOM_FAILED 8 -#define OWERROR_WRITECOM_FAILED 9 -#define OWERROR_READCOM_FAILED 10 -#define OWERROR_BLOCK_TOO_BIG 11 -#define OWERROR_BLOCK_FAILED 12 -#define OWERROR_PROGRAM_PULSE_FAILED 13 -#define OWERROR_PROGRAM_BYTE_FAILED 14 -#define OWERROR_WRITE_BYTE_FAILED 15 -#define OWERROR_READ_BYTE_FAILED 16 -#define OWERROR_WRITE_VERIFY_FAILED 17 -#define OWERROR_READ_VERIFY_FAILED 18 -#define OWERROR_WRITE_SCRATCHPAD_FAILED 19 -#define OWERROR_COPY_SCRATCHPAD_FAILED 20 -#define OWERROR_INCORRECT_CRC_LENGTH 21 -#define OWERROR_CRC_FAILED 22 -#define OWERROR_GET_SYSTEM_RESOURCE_FAILED 23 -#define OWERROR_SYSTEM_RESOURCE_INIT_FAILED 24 -#define OWERROR_DATA_TOO_LONG 25 -#define OWERROR_READ_OUT_OF_RANGE 26 -#define OWERROR_WRITE_OUT_OF_RANGE 27 -#define OWERROR_DEVICE_SELECT_FAIL 28 -#define OWERROR_READ_SCRATCHPAD_VERIFY 29 -#define OWERROR_COPY_SCRATCHPAD_NOT_FOUND 30 -#define OWERROR_ERASE_SCRATCHPAD_NOT_FOUND 31 -#define OWERROR_ADDRESS_READ_BACK_FAILED 32 -#define OWERROR_EXTRA_INFO_NOT_SUPPORTED 33 -#define OWERROR_PG_PACKET_WITHOUT_EXTRA 34 -#define OWERROR_PACKET_LENGTH_EXCEEDS_PAGE 35 -#define OWERROR_INVALID_PACKET_LENGTH 36 -#define OWERROR_NO_PROGRAM_PULSE 37 -#define OWERROR_READ_ONLY 38 -#define OWERROR_NOT_GENERAL_PURPOSE 39 -#define OWERROR_READ_BACK_INCORRECT 40 -#define OWERROR_INVALID_PAGE_NUMBER 41 -#define OWERROR_CRC_NOT_SUPPORTED 42 -#define OWERROR_CRC_EXTRA_INFO_NOT_SUPPORTED 43 -#define OWERROR_READ_BACK_NOT_VALID 44 -#define OWERROR_COULD_NOT_LOCK_REDIRECT 45 -#define OWERROR_READ_STATUS_NOT_COMPLETE 46 -#define OWERROR_PAGE_REDIRECTION_NOT_SUPPORTED 47 -#define OWERROR_LOCK_REDIRECTION_NOT_SUPPORTED 48 -#define OWERROR_READBACK_EPROM_FAILED 49 -#define OWERROR_PAGE_LOCKED 50 -#define OWERROR_LOCKING_REDIRECTED_PAGE_AGAIN 51 -#define OWERROR_REDIRECTED_PAGE 52 -#define OWERROR_PAGE_ALREADY_LOCKED 53 -#define OWERROR_WRITE_PROTECTED 54 -#define OWERROR_NONMATCHING_MAC 55 -#define OWERROR_WRITE_PROTECT 56 -#define OWERROR_WRITE_PROTECT_SECRET 57 -#define OWERROR_COMPUTE_NEXT_SECRET 58 -#define OWERROR_LOAD_FIRST_SECRET 59 -#define OWERROR_POWER_NOT_AVAILABLE 60 -#define OWERROR_XBAD_FILENAME 61 -#define OWERROR_XUNABLE_TO_CREATE_DIR 62 -#define OWERROR_REPEAT_FILE 63 -#define OWERROR_DIRECTORY_NOT_EMPTY 64 -#define OWERROR_WRONG_TYPE 65 -#define OWERROR_BUFFER_TOO_SMALL 66 -#define OWERROR_NOT_WRITE_ONCE 67 -#define OWERROR_FILE_NOT_FOUND 68 -#define OWERROR_OUT_OF_SPACE 69 -#define OWERROR_TOO_LARGE_BITNUM 70 -#define OWERROR_NO_PROGRAM_JOB 71 -#define OWERROR_FUNC_NOT_SUP 72 -#define OWERROR_HANDLE_NOT_USED 73 -#define OWERROR_FILE_WRITE_ONLY 74 -#define OWERROR_HANDLE_NOT_AVAIL 75 -#define OWERROR_INVALID_DIRECTORY 76 -#define OWERROR_HANDLE_NOT_EXIST 77 -#define OWERROR_NONMATCHING_SNUM 78 -#define OWERROR_NON_PROGRAM_PARTS 79 -#define OWERROR_PROGRAM_WRITE_PROTECT 80 -#define OWERROR_FILE_READ_ERR 81 -#define OWERROR_ADDFILE_TERMINATED 82 -#define OWERROR_READ_MEMORY_PAGE_FAILED 83 -#define OWERROR_MATCH_SCRATCHPAD_FAILED 84 -#define OWERROR_ERASE_SCRATCHPAD_FAILED 85 -#define OWERROR_READ_SCRATCHPAD_FAILED 86 -#define OWERROR_SHA_FUNCTION_FAILED 87 -#define OWERROR_NO_COMPLETION_BYTE 88 -#define OWERROR_WRITE_DATA_PAGE_FAILED 89 -#define OWERROR_COPY_SECRET_FAILED 90 -#define OWERROR_BIND_SECRET_FAILED 91 -#define OWERROR_INSTALL_SECRET_FAILED 92 -#define OWERROR_VERIFY_SIG_FAILED 93 -#define OWERROR_SIGN_SERVICE_DATA_FAILED 94 -#define OWERROR_VERIFY_AUTH_RESPONSE_FAILED 95 -#define OWERROR_ANSWER_CHALLENGE_FAILED 96 -#define OWERROR_CREATE_CHALLENGE_FAILED 97 -#define OWERROR_BAD_SERVICE_DATA 98 -#define OWERROR_SERVICE_DATA_NOT_UPDATED 99 -#define OWERROR_CATASTROPHIC_SERVICE_FAILURE 100 -#define OWERROR_LOAD_FIRST_SECRET_FAILED 101 -#define OWERROR_MATCH_SERVICE_SIGNATURE_FAILED 102 -#define OWERROR_KEY_OUT_OF_RANGE 103 -#define OWERROR_BLOCK_ID_OUT_OF_RANGE 104 -#define OWERROR_PASSWORDS_ENABLED 105 -#define OWERROR_PASSWORD_INVALID 106 -#define OWERROR_NO_READ_ONLY_PASSWORD 107 -#define OWERROR_NO_READ_WRITE_PASSWORD 108 -#define OWERROR_OW_SHORTED 109 -#define OWERROR_ADAPTER_ERROR 110 -#define OWERROR_EOP_COPY_SCRATCHPAD_FAILED 111 -#define OWERROR_EOP_WRITE_SCRATCHPAD_FAILED 112 -#define OWERROR_HYGRO_STOP_MISSION_UNNECESSARY 113 -#define OWERROR_HYGRO_STOP_MISSION_ERROR 114 -#define OWERROR_PORTNUM_ERROR 115 -#define OWERROR_LEVEL_FAILED 116 -#define OWERROR_PASSWORD_NOT_SET 117 -#define OWERROR_LATCH_NOT_SET 118 -#define OWERROR_LIBUSB_OPEN_FAILED 119 -#define OWERROR_LIBUSB_DEVICE_ALREADY_OPENED 120 -#define OWERROR_LIBUSB_SET_CONFIGURATION_ERROR 121 -#define OWERROR_LIBUSB_CLAIM_INTERFACE_ERROR 122 -#define OWERROR_LIBUSB_SET_ALTINTERFACE_ERROR 123 -#define OWERROR_LIBUSB_NO_ADAPTER_FOUND 124 - -// One Wire functions defined in ownetu.c -SMALLINT owFirst(int portnum, SMALLINT do_reset, SMALLINT alarm_only); -SMALLINT owNext(int portnum, SMALLINT do_reset, SMALLINT alarm_only); -void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read); -void owFamilySearchSetup(int portnum, SMALLINT search_family); -void owSkipFamily(int portnum); -SMALLINT owAccess(int portnum); -SMALLINT owVerify(int portnum, SMALLINT alarm_only); -SMALLINT owOverdriveAccess(int portnum); - - -// external One Wire functions defined in owsesu.c - SMALLINT owAcquire(int portnum, char *port_zstr); - int owAcquireEx(char *port_zstr); - void owRelease(int portnum); - -// external One Wire functions defined in findtype.c -// SMALLINT FindDevices(int,uchar FamilySN[][8],SMALLINT,int); - -// external One Wire functions from link layer owllu.c -SMALLINT owTouchReset(int portnum); -SMALLINT owTouchBit(int portnum, SMALLINT sendbit); -SMALLINT owTouchByte(int portnum, SMALLINT sendbyte); -SMALLINT owWriteByte(int portnum, SMALLINT sendbyte); -SMALLINT owReadByte(int portnum); -SMALLINT owSpeed(int portnum, SMALLINT new_speed); -SMALLINT owLevel(int portnum, SMALLINT new_level); -SMALLINT owProgramPulse(int portnum); -SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte); -SMALLINT owReadBytePower(int portnum); -SMALLINT owHasPowerDelivery(int portnum); -SMALLINT owHasProgramPulse(int portnum); -SMALLINT owHasOverDrive(int portnum); -SMALLINT owReadBitPower(int portnum, SMALLINT applyPowerResponse); -// external One Wire global from owllu.c -extern SMALLINT FAMILY_CODE_04_ALARM_TOUCHRESET_COMPLIANCE; - -// external One Wire functions from transaction layer in owtrnu.c -SMALLINT owBlock(int portnum, SMALLINT do_reset, uchar *tran_buf, SMALLINT tran_len); -SMALLINT owReadPacketStd(int portnum, SMALLINT do_access, int start_page, uchar *read_buf); -SMALLINT owWritePacketStd(int portnum, int start_page, uchar *write_buf, - SMALLINT write_len, SMALLINT is_eprom, SMALLINT crc_type); -SMALLINT owProgramByte(int portnum, SMALLINT write_byte, int addr, SMALLINT write_cmd, - SMALLINT crc_type, SMALLINT do_access); - -// link functions -void msDelay(int len); -long msGettick(void); - -// ioutil.c functions prototypes -int EnterString(char *msg, char *buf, int min, int max); -int EnterNum(char *msg, int numchars, long *value, long min, long max); -int EnterHex(char *msg, int numchars, ulong *value); -int ToHex(char ch); -int getkeystroke(void); -int key_abort(void); -void ExitProg(char *msg, int exit_code); -int getData(uchar *write_buff, int max_len, SMALLINT gethex); -void PrintHex(uchar* buffer, int cnt); -void PrintChars(uchar* buffer, int cnt); -void PrintSerialNum(uchar* buffer); - -// external functions defined in crcutil.c -void setcrc16(int portnum, ushort reset); -ushort docrc16(int portnum, ushort cdata); -void setcrc8(int portnum, uchar reset); -uchar docrc8(int portnum, uchar x); - -#endif //OWNET_H diff --git a/tools_cmd/rwOW/tmexlnk.c b/tools_cmd/rwOW/tmexlnk.c deleted file mode 100644 index 7fa329a..0000000 --- a/tools_cmd/rwOW/tmexlnk.c +++ /dev/null @@ -1,368 +0,0 @@ -//--------------------------------------------------------------------------- -// Copyright (C) 2001 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. -//--------------------------------------------------------------------------- -// -// TMEXLnk.C - Link module to call on TMEX low-level functions to -// excersize the general 1-Wire Net functions. -// (Requires TMEX 3.11 or newer) -// -// Version: 3.00 -// -// History: 1.00 -> 1.01 Return values in owLevel corrected. -// Added function msDelay. -// 1.02 -> 1.03 Add msGettick, always return owLevel success -// to hide adapters (DS9097E) that do not have -// power delivery capabilities. -// 1.03 -> 2.00 Changed 'MLan' to 'ow'. Added support for -// multiple ports. -// 2.10 -> 3.00 Added owReadBitPower and owWriteBytePower - -#include "ownet.h" -#include - -// external TMEX variables -extern long SessionHandle[MAX_PORTNUM]; -extern uchar StateBuffer[MAX_PORTNUM][5120]; -extern short far pascal TMTouchByte(long, short); -extern short far pascal TMTouchReset(long); -extern short far pascal TMTouchBit(long, short); -extern short far pascal TMProgramPulse(long); -extern short far pascal TMOneWireCom(long, short, short); -extern short far pascal TMOneWireLevel(long, short, short, short); - -// globals -SMALLINT FAMILY_CODE_04_ALARM_TOUCHRESET_COMPLIANCE = FALSE; // for compatibility purposes - -//-------------------------------------------------------------------------- -// Reset all of the devices on the 1-Wire Net and return the result. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -// Returns: TRUE(1): presense pulse(s) detected, device(s) reset -// FALSE(0): no presense pulses detected -// -SMALLINT owTouchReset(int portnum) -{ - int result; - - // Assume valid Session - result = TMTouchReset(SessionHandle[portnum]); - - // success if the normal or alarm presence - if ((result == 1) || (result == 2)) - return TRUE; - else - return FALSE; -} - - -//-------------------------------------------------------------------------- -// Send 1 bit of communication to the 1-Wire Net and return the -// result 1 bit read from the 1-Wire Net. The parameter 'sendbit' -// least significant bit is used and the least significant bit -// of the result is the return bit. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'sendbit' - the least significant bit is the bit to send -// -// Returns: 0: 0 bit read from sendbit -// 1: 1 bit read from sendbit -// -SMALLINT owTouchBit(int portnum, SMALLINT sendbit) -{ - // Assume valid Session - return TMTouchBit(SessionHandle[portnum],(short)sendbit); -} - -//-------------------------------------------------------------------------- -// Send 8 bits of communication to the 1-Wire Net and verify that the -// 8 bits read from the 1-Wire Net is the same (write operation). -// The parameter 'sendbyte' least significant 8 bits are used. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'sendbyte' - 8 bits to send (least significant byte) -// -// Returns: TRUE: bytes written and echo was the same -// FALSE: echo was not the same -// -SMALLINT owTouchByte(int portnum, SMALLINT sendbyte) -{ - // Assume valid Session - return TMTouchByte(SessionHandle[portnum],(short)sendbyte); -} - -//-------------------------------------------------------------------------- -// Send 8 bits of communication to the MicroLAN and verify that the -// 8 bits read from the MicroLAN is the same (write operation). -// The parameter 'sendbyte' least significant 8 bits are used. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'sendbyte' - 8 bits to send (least significant byte) -// -// Returns: TRUE: bytes written and echo was the same -// FALSE: echo was not the same -// -SMALLINT owWriteByte(int portnum, SMALLINT sendbyte) -{ - return (owTouchByte(portnum,sendbyte) == sendbyte) ? TRUE : FALSE; -} - -//-------------------------------------------------------------------------- -// Send 8 bits of read communication to the 1-Wire Net and and return the -// result 8 bits read from the 1-Wire Net. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -// Returns: TRUE: 8 bytes read from 1-Wire Net -// FALSE: the 8 bytes were not read -// -SMALLINT owReadByte(int portnum) -{ - return owTouchByte(portnum,0xFF); -} - -//-------------------------------------------------------------------------- -// Set the 1-Wire Net communucation speed. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'new_speed' - new speed defined as -// MODE_NORMAL 0x00 -// MODE_OVERDRIVE 0x01 -// -// Returns: current 1-Wire Net speed -// -SMALLINT owSpeed(int portnum, SMALLINT new_speed) -{ - return TMOneWireCom(SessionHandle[portnum],0,(short)new_speed); -} - -//-------------------------------------------------------------------------- -// Set the 1-Wire Net line level. The values for new_level are -// as follows: -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'new_level' - new level defined as -// MODE_NORMAL 0x00 -// MODE_STRONG5 0x02 -// MODE_PROGRAM 0x04 -// MODE_BREAK 0x08 (not supported) -// -// Returns: current 1-Wire Net level -// -SMALLINT owLevel(int portnum, SMALLINT new_level) -{ - int rslt; - int docheck = FALSE; - - // check for DS2480 bug - if (((SessionHandle[portnum] & 0x0F0) == 0x050) && - (TMOneWireLevel(SessionHandle[portnum],1,0,0) == 1)) - docheck = TRUE; - - switch (new_level) - { - case MODE_NORMAL: - rslt = TMOneWireLevel(SessionHandle[portnum],0,0,0); - // test code for DS2480 bug - if (docheck) - TMTouchBit(SessionHandle[portnum],1); - break; - case MODE_STRONG5: - rslt = TMOneWireLevel(SessionHandle[portnum],0,1,0); - break; - case MODE_PROGRAM: - rslt = TMOneWireLevel(SessionHandle[portnum],0,3,0); - break; - case MODE_BREAK: - rslt = TMOneWireLevel(SessionHandle[portnum],0,2,0); - break; - default: - rslt = 0; - } - - // Assume TMEX can do it so always return NewLevel - return new_level; -} - -//-------------------------------------------------------------------------- -// This procedure creates a fixed 480 microseconds 12 volt pulse -// on the 1-Wire Net for programming EPROM iButtons. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -// Returns: TRUE successful -// FALSE program voltage not available -// -SMALLINT owProgramPulse(int portnum) -{ - return TMProgramPulse(SessionHandle[portnum]); -} - -//-------------------------------------------------------------------------- -// Description: -// Delay for at least 'len' ms -// -void msDelay(int len) -{ - Sleep(len); -} - -//-------------------------------------------------------------------------- -// Get the current millisecond tick count. Does not have to represent -// an actual time, it just needs to be an incrementing timer. -// -long msGettick(void) -{ - return GetTickCount(); -} - -//-------------------------------------------------------------------------- -// Send 8 bits of communication to the 1-Wire Net and verify that the -// 8 bits read from the 1-Wire Net is the same (write operation). -// The parameter 'sendbyte' least significant 8 bits are used. After the -// 8 bits are sent change the level of the 1-Wire net. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// 'sendbyte' - 8 bits to send (least significant byte) -// -// Returns: TRUE: bytes written and echo was the same -// FALSE: echo was not the same -// -SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte) -{ - // prime for power delivery after byte - TMOneWireLevel(SessionHandle[portnum],0,1,2); - - // send the byte and start strong pullup - if(TMTouchByte(SessionHandle[portnum],(short)sendbyte) != sendbyte) - { - TMOneWireLevel(SessionHandle[portnum],0,0,0); - return FALSE; - } - - return TRUE; -} - -//-------------------------------------------------------------------------- -// Read 8 bits of communication to the 1-Wire Net and verify that the -// 8 bits read from the 1-Wire Net is the same (write operation). -// The parameter 'sendbyte' least significant 8 bits are used. After the -// 8 bits are read change the level of the 1-Wire net. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// 'sendbyte' - 8 bits to send (least significant byte) -// -// Returns: TRUE: bytes written and echo was the same -// FALSE: echo was not the same -// -SMALLINT owReadBytePower(int portnum) -{ - SMALLINT sendbyte = 0xFF; - - // prime for power delivery after byte - TMOneWireLevel(SessionHandle[portnum],0,1,2); - - // send the byte and start strong pullup - return TMTouchByte(SessionHandle[portnum],(short)sendbyte); -} - -//-------------------------------------------------------------------------- -// Send 1 bit of communication to the 1-Wire Net and verify that the -// response matches the 'applyPowerResponse' bit and apply power delivery -// to the 1-Wire net. Note that some implementations may apply the power -// first and then turn it off if the response is incorrect. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// 'applyPowerResponse' - 1 bit response to check, if correct then start -// power delivery -// -// Returns: TRUE: bit written and response correct, strong pullup now on -// FALSE: response incorrect -// -SMALLINT owReadBitPower(int portnum, SMALLINT applyPowerResponse) -{ - // prime for power delivery after bit - TMOneWireLevel(SessionHandle[portnum],0,1,1); - - // send the byte and start strong pullup - if(TMTouchBit(SessionHandle[portnum],0x01) != applyPowerResponse) - { - TMOneWireLevel(SessionHandle[portnum],0,0,0); - return FALSE; - } - - return TRUE; -} - -//-------------------------------------------------------------------------- -// This procedure indicates wether the adapter can deliver power. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// -// Returns: TRUE because all userial adapters have over drive. -// -SMALLINT owHasPowerDelivery(int portnum) -{ - return TRUE; -} - -//-------------------------------------------------------------------------- -// This procedure indicates wether the adapter can deliver power. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// -// Returns: TRUE because all userial adapters have over drive. -// -SMALLINT owHasOverDrive(int portnum) -{ - return TRUE; -} - -//-------------------------------------------------------------------------- -// This procedure creates a fixed 480 microseconds 12 volt pulse -// on the 1-Wire Net for programming EPROM iButtons. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// -// Returns: TRUE program volatage available -// FALSE program voltage not available -SMALLINT owHasProgramPulse(int portnum) -{ - return TMProgramPulse(SessionHandle[portnum]); -} \ No newline at end of file diff --git a/tools_cmd/rwOW/tmexnet.c b/tools_cmd/rwOW/tmexnet.c deleted file mode 100644 index 3f9b77d..0000000 --- a/tools_cmd/rwOW/tmexnet.c +++ /dev/null @@ -1,249 +0,0 @@ -//--------------------------------------------------------------------------- -// Copyright (C) 2001 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. -//--------------------------------------------------------------------------- -// -// tmexnet.C - Wrapper class to hook 1-Wire Public Domain API to TMEX API -// for network functions. -// -// Version: 3.00 -// -// - -#include "ownet.h" -#include - -uchar StateBuffer[MAX_PORTNUM][5120]; - -// external TMEX variables -extern long SessionHandle[MAX_PORTNUM]; -extern short far pascal TMSearch(long session_handle, void *start_buffer, - short ResetSearch, short PerformReset, - short SrchCmd); -extern short pascal TMFirst(long, void *); -extern short pascal TMNext(long, void *); -extern short pascal TMAccess(long, void *); -extern short pascal TMStrongAccess(long, void *); -extern short pascal TMStrongAlarmAccess(long, void *); -extern short pascal TMOverAccess(long, void *); -extern short pascal TMRom(long, void *, short *); -extern short pascal TMFirstAlarm(long, void *); -extern short pascal TMNextAlarm(long, void *); -extern short pascal TMFamilySearchSetup(long, void *, short); -extern short pascal TMSkipFamily(long, void *); -extern short pascal TMAutoOverDrive(long, void *, short); - - -//-------------------------------------------------------------------------- -// The 'owFirst' finds the first device on the 1-Wire Net This function -// contains one parameter 'alarm_only'. When -// 'alarm_only' is TRUE (1) the find alarm command 0xEC is -// sent instead of the normal search command 0xF0. -// Using the find alarm command 0xEC will limit the search to only -// 1-Wire devices that are in an 'alarm' state. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'do_reset' - TRUE (1) perform reset before search, FALSE (0) do not -// perform reset before search. -// 'alarm_only' - TRUE (1) the find alarm command 0xEC is -// sent instead of the normal search command 0xF0 -// -// Returns: TRUE (1) : when a 1-Wire device was found and it's -// Serial Number placed in the global SerialNum[portnum] -// FALSE (0): There are no devices on the 1-Wire Net. -// -SMALLINT owFirst(int portnum, SMALLINT do_reset, SMALLINT alarm_only) -{ - return (TMSearch(SessionHandle[portnum], StateBuffer[portnum], 1, - (short)do_reset, (short)((alarm_only) ? 0xEC : 0xF0)) == 1); -} - -//-------------------------------------------------------------------------- -// The 'owNext' function does a general search. This function -// continues from the previos search state. The search state -// can be reset by using the 'owFirst' function. -// This function contains one parameter 'alarm_only'. -// When 'alarm_only' is TRUE (1) the find alarm command -// 0xEC is sent instead of the normal search command 0xF0. -// Using the find alarm command 0xEC will limit the search to only -// 1-Wire devices that are in an 'alarm' state. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'do_reset' - TRUE (1) perform reset before search, FALSE (0) do not -// perform reset before search. -// 'alarm_only' - TRUE (1) the find alarm command 0xEC is -// sent instead of the normal search command 0xF0 -// -// Returns: TRUE (1) : when a 1-Wire device was found and it's -// Serial Number placed in the global SerialNum[portnum] -// FALSE (0): when no new device was found. Either the -// last search was the last device or there -// are no devices on the 1-Wire Net. -// -SMALLINT owNext(int portnum, SMALLINT do_reset, SMALLINT alarm_only) -{ - return (TMSearch(SessionHandle[portnum], StateBuffer[portnum], 0, - (short)do_reset, (short)((alarm_only) ? 0xEC : 0xF0)) == 1); -} - -//-------------------------------------------------------------------------- -// The 'owSerialNum' function either reads or sets the SerialNum buffer -// that is used in the search functions 'owFirst' and 'owNext'. -// This function contains two parameters, 'serialnum_buf' is a pointer -// to a buffer provided by the caller. 'serialnum_buf' should point to -// an array of 8 unsigned chars. The second parameter is a flag called -// 'do_read' that is TRUE (1) if the operation is to read and FALSE -// (0) if the operation is to set the internal SerialNum buffer from -// the data in the provided buffer. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'serialnum_buf' - buffer to that contains the serial number to set -// when do_read = FALSE (0) and buffer to get the serial -// number when do_read = TRUE (1). -// 'do_read' - flag to indicate reading (1) or setting (0) the current -// serial number. -// -void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read) -{ - short ROM[8],i; - - // check if reading or writing - if (do_read) - { - ROM[0] = 0; - } - else - { - for (i = 0; i < 8; i++) - ROM[i] = serialnum_buf[i]; - } - - // call TMEX to read or set the current device - TMRom(SessionHandle[portnum], StateBuffer[portnum], ROM); - - // place in 'serialnum_buf' - if (do_read) - { - for (i = 0; i < 8; i++) - serialnum_buf[i] = (uchar)ROM[i]; - } -} - -//-------------------------------------------------------------------------- -// Setup the search algorithm to find a certain family of devices -// the next time a search function is called 'owNext'. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to -// OpenCOM to indicate the port number. -// 'search_family' - family code type to set the search algorithm to find -// next. -// -void owFamilySearchSetup(int portnum, SMALLINT search_family) -{ - TMFamilySearchSetup(SessionHandle[portnum], StateBuffer[portnum], - (short)search_family); -} - -//-------------------------------------------------------------------------- -// Set the current search state to skip the current family code. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -void owSkipFamily(int portnum) -{ - TMSkipFamily(SessionHandle[portnum], StateBuffer[portnum]); -} - -//-------------------------------------------------------------------------- -// The 'owAccess' function resets the 1-Wire and sends a MATCH Serial -// Number command followed by the current SerialNum code. After this -// function is complete the 1-Wire device is ready to accept device-specific -// commands. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -// Returns: TRUE (1) : reset indicates present and device is ready -// for commands. -// FALSE (0): reset does not indicate presence or echos 'writes' -// are not correct. -// -SMALLINT owAccess(int portnum) -{ - return (TMAccess(SessionHandle[portnum], StateBuffer[portnum]) == 1); -} - -//---------------------------------------------------------------------- -// The function 'owVerify' verifies that the current device -// is in contact with the 1-Wire Net. -// Using the find alarm command 0xEC will verify that the device -// is in contact with the 1-Wire Net and is in an 'alarm' state. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'alarm_only' - TRUE (1) the find alarm command 0xEC -// is sent instead of the normal search -// command 0xF0. -// -// Returns: TRUE (1) : when the 1-Wire device was verified -// to be on the 1-Wire Net -// with alarm_only == FALSE -// or verified to be on the 1-Wire Net -// AND in an alarm state when -// alarm_only == TRUE. -// FALSE (0): the 1-Wire device was not on the -// 1-Wire Net or if alarm_only -// == TRUE, the device may be on the -// 1-Wire Net but in a non-alarm state. -// -SMALLINT owVerify(int portnum, SMALLINT alarm_only) -{ - if (alarm_only) - return (TMStrongAlarmAccess(SessionHandle[portnum], StateBuffer[portnum]) == 1); - else - return (TMStrongAccess(SessionHandle[portnum], StateBuffer[portnum]) == 1); -} - -//---------------------------------------------------------------------- -// Perform a overdrive MATCH command to select the 1-Wire device with -// the address in the ID data register. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -// Returns: TRUE: If the device is present on the 1-Wire Net and -// can do overdrive then the device is selected. -// FALSE: Device is not present or not capable of overdrive. -// -// *Note: This function could be converted to send DS2480 -// commands in one packet. -// -SMALLINT owOverdriveAccess(int portnum) -{ - return (TMOverAccess(SessionHandle[portnum], StateBuffer[portnum]) == 1); -} diff --git a/tools_cmd/rwOW/tmexses.c b/tools_cmd/rwOW/tmexses.c deleted file mode 100644 index fea8798..0000000 --- a/tools_cmd/rwOW/tmexses.c +++ /dev/null @@ -1,212 +0,0 @@ -//--------------------------------------------------------------------------- -// Copyright (C) 2001 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. -//--------------------------------------------------------------------------- -// -// owsestmx.c - Acquire and release a Session on the 1-Wire Net using TMEX. -// (Requires TMEX 3.11 or newer) -// -// Version: 2.01 -// -// History: 1.03 -> 2.00 Changed 'MLan' to 'ow'. Added support for -// multiple ports. -// 2.00 -> 2.01 Added support for owError library. -// - -#include -#include -#include "ownet.h" - -// external function prototypes -extern long far pascal TMExtendedStartSession(short, short, void far *); -extern short far pascal TMEndSession(long); -extern short far pascal TMClose(long); -extern short far pascal TMSetup(long); -extern short far pascal TMReadDefaultPort(short far *, short far *); - -short PortNum=1,PortType=2; -long SessionHandle[MAX_PORTNUM]; -SMALLINT handle_init = FALSE; - -//--------------------------------------------------------------------------- -// Attempt to acquire a 1-Wire net using a com port and a DS2480 based -// adapter. -// -// 'port_zstr' - zero terminated port name. For this platform -// use format {port number, port type}. -// -// Returns: port number and -1 if not successful in setting up the port. -// -int owAcquireEx(char *port_zstr) -{ - int portnum; - int string_counter, counter, i, lenmax; - char portnum_str[15]; - char porttype_str[15]; - void *tmex_options = NULL; - - if(!handle_init) - { - for(i=0; i 12) - lenmax = 12; - string_counter = 1; - counter = 0; - do - { - portnum_str[counter] = port_zstr[string_counter]; - - counter++; - string_counter++; - } - while((port_zstr[string_counter] != ',') && (string_counter <= lenmax)); - - portnum_str[counter] = '\0'; - - string_counter++; - counter = 0; - - do - { - porttype_str[counter] = port_zstr[string_counter]; - - counter++; - string_counter++; - } - while((port_zstr[string_counter] != '}') && (string_counter <= lenmax)); - - porttype_str[counter] = '\0'; - - PortNum = atoi(portnum_str); - PortType = atoi(porttype_str); - } - - // open a session - SessionHandle[portnum] = TMExtendedStartSession(PortNum,PortType,tmex_options); - - // check the session handle - if (SessionHandle[portnum] <= 0) - { - OWERROR(OWERROR_GET_SYSTEM_RESOURCE_FAILED); - SessionHandle[portnum] = 0; - return -1; - } - - // setup the port - if (TMSetup(SessionHandle[portnum]) != 1) - { - TMClose(SessionHandle[portnum]); - TMEndSession(SessionHandle[portnum]); - OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED); - SessionHandle[portnum] = 0; - return -1; - } - - return portnum; -} - -//--------------------------------------------------------------------------- -// Attempt to acquire a 1-Wire net using a com port and a DS2480 based -// adapter. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'port_zstr' - zero terminated port name. For this platform -// use format COMX where X is the port number. -// -// Returns: TRUE - success, COM port opened -// -SMALLINT owAcquire(int portnum, char *port_zstr) -{ - int i; - - if(!handle_init) - { - for(i=0; i=0 && !SessionHandle[portnum], - OWERROR_PORTNUM_ERROR, FALSE ); - - // read the default PortNum and PortType - TMReadDefaultPort(&PortNum,&PortType); - - // convert the string in port_zstr to be the port number - PortNum = atoi(port_zstr); - - // open a session - SessionHandle[portnum] = TMExtendedStartSession(PortNum,PortType,NULL); - - // check the session handle - if (SessionHandle[portnum] <= 0) - { - OWERROR(OWERROR_GET_SYSTEM_RESOURCE_FAILED); - SessionHandle[portnum] = 0; - return FALSE; - } - - // setup the port - if (TMSetup(SessionHandle[portnum]) != 1) - { - TMClose(SessionHandle[portnum]); - TMEndSession(SessionHandle[portnum]); - OWERROR(OWERROR_SYSTEM_RESOURCE_INIT_FAILED); - SessionHandle[portnum] = 0; - return FALSE; - } - - return TRUE; -} - -//--------------------------------------------------------------------------- -// Release the previously acquired a 1-Wire net. -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// -void owRelease(int portnum) -{ - TMClose(SessionHandle[portnum]); - TMEndSession(SessionHandle[portnum]); - SessionHandle[portnum] = 0; -} - diff --git a/tools_cmd/rwOW/tmextran.c b/tools_cmd/rwOW/tmextran.c deleted file mode 100644 index 4a4b926..0000000 --- a/tools_cmd/rwOW/tmextran.c +++ /dev/null @@ -1,199 +0,0 @@ -//--------------------------------------------------------------------------- -// Copyright (C) 1999 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. -//--------------------------------------------------------------------------- -// -// tmexnet.C - Wrapper class to hook 1-Wire Public Domain API to TMEX API -// for transport functions. -// -// Version: 3.00 -// - -#include "ownet.h" -#include - -// external TMEX variables -extern long SessionHandle[MAX_PORTNUM]; -extern short far pascal TMBlockIO(long, uchar *, short); -extern short far pascal TMBlockStream(long, uchar *, short); - -//-------------------------------------------------------------------------- -// The 'owBlock' transfers a block of data to and from the -// 1-Wire Net with an optional reset at the begining of communication. -// The result is returned in the same buffer. -// -// 'do_reset' - cause a owTouchReset to occure at the begining of -// communication TRUE(1) or not FALSE(0) -// 'tran_buf' - pointer to a block of unsigned -// chars of length 'TranferLength' that will be sent -// to the 1-Wire Net -// 'tran_len' - length in bytes to transfer -// Supported devices: all -// -// Returns: TRUE (1) : The optional reset returned a valid -// presence (do_reset == TRUE) or there -// was no reset required. -// FALSE (0): The reset did not return a valid prsence -// (do_reset == TRUE). -// -// The maximum tran_len is 64 -// -SMALLINT owBlock(int portnum, SMALLINT do_reset, uchar *tran_buf, SMALLINT tran_len) -{ - short rslt; - - // check for a block too big - if (tran_len > 192) - { - OWERROR(OWERROR_BLOCK_TOO_BIG); - return FALSE; - } - - // check if need to do a owTouchReset first - if (do_reset) - rslt = TMBlockIO(SessionHandle[portnum], tran_buf, (short)tran_len); - else - rslt = TMBlockStream(SessionHandle[portnum], tran_buf, (short)tran_len); - - return (rslt == tran_len); -} - -//-------------------------------------------------------------------------- -// Write a byte to an EPROM 1-Wire device. -// -// Supported devices: crc_type=0(CRC8) -// DS1982 -// crc_type=1(CRC16) -// DS1985, DS1986, DS2407 -// -// 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to -// indicate the symbolic port number. -// 'write_byte' - byte to program -// 'addr' - address of byte to program -// 'write_cmd' - command used to write (0x0F reg mem, 0x55 status) -// 'crc_type' - CRC used (0 CRC8, 1 CRC16) -// 'do_access' - Flag to access device for each byte -// (0 skip access, 1 do the access) -// WARNING, only use do_access=0 if programing the NEXT -// byte immediatly after the previous byte. -// -// Returns: >=0 success, this is the resulting byte from the program -// effort -// -1 error, device not connected or program pulse voltage -// not available -// -SMALLINT owProgramByte(int portnum, SMALLINT write_byte, int addr, SMALLINT write_cmd, - SMALLINT crc_type, SMALLINT do_access) -{ - ushort lastcrc16; - uchar lastcrc8; - - // optionally access the device - if (do_access) - { - if (!owAccess(portnum)) - { - OWERROR(OWERROR_ACCESS_FAILED); - return -1; - } - - // send the write command - if (!owWriteByte(portnum,write_cmd)) - { - OWERROR(OWERROR_WRITE_BYTE_FAILED); - return -1; - } - - // send the address - if (!owWriteByte(portnum,addr & 0xFF) || !owWriteByte(portnum,addr >> 8)) - { - OWERROR(OWERROR_WRITE_BYTE_FAILED); - return -1; - } - } - - // send the data to write - if (!owWriteByte(portnum,write_byte)) - { - OWERROR(OWERROR_WRITE_BYTE_FAILED); - return -1; - } - - // read the CRC - if (crc_type == 0) - { - // calculate CRC8 - if (do_access) - { - setcrc8(portnum,0); - docrc8(portnum,(uchar)write_cmd); - docrc8(portnum,(uchar)(addr & 0xFF)); - docrc8(portnum,(uchar)(addr >> 8)); - } - else - setcrc8(portnum,(uchar)(addr & 0xFF)); - - docrc8(portnum,(uchar)write_byte); - // read and calculate the read crc - lastcrc8 = docrc8(portnum,(uchar)owReadByte(portnum)); - // crc should now be 0x00 - if (lastcrc8 != 0) - { - OWERROR(OWERROR_CRC_FAILED); - return -1; - } - } - else - { - // CRC16 - if (do_access) - { - setcrc16(portnum,0); - docrc16(portnum,(ushort)write_cmd); - docrc16(portnum,(ushort)(addr & 0xFF)); - docrc16(portnum,(ushort)(addr >> 8)); - } - else - setcrc16(portnum,(ushort)addr); - docrc16(portnum,(ushort)write_byte); - // read and calculate the read crc - docrc16(portnum,(ushort)owReadByte(portnum)); - lastcrc16 = docrc16(portnum,(ushort)owReadByte(portnum)); - // crc should now be 0xB001 - if (lastcrc16 != 0xB001) - return -1; - } - - // send the program pulse - if (!owProgramPulse(portnum)) - { - OWERROR(OWERROR_PROGRAM_PULSE_FAILED); - return -1; - } - - // read back and return the resulting byte - return owReadByte(portnum); -} - -