Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Fix bugs with getPiRevision and readS16 #82

Merged
merged 4 commits into from
Jun 20, 2014
Merged

Fix bugs with getPiRevision and readS16 #82

merged 4 commits into from
Jun 20, 2014

Conversation

tdicola
Copy link
Contributor

@tdicola tdicola commented Jun 19, 2014

This pull fixes a couple small issues:

  • getPiRevision's check for the revision 1 boards should check for revisions ending in '2' or '3' instead of '1' or '2'. This is based on the revision info from here: http://elinux.org/RPi_HardwareHistory#Board_Revision_History and looking at the latest quick2wire-python-api code which also now checks for 2 or 3.

  • readS16 was actually returning unsigned values. This fixes the function so it returns a signed value, and adds an optional little_endian=True or False parameter (defaults to true). The endian parameter will make it explicit what endianness the caller desires since the underlying I2C read system calls assume little endian (which causes problems when reading big endian data like BMP085 sensor calibration).

    Note that this is a potentially breaking change for code which currently uses readS16 and unknowingly depends on it actually returning incorrect unsigned values. I searched the Adafruit github code and don't see anything depending the function so it should be safe to change. For folks that have code that depends on this bug I think it's best to still make this fix and help them update their code going forward (either switching to readU16 or using readS16 with signed data correctly).

tdicola added a commit that referenced this pull request Jun 20, 2014
Fix bugs with getPiRevision and readS16
@tdicola tdicola merged commit 11263c4 into master Jun 20, 2014
@tdicola tdicola deleted the i2c_fixes branch June 20, 2014 01:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant