1
Messages
This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.
Messages - szczys
2
Bus Pirate Support / Re: BP Firmware Upgrade Error -> BP gone !
3
Bus Pirate Support / Re: Trouble using bit bang mode with 1-wire protocol
Code: [Select]
import serial
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.05)
print ser.read(100)
#Funtion sends one byte at a time to the BP
def writeBytes(myData):
for c in myData:
ser.write(c)
s = ser.read(100)
for c in s:
print '%02X'%ord(c),
return s
#Put BP into Bit Bang mode (Mode LED should light up)
ser.write("x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00")
s = ser.read(100)
print s
#Put BP into 1-wire mode
writeBytes("x04")
#Turn on voltage regulator
writeBytes("x48")
#bus reset
writeBytes("x02")
#Get address
s = writeBytes("x08")
#Slice out 8 bytes excluding the first byte (it was a confirmation byte)
tempSensorAddr = s[1:9]
print "nUsing 1-Wire Address:"
for c in tempSensorAddr:
print '%02X'%ord(c),
print "n"
#bus reset
writeBytes("x02")
#Start conversion by sending 0x44
writeBytes("x19x55" + tempSensorAddr + "x44")
#bus reset
writeBytes("x02")
#Read from sketchpad by sending 0xBE
writeBytes("x19x55" + tempSensorAddr + "xBE")
#Read first two bytes
lsByte = writeBytes("x04")
msByte = writeBytes("x04")
#Convert lsByte and msByte to a usable decimal sum
lsByte = int(ord(lsByte))
msByte = int(ord(msByte))*256
rawTemp = lsByte + msByte
print rawTemp
#Convert rawTemp to precision temp, then to Fahrenheit
tempCelsius = rawTemp * 0.0625
print "Temperature Celsius: ", tempCelsius
tempFahrenheit = ((tempCelsius*9)/5)+32
print "Temperature Fahrenheit: ", tempFahrenheit
Here's the output of the script:
Code: [Select]
BBIO1
Bus Pirate v3
Firmware v4.2 (rxxx) Bootloader v4.1
DEVID:0x0447 REVID:0x3003 (A3)
http://
dangerousprototypes.com
HiZ>BBIO1
31 57 30 31
01
01
01 28 A8 CD 5E 02 00 00 AF FF FF FF FF FF FF FF FF
Using 1-Wire Address:
28 A8 CD 5E 02 00 00 AF
01
01 01 01 01 01 01 01 01 01 01 01
01
01 01 01 01 01 01 01 01 01 01 01
75
01
373
Temperature Celsius: 23.3125
Temperature Fahrenheit: 73.9625
4
Bus Pirate Support / Re: Trouble using bit bang mode with 1-wire protocol
Is this bug in the bit bang protocol?
5
Bus Pirate Support / Re: Trouble using bit bang mode with 1-wire protocol
You're right, I need to be sending the reset command. I figured that out after I posted yesterday. But that's not really the problem. It seem's I'm overflowing the buffer by sending too many bytes too quickly. If I reduce the number of bytes sent to no more than 4 at a time I get an ok response for each byte (0x01). After issuing the commands I can then read out the data one byte at a time by sending (0x04).
I was confused because there address search macro handles multiple bits (incoming) without a problem. But anyway, working now. Thanks!
-Mike
6
Bus Pirate Support / Trouble using bit bang mode with 1-wire protocol
I'm playing around with python scripting for the BP through the bit bang mode. I've got a Dallas 1-wire temperature sensor (18B20) that I have no problem communicating with through the serial terminal. When I try to do the same through bit bang mode I'm unable to read data. Here's what I'm attempting:
1. Open the proper port
2. Send as string of twenty 0x00 to put it in bit bang mode (sends back BBIO1 as expected)
3. Send 0x04 to get into 1-wire mode (sends back 1W01 as expected)
4. Turn on voltage regulator by sending 0x48 (LED lights up as expected)
5. Scan for 1-wire address by sending 0x08 (Expected address comes back)
Here's where the problems start?
6. I need to send a matchrom signal (0x55) followed by the 8-byte address, then the start conversion command (0x44). I send the bulkwrite command in front of these like so: 0x19 0x55 0x28 0xa8 0xcd 0x5e 0x02 0x00 0x00 0xaf 0x44. I get back a six 0x01.
7 I then need to read the temp so I send 0xbe instead of 0xhh at the end: 0x19 0x55 0x28 0xa8 0xcd 0x5e 0x02 0x00 0x00 0xaf 0xbe.
No dice. I get a string of 0x01 back again.
Any idea why I'm not getting the expected results for steps 6 and 7?
Thanks!