示例#1
0
文件: dblogger.py 项目: 3tones/brybus
def scantable():
  #make queue for 3b table  
  scan_q = brybus.writequeue()
  
  print "Building Queue"

  #table 3c isn't complete so use this array of valid rows
  table_3c = (
  '200130010300000B003C01',
  '200130010300000B003C03',
  '200130010300000B003C04',
  '200130010300000B003C05',
  '200130010300000B003C06',
  '200130010300000B003C08',
  '200130010300000B003C09',
  '200130010300000B003C0A',
  '200130010300000B003C0B',
  '200130010300000B003C0C',
  '200130010300000B003C0D',
  '200130010300000B003C0E',
  '200130010300000B003C0F',
  '200130010300000B003C10',
  '200130010300000B003C11',
  '200130010300000B003C12',
  '200130010300000B003C13',
  '200130010300000B003C14',
  '200130010300000B003C1E',
  '200130010300000B003C1F',
  '200130010300000B003C28',
  '200130010300000B003C29'
  )


  for r in range(1,16):
    reg = '00' + '3B' + "{0:02X}".format(r)
    f = brybus.frame(reg,'C','2001','3001','0B')
    scan_q.pushframe(f)
  #use the list above
  for r in table_3c:
    f = brybus.frame(r,'S')
    scan_q.pushframe(f)
  for r in range(1,4):
    reg = '00' + '3D' + "{0:02X}".format(r)
    f = brybus.frame(reg,'C','2001','3001','0B')
    scan_q.pushframe(f)
        
  return scan_q  
示例#2
0
def scantable():
    # load data from csv
    print "Loading table information"

    # load CSV into memory
    registers = []
    tfin = csv.reader(open(scan_registers, "rb"))
    for row in tfin:
        registers.append(row)

    scan_q = brybus.writequeue()

    print "Building Queue"
    for r in registers:
        reg = "00" + r[1] + r[6]
        f = brybus.frame(reg, "C", r[0], "3001", "0B")
        scan_q.pushframe(f)

    return scan_q
示例#3
0
文件: readraw.py 项目: 3tones/brybus
import ConfigParser

cfg = ConfigParser.ConfigParser()
cfg.read('brybus.cfg')
serialport = cfg.get('brybus','serialport')

#build a frame if you already know it
f1 = brybus.frame('400130010300000B000101',"S")
print "Frame Built: ",f1.print_str()

#build a frame from parts: data, C for Create, dst, src, function
f2 = brybus.frame('000101','C','5001','3001','0B')
print "Frame Built: ",f2.print_str()

#build the queue and put the items in it
q = brybus.writequeue()
q.pushframe(f1)
q.pushframe(f2)
q.printqueue()

#setup the stream and bus
s = brybus.stream('S',serialport)
b = brybus.bus(s)

#loop forever
while(1):

  #write data if there
  b.write(q.writeframe())
  
  #read data