Hm, it looks like you might be using the version of pyBusPirateLite from that previous forum post. I had quite a bit of trouble getting anywhere with it, it seems to have diverged quite a bit from the current SVN source. Try starting with the version in the repository (currently rev598) or grab the download package of r597: http://http://code.google.com/p/the-bus-pirate/downloads/detail?name=pyBusPirateLite-r597.zip&can=2&q=#makechanges
[quote author="vk2tds"]In onewire.py, it would seem that going into 1wire mode resets the power and pullups. Therefore, I have added the following code, although it is a real hack, just to turn on power.
def _1wire_test(self):
self.check_mode('1wire')
self.port.write("x48")
self.timeout(0.1)
return self.response(1)
[/quote]
It seems to be normal for the system to disable power and pullups at mode transitions, requiring the user to re-enable them. The BBIO class (in SVN) that 1Wire inherits from provides a "cfg_pins" interface that you can use to set them. The values for the various peripherals are defined here: http://http://dangerousprototypes.com/docs/1-Wire_%28binary%29
obj.cfg_pins(0x08 | 0x04) # where obj is an instance of the 1Wire class
If you look at the I2C package (in SVN), it defines an "I2CPins" class which specifies the different peripherals that you can pass to cfg_pins. We probably ought to define something similar for the 1Wire class. According to http://http://dangerousprototypes.com/docs/I2C_%28binary%29, the peripherals are the same. I'll try and add that to SVN later. In the meantime, you can copy it directly, and then call
obj.cfg_pins(1WirePins.POWER | 1WirePins.PULLUPS) # where obj is an instance of the 1Wire class
[quote author="vk2tds"]
Also, the function __group_response will not work in Python from what I can determine. I have created a hack that sort of works. Probably not the best but it does return something.
def __group_response(self):
self.check_mode('1wire')
EOD = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
#= was ==
while 1:
print "read"
data = self.port.read(8)
if data == EOD:
break
if len(data) == 8:
print "%d %d %d %d %d %d %d %d" % (ord(data[0]), ord(data[1]), ord(data[2]), ord(d
[/quote]
Interesting, I'll have to look into this a bit more.
[quote author="vk2tds"]
Now, when this runs, I get the following.... This seems to be the ID's of the two devices I have connected. Still, with the two zeros at the end, things look a bit suspicious. I will need to check. No, it is fine, but the first character being returned does not seem to be the ID, and there is a number at the end that is missing from the ASCII command under the BP [command (240) ]
MacBook:pyBusPirateLite_v1 darryl$ ./test.py
read
1 40 220 20 6 3 0 0
read
41 40 253 22 6 3 0 0
read
43 255 255 255 255 255 255 255
read
read
My test code is :-
#!/usr/bin/python
import UC
myBP = UC.UC()
myBP.connect ("/dev/tty.usbserial-A6005kqu")
myBP.enter_bb()
myBP.configure_peripherals( power = 'on', pullups = 'on')
myBP.set_dir(0x00)
myBP.enter_1wire()
myBP._1wire_reset()
myBP._1wire_test()
myBP.rom_search()
Hope this helps
[/quote]
Good work so far. Have you considered using the Python console? It can be handy for experimenting with commands "live".