+ def spitSingle(self,freq, standardid, repeat,writes, period = None, debug = False, packet = None):
+ """
+ This method will spit a single message onto the bus. If there is no packet information provided then the
+ message will be sent as a remote transmission request (RTR). The packet length is assumed to be 8 bytes The message can be repeated given number of times with
+ a gap of period (milliseconds) between each message. This will continue for the the number of times specified in the writes input.
+ This method will setup the bus and call the spit method, L{spit}. This method includes a bus reset and initialization.
+
+ @type freq: number
+ @param freq: The frequency of the bus
+
+ @type standardid: list of integer
+ @param standardid: This is a single length list with one integer elment that corresponds to the standard id you wish to write to
+
+ @type repeat: Boolean
+ @param repeat: If true the message will be repeatedly injected. if not the message will only be injected 1 time
+
+ @type writes: Integer
+ @param writes: Number of writes of the packet
+
+ @type period: Integer
+ @param period: Time delay between injections of the packet in Milliseconds
+
+ @type debug: Boolean
+ @param debug: When true debug status messages will be printed to the terminal
+
+ @type packet: List
+ @param packet: Contains the data bytes for the packet which is assumed to be of length 8. Each byte is stored as
+ an integer and can range from 0 to 255 (8 bits). If packet == None then an RTR will be sent on the given
+ standard id.
+
+ """
+ self.spitSetup(freq);
+ spit(self,freq, standardid, repeat,writes, period, debug , packet)
+
+ def spit(self,freq, standardid, repeat,writes, period = None, debug = False, packet = None):
+ """
+ This method will spit a single message onto the bus. If there is no packet information provided then the
+ message will be sent as a remote transmission request (RTR). The packet length is assumed to be 8 bytes The message can be repeated a given number of times with
+ a gap of period (milliseconds) between each message. This will continue for the the number of times specified in the writes input.
+ This method does not include bus setup, it must be done before the method call.
+
+
+ @type freq: number
+ @param freq: The frequency of the bus
+
+ @type standardid: list of integer
+ @param standardid: This is a single length list with one integer elment that corresponds to the standard id you wish to write to
+
+ @type repeat: Boolean
+ @param repeat: If true the message will be repeatedly injected. if not the message will only be injected 1 time
+
+ @type writes: Integer
+ @param writes: Number of writes of the packet
+
+ @type period: Integer
+ @param period: Time delay between injections of the packet in Milliseconds
+
+ @type debug: Boolean
+ @param debug: When true debug status messages will be printed to the terminal
+
+ @type packet: List
+ @param packet: Contains the data bytes for the packet which is assumed to be of length 8. Each byte is stored as
+ an integer and can range from 0 to 255 (8 bits). If packet == None then an RTR will be sent on the given
+ standard id.
+
+ """
+
+ #### split SID into different regs
+ SIDlow = (standardid[0] & 0x07) << 5; # get SID bits 2:0, rotate them to bits 7:5
+ SIDhigh = (standardid[0] >> 3) & 0xFF; # get SID bits 10:3, rotate them to bits 7:0
+
+ if(packet == None):
+
+ # if no packet, RTR for inputted arbID
+ # so packet to transmit is SID + padding out EID registers + RTR request (set bit 6, clear lower nibble of DLC register)
+ packet = [SIDhigh, SIDlow, 0x00,0x00,0x40]
+
+
+ else:
+
+ # if we do have a packet, packet is SID + padding out EID registers + DLC of 8 + packet
+ #
+ """@todo: allow for variable-length packets"""
+ # TODO: allow for variable-length packets
+ #
+ packet = [SIDhigh, SIDlow, 0x00,0x00, # pad out EID regs
+ 0x08, # bit 6 must be set to 0 for data frame (1 for RTR)
+ # lower nibble is DLC
+ packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7]]
+
+
+ if(debug):
+ if self.client.MCPcanstat()>>5!=0:
+ print "Warning: currently in %s mode. NOT in normal mode! May not transmit.\n" %self.client.MCPcanstatstr();
+ print "\nInitial state:"
+ print "Tx Errors: %3d" % self.client.peek8(0x1c);
+ print "Rx Errors: %3d" % self.client.peek8(0x1d);
+ print "Error Flags: %02x\n" % self.client.peek8(0x2d);