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