Help With AttributeError - Raspberry Pi Forums
code: select all
#!/usr/bin/env python import time import argparse import sys import bb_i2c import pigpio if len(sys.argv) == 1: sys.exit ("the total numbers of arguments passed 1.\nrun app -h command help.") parser = argparse.argumentparser(description='rds setting application') parser.add_argument('-c','--change', help='input station name (8 characters max)', required=false) parser.add_argument('-s','--song',help='song name', required=false) parser.add_argument('-l','--liststation', help='print out station id', required=false, action="store_true") parser.add_argument('-n','--nowplaying', help='print out current radiotext', required=false, action="store_true") parser.add_argument('-i','--install', help='run first time install turn off dynamic ps', required=false, action="store_true") parser.add_argument('-w','--write',help='write memory', required=false, action="store_true") args = parser.parse_args() pi = pigpio.pi() s = bb_i2c.i2c(pi, 28, 29, 600) if args.change: #we have station name change #so...set name of radio station if len(args.change) >=9: sys.exit ("the station name has 8 characters or less") stationname = args.change stationname = stationname.ljust(8,' ') s.s() s.tx(214) s.tx(02) x in range(0, 8): # print " %d" % ord(stationname[x]) s.tx(ord(stationname[x])) s.e() print "station name changed to: %s" % stationname if args.install: #store settings eeprom print ("setting dynamic ps off , saving eeprom...") # turn off dynamic ps because it's bad (although edm has on default - http://www.rds.org.uk/2010/usage-of-ps.htm) s.s() s.tx(214) s.tx(0x76) s.tx(0) s.e() s.s() s.tx(214) s.tx(0x71) s.tx(0x45) s.e() print ("settings saved eeprom") if args.song: #we have change song title playing if len(args.song) >=64: sys.exit ("the song has 64 characters or less") radiotext = args.song radiotext = radiotext.ljust(64,' ') s.s() s.tx(214) s.tx(0x20) x in range(0, 64): # print " %d" % ord(radiotext[x]) s.tx(ord(radiotext[x])) s.e() print "radiotext changed to: %s" % radiotext if args.liststation: #print out radio station id s.s() s.tx(214) s.tx(02) #0x77 dynamic ps 0x20 rt s.s() s.tx(215) number1 = s.rx(1) #1 = ack, 0-nack number2 = s.rx(1) number3 = s.rx(1) number4 = s.rx(1) number5 = s.rx(1) number6 = s.rx(1) number7 = s.rx(1) number8 = s.rx(0) print '%s%s%s%s%s%s%s%s' %(chr(number1) , chr(number2) , chr(number3), chr(number4) , chr(number5) , chr(number6), chr(number7) , chr(number8)) s.e() if args.nowplaying: #print out current radio text information radiotext = "" s.s() s.tx(214) s.tx(0x20) s.s() s.tx(215) x in range(0, 63): #print " %s" % chr(s.rx(1)) radiotext = radiotext + chr(s.rx(1)) radiotext = radiotext + chr(s.rx(0)) s.e() print "%s" % radiotext if args.write: #store settings eeprom print ("saving...") s.s() s.tx(214) s.tx(0x71) s.tx(0x45) s.e() print ("settings saved eeprom") # print ("station name: %s" % args.change ) # print ("song: %s" % args.song ) # print ("write on?: %s" % args.write ) ### # configuration of minirds per http://www.edmdesign.com/docs/edm-tx-rds.pdf # address information , valudes found http://pira.cz/rds/mrds192.pdf # step 1: set pty coding # pty coding (set us) # pty flag set when write eeprom never change otherwise! # pty = program type = 0x0a = value of 2 information # step 2: set subcarier phase shift 85.23 degrees, clock source auto(stero), pll lock range 19000+/- 5hz # step 3: set ps name # step 4: set radio text # dyanmic ps used default ### ### # example of how read byte of data #s.s() #s.tx(214) #s.tx(0x22) #s.s() #s.tx(215) #print(s.rx(0)) #print 'got new device: %s' % chr(79) #s.e() ### ### #set name of radio station #s.s() #s.tx(214) #s.tx(02) #s.tx(ord('x')) #s.tx(ord('m')) #s.tx(ord('a')) #s.tx(ord('s')) # s.tx(ord('m')) #s.tx(ord('u')) #s.tx(ord('z')) #s.tx(ord('k')) #s.e() #store eeprom #s.s() #s.tx(214) #s.tx(0x71) #s.tx(0x45) #s.e() s.cancel() pi.stop()
fpp@fpp ~/media/plugins/edmrds $ sudo ./rds-song.py -l
traceback (most recent call last):
file "./rds-song.py", line 22, in <module>
pi = pigpio.pi()
attributeerror: 'module' object has no attribute 'pi'
looking resolving. believe pigpio libraries ok. command pigs pigpv returns value 44. suspect may problem python or pigpiod daemon. i'm new @ more basic environment or permissions.
code looks correct http://abyz.co.uk/rpi/pigpio/python.html#pigpio.pi ...unless happen have old version of pigpio looks differently initialised viewtopic.php?p=486959
maybe have file called pigpio.py or sub-directory called pigpio in current directory , python imports instead of correct module?
maybe have file called pigpio.py or sub-directory called pigpio in current directory , python imports instead of correct module?
raspberrypi
Comments
Post a Comment