Exemplo n.º 1
0
 def send(self, widget):
     self.PackedData = []
     #print widget
     #print 'widget class = ',widget.__class__.__name__
     if widget.__class__.__name__ == 'Entry':
         fields = [
             self.classification,
             gtk.Buildable.get_name(widget),
             widget.get_text()
         ]
         #print fields #['cfdata', 'StepNumX', '2000']
         #raw_input('fields')
     elif widget.__class__.__name__ == 'ComboBox':
         index = widget.get_active()  #indicate nth item selection
         model = widget.get_model()
         item = model[index][1]
         fields = [
             self.classification,
             gtk.Buildable.get_name(widget), item
         ]
     #print fields
     if Communications.serial_activated:
         #fields = ['cfdata', 'StepNumX', '2000']
         #msg_encodded = pw.wrapfieldscrc(fields)
         #print 'encoded = ',msg_encodded
         ##encoded =  [#[F709D151#]#[###[cfdata###]###[StepNumX###]###[2000###]#]]
         value = framer.wrapfieldscrc(fields)
         #print 'class ManualControlData is sending: ',value
         Communications.transmit(value)
Exemplo n.º 2
0
 def send(self, widget):
     #print widget
     self.PackedData = []
     fields = [self.classification,
               gtk.Buildable.get_name(widget)]  #,item.get_text()]
     #print fields
     Communications.transmit(framer.wrapfieldscrc(fields))
Exemplo n.º 3
0
def send_file(filename):
    #create an object of protocol wrapper
    #if not Communications.active_serial == None:
    global framer
    PackedData = []
    file = open(filename, 'r')
    for line in file:
        #print line
        stripped = line.rstrip('\r\n')  #remove carriage returns
        if not (len(stripped) == 0):  #skip empty lines
            fields = ['gcode']  #initialieze fields list with classification
            fields.extend(stripped.split())  #tokenize on white spaces
            PackedData.append(framer.wrapfieldscrc(fields))  #wrap with crc
    for data in PackedData:
        Communications.transmit(data)  #transmit
Exemplo n.º 4
0
 def send(self):
     '''
     sends packed data over serial channel
     data will be in the format defined by protocol wrapper
     [Classification][Type][Data]
     [CRC32][Classification][Type][Data]
     
     call get_packedData to get the data to send
     '''
     #print self.get_packedData()[0]
     #if not Communications.active_serial == None:
     #         print self.get_packedData()
     #         raw_input('packed data')
     #         for data in self.get_packedData():
     #             C
     for data in self.get_packedData():
         Communications.transmit(data)
Exemplo n.º 5
0
    def _send(self, command='ADEAD', payload='', queue_priority=0):
        '''
        payload should be a binary string in the format of the length of payload
        queue_priority == 0 is the fastest and the higher the number the slower 
        #note:set all gcode commands priority = 1, this will place gcode in slow queue
        #allowing user sent commands to be processed quickly even if routing is in progress
        '''
        payload_len = self.command_list[command]['command_length']
        received_payload_len = len(payload) / self.bits_per_byte
        cmd_num = self.get_bin(self.command_list[command]['command_number'],
                               self.command_num_bits)

        cmd_len = self.get_bin(payload_len, self.command_len_bits)

        #verify length of payload matches the specified length

        if not payload_len == received_payload_len:
            print 'specified payload {} does not match recevied payload size {}'.format(
                payload_len, received_payload_len)
        full_command_bin = cmd_num + cmd_len + payload  #build full binary string
        hex_fill = '{0:0>' + str(len(full_command_bin) / 4) + '}'
        #print '%x'% int(full_command_bin,2)
        full_command_hex = hex_fill.format(
            '%x' % int(full_command_bin, 2))  #build hex string zero fill

        #full_command_ascii = binascii.b2a_uu(full_command_bin)
        #self._send_handle.send(full_command_hex.decode('hex'))
        #print 'command ',command, cmd_num, cmd_len

        #print 'full_command binary:',command, cmd_num, cmd_len,payload
        #print 'full_command_decode',full_command_hex.decode('hex')
        #print 'full_command hex: ',full_command_hex
        #print 'full_command ascii:',full_command_ascii
        #         producer1 = Communications.count_stuff(1,5,Communications.myQueue)
        #         producer1.start()
        Communications.transmit(full_command_hex.decode('hex'), queue_priority)
Exemplo n.º 6
0
 def send(self, widget):
     fields = [self.classification, 'RouterPWM',
               widget.get_text()]  #,item.get_text()]
     print fields
     Communications.transmit(framer.wrapfieldscrc(fields))