Project Name : {{this.currentFile.name}}
Your Code ...
import binascii import struct def pronto2lirc(pronto): codes = [long(binascii.hexlify(pronto[i:i+2]), 16) for i in xrange(0, len(pronto), 2)] if codes[0]: raise ValueError('Pronto code should start with 0000') if len(codes) != 4 + 2 * (codes[2] + codes[3]): raise ValueError('Number of pulse widths does not match the preamble') frequency = 1 / (codes[1] * 0.241246) return [int(round(code / frequency)) for code in codes[4:]] def lirc2broadlink(pulses): array = bytearray() for pulse in pulses: pulse = pulse * 269 / 8192 # 32.84ms units if pulse < 256: array += bytearray(struct.pack('>B', pulse)) # big endian (1-byte) else: array += bytearray([0x00]) # indicate next number is 2-bytes array += bytearray(struct.pack('>H', pulse)) # big endian (2-bytes) packet = bytearray([0x26, 0x00]) # 0x26 = IR, 0x00 = no repeats packet += bytearray(struct.pack('<H', len(array))) # little endian byte count packet += array packet += bytearray([0x0d, 0x05]) # IR terminator # Add 0s to make ultimate packet size a multiple of 16 for 128-bit AES encryption. remainder = (len(packet) + 4) % 16 # rm.send_data() adds 4-byte header (02 00 00 00) if remainder: packet += bytearray(16 - remainder) return packet if __name__ == '__main__': import sys for code in sys.argv[1:]: pronto = bytearray.fromhex(code) pulses = pronto2lirc(pronto) packet = lirc2broadlink(pulses) print print binascii.hexlify(packet)
CommandLine Arguments ...
Stdin Inputs...
Interactive mode :

Focus View:

Version :
Please Login to use this function
Share URL
CPU Time: {{this.cpuTime}} sec(s), Memory: {{this.memory}} kilobyte(s)
executed in {{this.executionTime}} sec(s)
Please enter all values - GroupID, ArtifactID and Version
Note: you can search maven artifact details in http://search.maven.org/ or http://mvnrepository.com/
Trying to save your file, Please wait...

My {{this.language}} Projects

Loading, Please wait...
File Deleted Successfully
Unable to Delete, please try again later or contact JDoodle support

Are you sure, you want to delete this file?

Recent {{this.language}} Projects

{{moment(option.executedAt).format("MMMM Do YYYY, h:mm:ss a")}}
{{this.setLanguage("python2", "2.7.11, 2.7.15","jdoodle.py",false, 0)}}
{{this.setShared("", "","","jdoodle.com/a/eBD","https://www.jdoodle.com/embed/v0/eBD")}}
Your valuable inputs will help us improve this site
please give your comments. Thanks.
Which language would you like to see next in JDoodle?
Thanks for your Input!
{{this.surveyForm.comment}} is already available at {{this.surveyForm.existingPath}}
For direct response, please include your email id in the comment
or email to jdoodle@nutpan.com
Thanks for your Input!

Sign in

New to JDoodle ? -
JDoodle is trying to signin you in, Please wait...


Thanks for registering!!!
We have sent you an email for confirmation.
Before login, Please check your email to complete the registration!
Already Have an Account ? -
We recommend
or you can register with your email below
{{ message }}
JDoodle is creating an account for you, Please wait...
By registering, you agree to the Terms of Service

Forgot Password


Please check your email for password reset link.

JDoodle is checking your details, Please wait...

Unlock Account


Please check your email for unlock link.

JDoodle is checking your details, Please wait...

Change Password

Password Successfully Changed


Change Display Name


Display Name Successfully Updated

Welcome to JDoodle

app loading now, please wait...