Ejemplo n.º 1
0
 def GetValue(self):
     name = self.name.GetValue()
     id = int(self.arbId.GetValue(),16)
     xtd = self.xtd.GetValue()
     dType = self.dataTypesVal[self.dataType.GetSelection()]
     endian = self.endianessesVal[self.endianess.GetSelection()]
     startBit = self.startBit.GetValue()
     bitLength = self.bitLength.GetValue()
     value = float(self.value.GetValue())
             
     return CANMessage.CANSignal(name, id, xtd, dType, endian, startBit, bitLength, value)
Ejemplo n.º 2
0
if __name__ == "__main__":
    if sys.platform == 'win32':
        DEVICE = "COM3"
    else:
        DEVICE = "/dev/ttyUSB0"

    try:
        canusb = lawicel_canusb.opencan(DEVICE, 1000000)
        count = 0

        startTime = time.time()

        while (1):
            try:
                #sig = CANMessage.CANSignal("test", 0x300+(count%8), 0, 'f64', 'motorola', 56, 64, count/((count%8)+1))
                sig = CANMessage.CANSignal("test", 0x300, 0, 'i32', 'intel', 4,
                                           32, count)
                canusb.transmit_frame(sig.to_canframe())
                count = count + 1
            except lawicel_canusb.CANUSBError, e:
                # re-raise error if it's not timeout
                if str(e).find("timeout") < 0:
                    print "CANUSB error: " + str(e)
                    break
                else:
                    continue

            if count >= 500:
                duration = time.time() - startTime
                rate = float(count) / duration
                print "sent %d frames in %f s (%f frames/s)" % (count,
                                                                duration, rate)