From 12b9417f3620cf74fb733f5fc1437a9ec109abcc Mon Sep 17 00:00:00 2001 From: travisutk Date: Wed, 15 Aug 2012 21:29:05 +0000 Subject: [PATCH] More MCP2515 CAN Bus commands. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1227 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETMCPCAN.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/client/GoodFETMCPCAN.py b/client/GoodFETMCPCAN.py index e942b42..aab98f4 100644 --- a/client/GoodFETMCPCAN.py +++ b/client/GoodFETMCPCAN.py @@ -28,9 +28,22 @@ class GoodFETMCPCAN(GoodFETSPI): data=self.SPItrans([0xB0,0x00]); return ord(data[1]); def MCPreadstatus(self): - """Reads the RX Status by the SPI verb of the same name.""" + """Reads the Read Status by the SPI verb of the same name.""" + #See page 67 of the datasheet for the flag names. data=self.SPItrans([0xA0,0x00]); return ord(data[1]); + def MCPrts(self,TXB0=False,TXB1=False,TXB2=False): + """Requests to send one of the transmit buffers.""" + flags=0; + if TXB0: flags=flags|1; + if TXB1: flags=flags|2; + if TXB2: flags=flags|4; + + if flags==0: + print "Warning: Requesting to send no buffer."; + + """Request To Send a transmission.""" + self.SPItrans([0x80|flags]); def peek8(self,adr): """Read a byte from the given address. Untested.""" data=self.SPItrans([0x03,adr&0xFF,00]); @@ -40,23 +53,3 @@ class GoodFETMCPCAN(GoodFETSPI): """Poke a value into RAM. Untested""" self.SPItrans([0x02,adr&0xFF,val&0xFF]); return val; - def rand16(self): - """Read a random 16-bit word.""" - - data=self.EZSPtrans([0x49]); - if data==None: - print "Insufficient random data."; - return 0; - return ord(data[6])+(ord(data[7])<<8); - - def info(self): - """Read the info bytes.""" - print "Ember EM26 Z-Stack SPI Module."; - version=self.EM260spiversion(); - status=self.EM260spistatus(); - print "Version: %i" % (version); - print "Status: %s" % (["dead","alive"][status]); - print "" - self.setVersion(); - print "Node ID: %04x" % (self.getNodeID()); - print "Connected to %2i neighbors." % self.neighborCount(); -- 2.20.1