sunfounder / SunFounder_PiCar

GNU General Public License v2.0
34 stars 75 forks source link

support for raspberry pi 4b #8

Open gpintore82 opened 5 years ago

gpintore82 commented 5 years ago

Please add support for it. I think the error is in PCF8591.py because im getting: Error. Pi revision didn't recognize, module number: c03111

Thanks!

ICEFIR commented 5 years ago

Passing bus number to the servo object constructor works on our end. Something like Servo.Servo(1, bus_number=1) Also I've added rasp pi 4 model num to PCF8591, I can create a pull request to fix this if its needed?

gpintore82 commented 5 years ago

Hey ICEFIR, thanks for the answer! I made it work adding the the rp4 model number to the PCF8591 too, but i've created the ticket, just in case anyone else needed that :). Again thanks!

peta-peta commented 4 years ago

Hi, I had the same problem on the Raspberry Pi 4B. I tried to use dragit for sunfounder-PiCar-V. Unfortunately, I got the error message Error. Pi revision didn't recognize, module number: c03111 Exiting...

I followed the instructions by gpintore82: If you have installed dragit through dragit_installer.py, you will be able to find dragit installed here /opt/SunFounder_Dragit/Dragit/.

Just modify the file /opt/SunFounder_Dragit/Dragit/Dragit/libs/picar/SunFounder_PCA9685/PCA9685.py and add RPI_REVISION_4_MODULE_B = ["c03111"] You will need to include the new version at line 70 and 100, too.

Cheers Peter

RPI_REVISION_0 = ["900092"]
RPI_REVISION_1_MODULE_B = ["Beta", "0002", "0003", "0004", "0005", "0006", "000d", "000e", "000f"]
RPI_REVISION_1_MODULE_A = ["0007", "0008", "0009",]
RPI_REVISION_1_MODULE_BP = ["0010", "0013"]
RPI_REVISION_1_MODULE_AP = ["0012"]
RPI_REVISION_2_MODULE_B = ["a01041", "a21041"]
RPI_REVISION_3_MODULE_B = ["a02082", "a22082"]
RPI_REVISION_3_MODULE_BP = ["a020d3"]
RPI_REVISION_4_MODULE_B = ["c03111"]

_DEBUG = False
_DEBUG_INFO = 'DEBUG "PCA9685.py":'

def _get_bus_number(self):
    pi_revision = self._get_pi_revision()
    if   pi_revision == '0':
        return 0
    elif pi_revision == '1 Module B':
        return 0
    elif pi_revision == '1 Module A':
        return 0
    elif pi_revision == '1 Module B+':
        return 1
    elif pi_revision == '1 Module A+':
        return 0
    elif pi_revision == '2 Module B':
        return 1
    elif pi_revision == '3 Module B':
        return 1
    elif pi_revision == '3 Module B+':
        return 1
    elif pi_revision == '4 Module B':
        return 1

def _get_pi_revision(self):
    "Gets the version number of the Raspberry Pi board"
    # Courtesy quick2wire-python-api
    # https://github.com/quick2wire/quick2wire-python-api
    # Updated revision info from: http://elinux.org/RPi_HardwareHistory#Board_Revision_History
    try:
        f = open('/proc/cpuinfo','r')
        for line in f:
            if line.startswith('Revision'):
                if line[11:-1] in self.RPI_REVISION_0:
                    return '0'
                elif line[11:-1] in self.RPI_REVISION_1_MODULE_B:
                    return '1 Module B'
                elif line[11:-1] in self.RPI_REVISION_1_MODULE_A:
                    return '1 Module A'
                elif line[11:-1] in self.RPI_REVISION_1_MODULE_BP:
                    return '1 Module B+'
                elif line[11:-1] in self.RPI_REVISION_1_MODULE_AP:
                    return '1 Module A+'
                elif line[11:-1] in self.RPI_REVISION_2_MODULE_B:
                    return '2 Module B'
                elif line[11:-1] in self.RPI_REVISION_3_MODULE_B:
                    return '3 Module B'
                elif line[11:-1] in self.RPI_REVISION_3_MODULE_BP:
                    return '3 Module B+'
        elif line[11:-1] in self.RPI_REVISION_4_MODULE_B:
                    return '4 Module B+'
NaderOudh98 commented 3 years ago

it didn't work with me, I did exact same what peta-peta did and it didn't work

Minemetero commented 8 months ago

my one say a03111, so maybe you meet same be careful with the code it out. Mine is a03111 so it should be a03111 when you change it