update 2016-11-10 b1
1. merged unused encoder for irext
This commit is contained in:
Binary file not shown.
@@ -6,12 +6,12 @@ LOCAL_CFLAGS := -DBOARD_ANDROID
|
||||
LOCAL_MODULE := libirdecode
|
||||
LOCAL_SRC_FILES := irda_decode_jni.c \
|
||||
irda_decode.c \
|
||||
irda_tv_parse.c \
|
||||
irda_apply.c \
|
||||
irda_irframe.c \
|
||||
irda_parse_ac_parameter.c \
|
||||
irda_parse_forbidden_info.c \
|
||||
irda_parse_frame_parameter.c \
|
||||
irda_tv_parse_protocol.c \
|
||||
irda_ac_apply.c \
|
||||
irda_ac_build_frame.c \
|
||||
irda_ac_parse_parameter.c \
|
||||
irda_ac_parse_forbidden_info.c \
|
||||
irda_ac_parse_frame_parameter.c \
|
||||
irda_utils.c \
|
||||
|
||||
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
|
||||
|
||||
@@ -7,19 +7,19 @@ add_definitions(-DBOARD_PC)
|
||||
set(SOURCE_FILES_EXECUTABLE
|
||||
irda_decode.c
|
||||
include/irda_decode.h
|
||||
irda_tv_parse.c
|
||||
include/irda_tv_parse.h
|
||||
irda_apply.c
|
||||
include/irda_apply.h
|
||||
irda_tv_parse_protocol.c
|
||||
include/irda_tv_parse_protocol.h
|
||||
irda_ac_apply.c
|
||||
include/irda_ac_apply.h
|
||||
include/irda_defs.h
|
||||
irda_irframe.c
|
||||
include/irda_irframe.h
|
||||
irda_parse_ac_parameter.c
|
||||
include/irda_parse_ac_parameter.h
|
||||
irda_parse_forbidden_info.c
|
||||
include/irda_parse_forbidden_info.h
|
||||
irda_parse_frame_parameter.c
|
||||
include/irda_parse_frame_parameter.h
|
||||
irda_ac_build_frame.c
|
||||
include/irda_ac_build_frame.h
|
||||
irda_ac_parse_parameter.c
|
||||
include/irda_ac_parse_parameter.h
|
||||
irda_ac_parse_forbidden_info.c
|
||||
include/irda_ac_parse_forbidden_info.h
|
||||
irda_ac_parse_frame_parameter.c
|
||||
include/irda_ac_parse_frame_parameter.h
|
||||
irda_utils.c
|
||||
include/irda_utils.h
|
||||
irda_main.c
|
||||
@@ -28,19 +28,19 @@ set(SOURCE_FILES_EXECUTABLE
|
||||
set(SOURCE_FILES_SHARED_LIB
|
||||
irda_decode.c
|
||||
include/irda_decode.h
|
||||
irda_tv_parse.c
|
||||
include/irda_tv_parse.h
|
||||
irda_apply.c
|
||||
include/irda_apply.h
|
||||
irda_tv_parse_protocol.c
|
||||
include/irda_tv_parse_protocol.h
|
||||
irda_ac_apply.c
|
||||
include/irda_ac_apply.h
|
||||
include/irda_defs.h
|
||||
irda_irframe.c
|
||||
include/irda_irframe.h
|
||||
irda_parse_ac_parameter.c
|
||||
include/irda_parse_ac_parameter.h
|
||||
irda_parse_forbidden_info.c
|
||||
include/irda_parse_forbidden_info.h
|
||||
irda_parse_frame_parameter.c
|
||||
include/irda_parse_frame_parameter.h
|
||||
irda_ac_build_frame.c
|
||||
include/irda_ac_build_frame.h
|
||||
irda_ac_parse_parameter.c
|
||||
include/irda_ac_parse_parameter.h
|
||||
irda_ac_parse_forbidden_info.c
|
||||
include/irda_ac_parse_forbidden_info.h
|
||||
irda_ac_parse_frame_parameter.c
|
||||
include/irda_ac_parse_frame_parameter.h
|
||||
irda_utils.c
|
||||
include/irda_utils.h)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Revision log:
|
||||
|
||||
#include "./include/irda_utils.h"
|
||||
#include "./include/irda_decode.h"
|
||||
#include "./include/irda_apply.h"
|
||||
#include "include/irda_ac_apply.h"
|
||||
|
||||
/*
|
||||
* global vars
|
||||
@@ -611,4 +611,3 @@ INT8 apply_checksum(struct ac_protocol *protocol)
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ Revision log:
|
||||
**************************************************************************************************/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "./include/irda_irframe.h"
|
||||
#include "include/irda_ac_build_frame.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
extern protocol* context;
|
||||
@@ -18,7 +18,7 @@ Revision log:
|
||||
|
||||
#include "./include/irda_decode.h"
|
||||
#include "./include/irda_utils.h"
|
||||
#include "./include/irda_parse_forbidden_info.h"
|
||||
#include "include/irda_ac_parse_forbidden_info.h"
|
||||
/*
|
||||
* global vars
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ Revision log:
|
||||
#include <string.h>
|
||||
|
||||
#include "./include/irda_utils.h"
|
||||
#include "./include/irda_parse_frame_parameter.h"
|
||||
#include "include/irda_ac_parse_frame_parameter.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
/*
|
||||
@@ -16,7 +16,7 @@ Revision log:
|
||||
#include <string.h>
|
||||
|
||||
#include "./include/irda_utils.h"
|
||||
#include "./include/irda_parse_ac_parameter.h"
|
||||
#include "include/irda_ac_parse_parameter.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
/*
|
||||
@@ -15,12 +15,12 @@ Revision log:
|
||||
|
||||
#include "./include/irda_decode.h"
|
||||
#include "./include/irda_utils.h"
|
||||
#include "./include/irda_parse_frame_parameter.h"
|
||||
#include "./include/irda_parse_ac_parameter.h"
|
||||
#include "./include/irda_parse_forbidden_info.h"
|
||||
#include "./include/irda_irframe.h"
|
||||
#include "./include/irda_apply.h"
|
||||
#include "include/irda_tv_parse.h"
|
||||
#include "include/irda_ac_parse_frame_parameter.h"
|
||||
#include "include/irda_ac_parse_parameter.h"
|
||||
#include "include/irda_ac_parse_forbidden_info.h"
|
||||
#include "include/irda_ac_build_frame.h"
|
||||
#include "include/irda_ac_apply.h"
|
||||
#include "include/irda_tv_parse_protocol.h"
|
||||
|
||||
struct ir_bin_buffer binaryfile;
|
||||
struct ir_bin_buffer *pirda_buffer = &binaryfile;
|
||||
|
||||
@@ -19,7 +19,7 @@ Revision log:
|
||||
#include "./include/irda_main.h"
|
||||
|
||||
// global variable definition
|
||||
UINT16 binary_length = 0;
|
||||
long binary_length = 0;
|
||||
UINT8 *binary_content = NULL;
|
||||
|
||||
INT8 irda_ac_file_open(const char* file_name);
|
||||
@@ -58,7 +58,7 @@ INT8 irda_ac_file_open(const char* file_name)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
UINT8 decode_as_ac(const char* file_name)
|
||||
INT8 decode_as_ac(const char* file_name)
|
||||
{
|
||||
// keyboard input
|
||||
int in_char = 0;
|
||||
@@ -238,7 +238,7 @@ INT8 irda_tv_file_open(const char* file_name)
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
UINT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
||||
INT8 decode_as_tv(char *file_name, UINT8 irda_hex_encode)
|
||||
{
|
||||
// keyboard input
|
||||
int in_char = 0;
|
||||
|
||||
@@ -17,7 +17,7 @@ Revision log:
|
||||
#include <string.h>
|
||||
|
||||
#include "./include/irda_defs.h"
|
||||
#include "./include/irda_tv_parse.h"
|
||||
#include "include/irda_tv_parse_protocol.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
@@ -226,7 +226,7 @@ static BOOL get_irda_keymap(void)
|
||||
remote_p = (irda_data_tv_t *) (pbuffer->data + pbuffer->offset);
|
||||
pbuffer->offset += sizeof(irda_data_tv_t);
|
||||
|
||||
if (strncmp(remote_p->magic, "ykir", 4) == 0)
|
||||
if (strncmp(remote_p->magic, "irda", 4) == 0)
|
||||
{
|
||||
remote_pdata = pbuffer->data + pbuffer->offset;
|
||||
return TRUE;
|
||||
@@ -3,7 +3,7 @@
|
||||
# for protocol version V1.0
|
||||
# 29 tags are supported
|
||||
|
||||
import sys,os
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
@@ -60,22 +60,21 @@ def create_binary(ac_device):
|
||||
for i in range(len(alltags)):
|
||||
find = 0
|
||||
for j in range(len(ac_device.tags)):
|
||||
if (alltags[i] == ac_device.tags[j].tag):
|
||||
if alltags[i] == ac_device.tags[j].tag:
|
||||
f_content.write(ac_device.tags[j].value)
|
||||
|
||||
f_head.write(struct.pack("H", offset))
|
||||
offset = offset + ac_device.tags[j].len
|
||||
###############################################################################
|
||||
# Find Max length
|
||||
###############################################################################
|
||||
if (tags_max_size[i] < ac_device.tags[j].len):
|
||||
|
||||
# Find Max length
|
||||
if tags_max_size[i] < ac_device.tags[j].len:
|
||||
tags_max_size[i] = ac_device.tags[j].len;
|
||||
find = 1
|
||||
break
|
||||
|
||||
if find == 0:
|
||||
f_head.write(struct.pack("H", 0xffff))
|
||||
#f.write(ac_device)
|
||||
# f.write(ac_device)
|
||||
f_content.close()
|
||||
f_tmp = open(sys.argv[2] + str(ac_device.device_id) + "_tmp.bin", "rb")
|
||||
f_head.write(f_tmp.read())
|
||||
@@ -84,7 +83,7 @@ def create_binary(ac_device):
|
||||
|
||||
dom = xml.dom.minidom.parse(sys.argv[1])
|
||||
device = dom.documentElement
|
||||
#devices = root.getElementsByTagName('remote_controller')
|
||||
# devices = root.getElementsByTagName('remote_controller')
|
||||
|
||||
print "============================"
|
||||
print "AC data:"
|
||||
111
src/ir_encoder/irda_tv_encode.py
Normal file
111
src/ir_encoder/irda_tv_encode.py
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict_tv = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", "HOME",
|
||||
"SET", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
keymap_dict_stb = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU",
|
||||
"UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
keymap_dict_nw = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "MENU", "HOME", "0", "1", "2",
|
||||
"3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
keymap_dict_iptv = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU",
|
||||
"UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
keymap_dict_dvd = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "PLAY", "PAUSE", "EJECT", "BACK",
|
||||
"FOR", "MENU", "SWITCH")
|
||||
|
||||
keymap_dict_fan = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "SPEED+", "SPEED-", "SWING", "SPEED", "MODE", "BACK",
|
||||
"HOME", "MENU", "SWITCH")
|
||||
|
||||
keymap_dict_stereo = ("POWER1", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "MUTE", "MENU1", "POWER2", "BACK",
|
||||
"HOME", "MENU2", "SWITCH")
|
||||
|
||||
keymap_dict_projector = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "ZOOM+", "MENU1", "ZOOM-",
|
||||
"BACK", "HOME", "MENU2", "SWITCH")
|
||||
|
||||
keymap_dict_light = ("POWER", "COLOR_1", "COLOR_2", "COLOR_3", "COLOR_4", "COLOR_0", "BRIGHT", "DARK", "POWER_ON",
|
||||
"RAINBOW", "POWER_OFF", "BACK", "HOME", "MENU", "SWITCH")
|
||||
|
||||
keymap_dict_air_cleaner = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "ION", "PLUS", "MINUS", "AUTO", "SPEED", "MODE",
|
||||
"TIMING", "LIGHT", "FORCE", "SWITCH")
|
||||
|
||||
keymap_dict_clean_robot = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "START", "PLUS", "MINUS", "AUTO", "SPOT", "SPEED",
|
||||
"TIMING", "CHARGE", "PLAN", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def print_info(self):
|
||||
print self.name, self.value
|
||||
|
||||
def pack_key(self, output_file):
|
||||
for i in range(len(self.value)):
|
||||
output_file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def pack_null(self, output_file):
|
||||
for i in range(len(self.value)):
|
||||
output_file.write(struct.pack('B', 0))
|
||||
|
||||
def pack_length(self, output_file):
|
||||
output_file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(input_file, real_path, real_name):
|
||||
print input_file
|
||||
dom = xml.dom.minidom.parse(input_file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = real_name.split('.')
|
||||
|
||||
binary = open(real_path + "/" + protocol + "#" + filename[0] + ".bin", 'wb')
|
||||
tag = struct.pack('4s', 'irda')
|
||||
binary.write(tag)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].pack_length(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].print_info()
|
||||
key[n].pack_key(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.pack_key(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -15,12 +15,12 @@ for root, dirs, files in os.walk(sys.argv[1]):
|
||||
remotePath = sys.argv[2]
|
||||
fileType2 = remotePath.split('.')
|
||||
if cmp(fileType2[-1], 'bin') == 0:
|
||||
prottype = fileType2[0].split('#')
|
||||
print(prottype[0])
|
||||
protocolType = fileType2[0].split('#')
|
||||
print(protocolType[0])
|
||||
print(fileType[0])
|
||||
if cmp(prottype[0].split('/')[-1], fileType[0]) == 0:
|
||||
outname = remotePath.split('#')
|
||||
binary = open(sys.argv[3] + "/ykir_"+outname[0].split('/')[-1]+"_"+outname[1], 'wb')
|
||||
if cmp(protocolType[0].split('/')[-1], fileType[0]) == 0:
|
||||
outName = remotePath.split('#')
|
||||
binary = open(sys.argv[3] + "/irda_" + outName[0].split('/')[-1] + "_" + outName[1], 'wb')
|
||||
prot_file = open(root+i, "rb")
|
||||
remote_file = open(remotePath, "rb")
|
||||
binary.write(prot_file.read())
|
||||
@@ -29,5 +29,3 @@ for root, dirs, files in os.walk(sys.argv[1]):
|
||||
prot_file.close()
|
||||
remote_file.close()
|
||||
print remotePath
|
||||
print
|
||||
print
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "ION", "PLUS", "MINUS", "AUTO", "SPEED", "MODE", "TIMING",
|
||||
"LIGHT", "FORCE", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,108 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
# for protocol version V1.0
|
||||
# 20 tags are supported
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
allTags = [100, 101, 102, 103, 200, 201, 202, 203, 204, 205,
|
||||
206, 207, 208, 209, 210, 211, 212, 213, 214, 300]
|
||||
tags_max_size = [0 for x in range(0, len(allTags))]
|
||||
|
||||
# Definition of BLE Central tag class
|
||||
# (tag:value)
|
||||
|
||||
|
||||
class BCTag:
|
||||
def __init__(self, tag, value):
|
||||
self.tag = tag
|
||||
self.value = value
|
||||
self.len = len(self.value)
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.tag < other.tag
|
||||
|
||||
def printf(self):
|
||||
print "[%d] %s len:%d" % (self.tag, self.value, len(self.value))
|
||||
|
||||
# Definition of Remote_control class
|
||||
# device id:(tag:value)...(tag:value)
|
||||
|
||||
|
||||
class BCRemoteControl:
|
||||
def __init__(self, device_id):
|
||||
self.device_id = device_id
|
||||
self.tags = []
|
||||
|
||||
def add(self, tag):
|
||||
self.tags.append(tag)
|
||||
|
||||
def sort(self):
|
||||
self.tags.sort()
|
||||
|
||||
def printf(self):
|
||||
print "==========Device id:%d===========" % self.device_id
|
||||
for j in range(len(self.tags)):
|
||||
self.tags[j].printf()
|
||||
|
||||
|
||||
def create_binary(bc_device):
|
||||
find = 0
|
||||
offset = 0
|
||||
|
||||
f_content = open(sys.argv[2] + str(bc_device.device_id) + "_tmp.bin", "wb")
|
||||
f_head = open(sys.argv[2] + "ykir_bc_" + str(bc_device.device_id) + ".bin", "wb")
|
||||
f_head.write(struct.pack("B", 20))
|
||||
for i in range(len(allTags)):
|
||||
find = 0
|
||||
for j in range(len(bc_device.tags)):
|
||||
if allTags[i] == bc_device.tags[j].tag:
|
||||
f_content.write(bc_device.tags[j].value)
|
||||
|
||||
f_head.write(struct.pack("H", offset))
|
||||
offset = offset + bc_device.tags[j].len
|
||||
###############################################################################
|
||||
# Find Max length
|
||||
###############################################################################
|
||||
if tags_max_size[i] < bc_device.tags[j].len:
|
||||
tags_max_size[i] = bc_device.tags[j].len
|
||||
find = 1
|
||||
break
|
||||
|
||||
if find == 0:
|
||||
f_head.write(struct.pack("H", 0xffff))
|
||||
|
||||
f_content.close()
|
||||
f_tmp = open(sys.argv[2] + str(bc_device.device_id) + "_tmp.bin", "rb")
|
||||
f_head.write(f_tmp.read())
|
||||
f_tmp.close()
|
||||
f_head.close()
|
||||
|
||||
dom = xml.dom.minidom.parse(sys.argv[1])
|
||||
device = dom.documentElement
|
||||
# devices = root.getElementsByTagName('remote_controller')
|
||||
|
||||
print "============================"
|
||||
print "BC data:"
|
||||
print "============================"
|
||||
bc_device_array=[]
|
||||
id = device.getElementsByTagName('id')
|
||||
idnum = int(id[0].firstChild.data.encode('ascii'), 10)
|
||||
|
||||
g_bc_device = BCRemoteControl(idnum)
|
||||
print "------------BC Device ID: %d-------------" % idnum
|
||||
exts = device.getElementsByTagName('exts')
|
||||
for n in range(len(exts)):
|
||||
ext = exts[n].getElementsByTagName('ext')
|
||||
for j in range(len(ext)):
|
||||
tag_index=ext[j].getElementsByTagName('tag')
|
||||
tag_index_data = int(tag_index[0].firstChild.data.encode('ascii'), 10)
|
||||
tag_value=ext[j].getElementsByTagName('value')
|
||||
tag_value_data = tag_value[0].firstChild.data.encode('ascii')
|
||||
g_bc_device.add(BCTag(tag_index_data, tag_value_data))
|
||||
g_bc_device.sort()
|
||||
g_bc_device.printf()
|
||||
create_binary(g_bc_device)
|
||||
bc_device_array.append(g_bc_device)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "CHAN+", "CHAN-", "BACK", "MUTE", "PROGRAM",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "START", "PLUS", "MINUS", "AUTO", "SPOT", "SPEED", "TIMING",
|
||||
"CHARGE", "PLAN", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "PLAY", "PAUSE", "EJECT", "BACK", "FOR", "MENU", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "SPEED+", "SPEED-", "SWING", "SPEED", "MODE", "BACK",
|
||||
"HOME", "MENU", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath + "/" + protocol + "#" + filename[0] + ".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU",
|
||||
"UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "COLOR_1", "COLOR_2", "COLOR_3", "COLOR_4", "COLOR_0", "BRIGHT", "DARK", "POWER_ON", "RAINBOW",
|
||||
"POWER_OFF", "BACK", "HOME", "MENU", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "MENU", "HOME", "0", "1", "2",
|
||||
"3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -5,7 +5,8 @@ import struct
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
|
||||
flag_tab = ("boot", "stop", "separator", "one", "zero", "flip", "two", "three", "four", "five", "six", "seven", "eight", "nine", "A", "B", "C", "D", "E", "F")
|
||||
flag_tab = ("boot", "stop", "separator", "one", "zero", "flip", "two", "three", "four", "five", "six", "seven",
|
||||
"eight", "nine", "A", "B", "C", "D", "E", "F")
|
||||
|
||||
class IRDAData:
|
||||
def __init__(self, bits, lsb, mode, index):
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "ZOOM+", "MENU1", "ZOOM-", "BACK", "HOME",
|
||||
"MENU2", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU",
|
||||
"UP_PAGE", "DOWN_PAGE", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER1", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "MUTE", "MENU1", "POWER2", "BACK", "HOME",
|
||||
"MENU2", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "MUTE", "INPUT1", "INPUT2", "BACK", "HOME",
|
||||
"MENU", "SWITCH")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding = utf-8
|
||||
|
||||
import sys
|
||||
import xml.dom.minidom
|
||||
import struct
|
||||
|
||||
keymap_dict = ("POWER", "MUTE", "UP", "DOWN", "LEFT", "RIGHT", "OK", "VOL+", "VOL-", "BACK", "INPUT", "MENU", "HOME",
|
||||
"SET", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||
|
||||
|
||||
class CKeyMap:
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def printf(self):
|
||||
print self.name, self.value
|
||||
|
||||
def packkey(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', self.value[i]))
|
||||
|
||||
def packnull(self, file):
|
||||
for i in range(len(self.value)):
|
||||
file.write(struct.pack('B', 0))
|
||||
|
||||
def packlen(self, file):
|
||||
file.write(struct.pack('B', len(self.value)))
|
||||
print len(self.value)
|
||||
|
||||
|
||||
def print_remote(file, realPath, realName):
|
||||
print file
|
||||
dom = xml.dom.minidom.parse(file)
|
||||
root = dom.documentElement
|
||||
protocol_node = root.getElementsByTagName('protocol')
|
||||
protocol = protocol_node[0].firstChild.data
|
||||
|
||||
filename = realName.split('.')
|
||||
|
||||
binary = open(realPath+"/"+protocol+"#"+filename[0]+".bin", 'wb')
|
||||
bytes = struct.pack('4s', 'ykir')
|
||||
binary.write(bytes)
|
||||
|
||||
print protocol
|
||||
keymap = root.getElementsByTagName('key-map')
|
||||
key = []
|
||||
empty_value = []
|
||||
for i in keymap[0].childNodes:
|
||||
if i.nodeType == i.ELEMENT_NODE:
|
||||
key_map_str = i.firstChild.data.encode('ascii').split(' ')
|
||||
value = []
|
||||
empty_value = []
|
||||
for m in range(len(key_map_str)):
|
||||
value.append(int(key_map_str[m], 16))
|
||||
empty_value.append(int('0', 16))
|
||||
name = i.getAttribute('name').encode('ascii')
|
||||
data = CKeyMap(name, value)
|
||||
key.append(data)
|
||||
|
||||
key[0].packlen(binary)
|
||||
for j in range(len(keymap_dict)):
|
||||
empty_key = CKeyMap(keymap_dict[j], empty_value)
|
||||
find = 0
|
||||
for n in range(len(key)):
|
||||
if cmp(keymap_dict[j], key[n].name) == 0:
|
||||
key[n].printf()
|
||||
key[n].packkey(binary)
|
||||
find = 1
|
||||
break
|
||||
if find == 0:
|
||||
print "Don't file this key %s" % (keymap_dict[j])
|
||||
empty_key.packkey(binary)
|
||||
|
||||
fileName = sys.argv[1]
|
||||
realName = sys.argv[2]
|
||||
realPath = sys.argv[3]
|
||||
fileType = fileName.split('.')
|
||||
if cmp(fileType[1], "xml") == 0:
|
||||
print_remote(fileName, realPath, realName)
|
||||
Reference in New Issue
Block a user