65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
|
|
#define VIDPID_PATH "/opt/camtprd-ffs.sh"
|
|
|
|
/*
|
|
* FunctionName: main
|
|
* Description:
|
|
*/
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int ret = 0;
|
|
printf("argc = %d \n", argc);
|
|
if (argc != 3)
|
|
{
|
|
return -1;
|
|
}
|
|
unsigned int i_vid = atoi(argv[1]);
|
|
unsigned int i_pid = atoi(argv[2]);
|
|
printf("arg0 = %d arg1=%d \n", i_vid, i_pid);
|
|
char buf_vid[5] ={0};
|
|
char buf_pid[5] ={0};
|
|
buf_vid[4]='\0';
|
|
buf_pid[4]='\0';
|
|
sprintf(buf_vid,"%04x",i_vid);
|
|
sprintf(buf_pid,"%04x",i_pid);
|
|
printf("buf_vid = %s buf_pid=%s \n", buf_vid, buf_pid);
|
|
if (i_pid > 0 && i_vid > 0)
|
|
{
|
|
FILE *fd;
|
|
|
|
fd = fopen(VIDPID_PATH, "rb+");
|
|
if (!fd) {
|
|
printf( "error open /usr/local/bin/mtp.sh...\n");
|
|
return -1;
|
|
}
|
|
else {
|
|
printf( "open %s scuess.fd = %d\n", VIDPID_PATH,fd);
|
|
}
|
|
|
|
/*set vid*/
|
|
fseek(fd , 0x1cb , SEEK_SET);
|
|
ret = fwrite(buf_vid, 1, 4, fd);
|
|
|
|
/*set pid*/
|
|
fseek(fd , 0x1b3 , SEEK_SET);
|
|
ret = fwrite(buf_pid, 1, 4, fd);
|
|
|
|
fclose(fd);
|
|
return 0;
|
|
}
|
|
|
|
return -1;
|
|
} /* ---------- end of function main ---------- */
|