Now I would like to create a simple standalone binary-app to be executed directly from telnet. I don't want to execute it from GAME menu.
My application is going to send HDMI1 command to switch TV's source and terminate.
BTW: is it possible anyway?
But I have one big problem, so maybe you could help me...
Please take a look:
This is my source code (remo.c):
Code: Select all
#include <stdio.h>
#include <dlfcn.h>
int main()
{
unsigned *handle=NULL;
if ( (handle = dlopen(NULL,RTLD_LAZY | RTLD_GLOBAL)) == NULL )
{
printf("Cannot open self!\n");
printf(dlerror());
printf("\n");
return 1;
}
// just for test we have proper instance
unsigned *KeyInputBase_SendKey = dlsym(handle,"_ZN14SsKeyInputBase7SendKeyEi");
unsigned *pKeyInputBase = dlsym(handle,"_ZN8SsObject14m_poObjectListE");
if(pKeyInputBase == NULL)
{
printf("Cannot find function!\n");
printf(dlerror());
printf("\n");
return 1;
}
if(KeyInputBase_SendKey == NULL )
{
printf("Cannot find _ZN14SsKeyInputBase7SendKeyEi functions\n");
printf(dlerror());
printf("\n");
return 1;
}
dlclose(handle);
unsigned *pInstance = (unsigned *)(pKeyInputBase[2]);
pKeyInputBase = (unsigned *)(*pInstance);
if (pKeyInputBase[6] != (unsigned)KeyInputBase_SendKey)
{
printf("Bad instance?! Should be SsKeyInputBase..\n");
return 1;
}
int key = 0xe9; // HDMI1 select key
asm volatile(
"MOV R0,%0\n"
"MOV R1,%1\n"
// problem is here:
"BL _ZN14SsKeyInputBase7SendKeyEi\n"
: // no output registers
: "r" (pInstance), "r" (key) );
printf("Does it work?\n");
return 0;
}
Code: Select all
[user@fedora src]$ arm-SamyGO-linux-gnueabi-gcc -ldl remo.c -o hdmi.bin
/tmp/ccN4Z5nT.o: In function `main':
remo.c:(.text+0x164): undefined reference to `SsKeyInputBase::SendKey(int)'
collect2: ld returned 1 exit status
[user@fedora src]$
The environment has been prepared in FC12 linux using this manual.
Note, that I am a novice with linux programming and GCC. So, what's up?
EDIT: I also tried to create a loader with dynamically-loaded so module. But at execution time it says: "Cannot find function!". So I'd like to know how to obtain SendKey() function address in my app. I think I have to obtain exeDSP's instance somehow for my app to get this function. Any ideas? Or maybe it is not so easy?