找回密码
 注册

QQ登录

只需一步,快速开始

华为EC1308机顶盒更改参数教程

20
回复
73154
查看
[复制链接]
来源:华为盒子 2017-4-5 09:40:00 |阅读模式
华为EC1308机顶盒有几个版本,本方式只适用于采用海思Hi3560V100芯片,且存在设备文件/dev/misc/e2prom_24lc16的机顶盒。

用Telnet登录机顶盒,执行下面的命令:
游客,如果您要查看本帖隐藏内容请回复

修改参数程序源代码如下:
#include <fcntl.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>

typedef struct {
        unsigned int        e2prom_cmd_sub_addr;
        unsigned int        sub_addr_count;
        unsigned char*        e2prom_cmd_data;
        unsigned int        data_count;
} e2prom_s_cmd;

#define E2PROM_CMD_READ 1
#define E2PROM_CMD_WRITE 2
#define E2PROM_DEVICE "/dev/misc/e2prom_24lc16"

static int readparam(unsigned char *mac, unsigned char *stbid)
{
        int fd, ret;
        e2prom_s_cmd arg;
        unsigned char buf[0x18];

        fd = open(E2PROM_DEVICE, O_RDWR);
        if (fd  < 0) {
                printf("Device %s open error.\n", E2PROM_DEVICE);
                return -1;
        }
        arg.sub_addr_count      = 2;
        arg.data_count          = 0x18;
        arg.e2prom_cmd_sub_addr = 0x290;
        arg.e2prom_cmd_data     = buf;
        ret = ioctl(fd, E2PROM_CMD_READ, &arg);
        if (ret != 0) {
                printf("Device %s read error.\n", E2PROM_DEVICE);
                return -1;
        }
        memcpy(mac, buf, 6);
        memcpy(stbid, &buf[6], 18);
        stbid[18] = '\0';

        return 0;
}

static int writeparam(unsigned char *mac, unsigned char *stbid)
{
        int fd, ret;
        e2prom_s_cmd arg;
        unsigned char buf[0x18];

        memcpy(buf, mac, 6);
        memcpy(&buf[6], stbid, 18);
        fd = open(E2PROM_DEVICE, O_RDWR);
        if (fd  < 0) {
                printf("Device %s open error.\n", E2PROM_DEVICE);
                return -1;
        }
        arg.sub_addr_count      = 2;
        arg.data_count          = 0x18;
        arg.e2prom_cmd_sub_addr = 0x290;
        arg.e2prom_cmd_data     = buf;
        ret = ioctl(fd, E2PROM_CMD_WRITE, &arg);
        if (ret != 0) {
                printf("Device %s write error.\n", E2PROM_DEVICE);
                return -1;
        }

        return 0;
}

int main()
{
        char c;
        int i, macs[6];
        unsigned char mac[6];
        unsigned char stbid[256];

        if (readparam(mac, stbid) < 0)
                return 1;

        printf("Current parameters: \n");
        printf("  MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
        printf("  STBID: %s\n", stbid);
        
        printf("\nPlease input new MAC (1a:2b:3c:4d:5e:6f): ");
        if (scanf("%02x:%02x:%02x:%02x:%02x:%02x", &macs[0], &macs[1], &macs[2], &macs[3], &macs[4], &macs[5]) != 6) {
                 printf("Input MAC error\n");
                 return 1;
        }
        for (i=0; i<6; i++)mac = macs;
        printf("\nPlease input new STBID: ");
        scanf("%s", stbid);
        if (strlen(stbid) != 18) {
                printf("Invalid stbid\n");
                return 1;
        }
        printf("\nNew parameters: \n");
        printf("  MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
        printf("  STBID: %s\n", stbid);

        printf("\nDo you want to change paramemters? (y/N) ");
        for (;;) {
                c = getchar();
                if (c == 'y' || c == 'Y')
                        break;
                if (c == 'n' || c == 'N') {
                        printf("\nAborted.\n");
                        return 1;
                }
        }
        if (writeparam(mac, stbid) == 0)
                printf("Parameters changed.\n");

        return 0;
}


2017-4-5 11:16:46
使用小米电视的路过
2017-4-14 01:38:49
使用小米电视的路过
2017-4-24 23:52:36
看了4K已经回不去1080p的感觉了
2017-4-27 13:22:18
4K电影时代早点来临吧
2017-4-28 09:22:41
感谢楼主分享
2017-5-1 19:48:00
真是难得给力的资源啊。
2017-5-5 15:57:30
用索尼电视的露个脸
2017-5-28 22:57:00
我家索尼大法是时候体验体验4K大片了
2017-5-30 02:12:44
下半年各种网络机顶盒新品开始多起来了
您需要登录后才可以回帖 登录 | 注册
当贝4K投影