pyFirmata_nickraptis_mq / SeparateVersions.diff

# HG changeset patch
# Parent cb5d071fad399ef8565e273565b820c2c3ad1cb1
Separated Firmware and Firmata versions

While StandardFirmata firmwares are versioned according
to the Protocol version, the firmware version can
actually be distinct from the firmata protocol version.

diff -r cb5d071fad39 pyfirmata/pyfirmata.py
--- a/pyfirmata/pyfirmata.py	Tue May 17 09:55:11 2011 +0200
+++ b/pyfirmata/pyfirmata.py	Tue May 17 14:25:04 2011 +0300
@@ -60,6 +60,7 @@
     """
     firmata_version = None
     firmware = None
+    firmware_version = None
     _command_handlers = {}
     _command = None
     _stored_data = []
@@ -292,7 +293,7 @@
     def _handle_report_firmware(self, *data):
         major = data[0]
         minor = data[1]
-        self.firmata_version = (major, minor)
+        self.firmware_version = (major, minor)
         self.firmware = two_byte_iter_to_str(data[2:])
 
 class Port(object):
diff -r cb5d071fad39 tests.py
--- a/tests.py	Tue May 17 09:55:11 2011 +0200
+++ b/tests.py	Tue May 17 14:25:04 2011 +0300
@@ -61,7 +61,7 @@
         data = [2, 1] + str_to_two_byte_iter('Firmware_name')
         self.board._handle_report_firmware(*data)
         self.assertEqual(self.board.firmware, 'Firmware_name')
-        self.assertEqual(self.board.firmata_version, (2, 1))
+        self.assertEqual(self.board.firmware_version, (2, 1))
         
     # type                command  channel    first byte            second byte 
     # ---------------------------------------------------------------------------
@@ -119,7 +119,7 @@
     # 6  END_SYSEX (0xF7)
     def test_incoming_report_firmware(self):
         self.assertEqual(self.board.firmware, None)
-        self.assertEqual(self.board.firmata_version, None)
+        self.assertEqual(self.board.firmware_version, None)
         msg = [chr(pyfirmata.START_SYSEX), 
                chr(pyfirmata.REPORT_FIRMWARE), 
                chr(2), 
@@ -128,7 +128,7 @@
         self.board.sp.write(msg)
         self.board.iterate()
         self.assertEqual(self.board.firmware, 'Firmware_name')
-        self.assertEqual(self.board.firmata_version, (2, 1))
+        self.assertEqual(self.board.firmware_version, (2, 1))
         
     # type                command  channel    first byte            second byte 
     # ---------------------------------------------------------------------------
@@ -170,7 +170,7 @@
         self.board.sp.write(sysex)
         while len(self.board.sp):
             self.board.iterate()
-        self.assertEqual(self.board.firmata_version, (2, 1))
+        self.assertEqual(self.board.firmware_version, (2, 1))
         self.assertEqual(self.board.firmware, 'abc')
         
     def test_too_much_data(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.