DEV Community

Cover image for Radio code generator for Dodge RAM in Python
Bartosz Wójcik for PELock LLC

Posted on

Radio code generator for Dodge RAM in Python

If you disconnect a car battery, your radio player might get locked as part of its standard anti-theft feature.

To unlock the radio again, you must generate a radio unlock code. I will show you how to generate it from Python using the Radio Code Calculator library.

Step 1: Install Radio Code Calculator API

The library is available on GitHub with complete sources.

https://github.com/PELock/Radio-Code-Calculator-Python

And on the PyPI repository.

https://pypi.org/project/radio-code-calculator/

To install it, add it to your new Python project with a command line of:

pip install radio-code-calculator

Step 2: Read your Dodge RAM radio player serial number

The serial number is on the placard on the back of the radio box. You will have to dismount it, but it's pretty easy:

You will need the last four characters of the serial number

Dodge RAM Truck Placard

Step 3: Generate the radio unlock key

Once you obtain your API key from the Radio Code Calculator service, you can check the Radio Code Calculator SDK documentation for all the parameters to generate the code for the suitable radio model.

#!/usr/bin/env python

###############################################################################
#
# Radio Code Calculator API - WebApi interface usage example
#
# In this example, we will demonstrate how to generate a code for a specific
# type of car radio.
#
# Version        : v1.1.6
# Language       : Python
# Author         : Bartosz Wójcik
# Project        : https://www.pelock.com/products/radio-code-calculator
# Homepage       : https://www.pelock.com
#
###############################################################################

#
# include Radio Code Calculator API module
#
from radio_code_calculator import *

#
# create Radio Code Calculator API class instance (we are using our activation key)
#
myRadioCodeCalculator = RadioCodeCalculator("ABCD-ABCD-ABCD-ABCD")

#
# generate radio code (using Web API)
#
error, result = myRadioCodeCalculator.calc(RadioModels.FIAT_VP, "C9PW")

if error == RadioErrors.SUCCESS:
    print(f'Radio code is {result["code"]}')
elif error == RadioErrors.INVALID_RADIO_MODEL:
    print("Invalid radio model (not supported)")
elif error == RadioErrors.INVALID_SERIAL_LENGTH:
    print(f'Invalid serial number length (expected {result["serialMaxLen"]} characters)')
elif error == RadioErrors.INVALID_SERIAL_PATTERN:
    print(f'Invalid serial number regular expression pattern (expected {result["serialRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_SERIAL_NOT_SUPPORTED:
    print("This serial number is not supported")
elif error == RadioErrors.INVALID_EXTRA_LENGTH:
    print(f'Invalid extra data length (expected {result["extraMaxLen"]} characters)')
elif error == RadioErrors.INVALID_EXTRA_PATTERN:
    print(f'Invalid extra data regular expression pattern (expected {result["extraRegexPattern"]["python"]} regex pattern)')
elif error == RadioErrors.INVALID_INPUT:
    print("Invalid input data")
elif error == RadioErrors.INVALID_COMMAND:
    print("Invalid command sent to the Web API interface")
elif error == RadioErrors.INVALID_LICENSE:
    print("Invalid license key")
elif error == RadioErrors.ERROR_CONNECTION:
    print("Something unexpected happen while trying to login to the service.")
else:
    print(f'Unknown error {error}')
Enter fullscreen mode Exit fullscreen mode

Step 4: Run the script

For our sample serial number ending with C9PW the radio unlock code for the Dodge RAM Uconnect Harman Kardon radio player is:

Radio code is 7013

What can you do with it?

  • Sell the radio codes on eBay or Craigslist

The end

It's pretty simple, and this is just for Python. The library also supports JS and PHP so you can integrate it easily within your sites, apps, and scripts. It also comes with a simple online interface to generate the codes for non-programmers.

Top comments (0)