Commits

Nick Raptis  committed e27af67

Another patch and assorted test patch

  • Participants
  • Parent commits 88edf47

Comments (0)

Files changed (2)

File SeparateVersions.diff

+# HG changeset patch
+# Parent 71affbbdfb46f14cb5e4c54c500dc69d88823076
+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 71affbbdfb46 -r db0ca50bf305 pyfirmata/pyfirmata.py
+--- a/pyfirmata/pyfirmata.py	Tue May 17 00:08:41 2011 +0300
++++ b/pyfirmata/pyfirmata.py	Tue May 17 01:26:08 2011 +0300
+@@ -60,6 +60,7 @@
+     """
+     firmata_version = None
+     firmware = None
++    firmware_version = None
+     _command_handlers = {}
+     _command = None
+     _stored_data = []
+@@ -306,7 +307,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 = self.two_byte_to_str(data[2:])
+ 
+ class Port(object):
+@@ -482,4 +483,4 @@
+             except ValueError:
+                 byte = chr(byte >> 7) # TODO send multiple bytes
+             self.board.sp.write(byte)
+-        self.board.sp.write(chr(END_SYSEX))
+\ No newline at end of file
++        self.board.sp.write(chr(END_SYSEX))
+diff -r 71affbbdfb46 -r db0ca50bf305 tests.py
+--- a/tests.py	Tue May 17 00:08:41 2011 +0300
++++ b/tests.py	Tue May 17 01:26:08 2011 +0300
+@@ -63,7 +63,7 @@
+             data += [ord(x), 0]
+         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 
+     # ---------------------------------------------------------------------------
+@@ -121,7 +121,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), 
+@@ -132,7 +132,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 
+     # ---------------------------------------------------------------------------
+@@ -175,7 +175,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):
 TestFirmware7bit.diff
 WaitAndInit.diff
 GetBoardBug.diff
+SeparateVersions.diff
 # Placed by Bitbucket