Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

should we understand syntax in python

Status
Not open for further replies.

anilvadnala

New Member
Hi frens,

Here I am writing a python program with not knowing some instructions so I hope you would help me.

Here "handle" is constant and aa is stand for "ardwark adaptor"I have to understand /, %d, q\n,
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0])) syntaxs
Code:
[\code]

# Set the bitrate
bitrate = aa_i2c_bitrate(handle, bitrate)
print "Bitrate set to %d kHz" % bitrate
# Configure the device
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGC, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
aa_i2c_write(handle,DEVICE,0,array('B',[FF_DELAY, FF_Delay]))
aa_i2c_write(handle,DEVICE,0,array('B',[MOT_DELAY, MOT_Delay]))
aa_i2c_write(handle,DEVICE,0,array('B',[FF_INT, int(FF_Threshold)]))
aa_i2c_write(handle,DEVICE,0,array('B',[MOT_INT, int(MOT_Threshold)]))
print "Ready..."
while (1):
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGA]))
(ret, data, count) = aa_i2c_read_ext(handle,DEVICE,0,1)
if len(data) < 1:
sys.stdout.write("SENSOR READ ERROR. Park drive head.\n(Press Enter to resume
sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
elif data[0] & FFI:
sys.stdout.write("Freefall started. Park drive head.\n(Press Enter to resume
sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
elif data[0] & MOTI:
sys.stdout.write("High-g motion detected. Park drive head.\n(Press Enter to
resume sampling or Q followed by Enter to quit.) ")
userinput = sys.stdin.readline()
if (userinput == "q\n" or userinput == "Q\n"):
aa_close(handle)
sys.exit()
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0]))
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, FFIen | MOTIen]))
aa_close(handle)
 
Here "handle" is constant and aa is stand for "ardwark adaptor"I have to understand /, %d, q\n,
aa_i2c_write(handle,DEVICE,0,array('B',[CTRL_REGB, 0])) syntaxs
When using code tags, [code] goes before your code, and [/code] (use a forward slash - you put a backslash in your tag above :p) goes after your code.

As I said in my PM to you, you'll have to dig through the Aardvark library to figure this out. About 90% of your Python code is just calls to the Aardvark lib. Almost all the actual code is there. Read it to help you understand what the Python program is doing.

aa_i2c_write() is a call to the Aardvark lib. Any command that starts with "aa_" is also a call to Aardvark. Aardvark is not part of Python. It's an add-on library.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top