To log to a text file from a native daemon process, push the empty file beforehand to /data. Next check that the owner of the process and the location where you are writing are the same.
So I was adding my driver to the Linux kernel. Made a new Kconfig file and added 'menu' and 'endmenu' sections. But when I compiled the kernel I got an error saying 'endmenu in different file than menu'. Reason: There has to be a new line character after endmenu in your Kconfig file!
First go into the Android.mk file in your jni folder and add this line: LOCAL_CFLAGS += -g This is going to enable the debug compile option. You might have a separate option for logging more data. Next go into Application.mk and uncomment this line: APP_OPTIM := debug (or add it if it isnt there) This should be sufficient. Now when you run the ndk-build (You can run ndk-build V=1 to enable the verbose option), you should get the debuggable binaries. For some reason the binary I get in the libs/armeabi folder is not the debuggable one, this one has its debug options stripped out. To get the debug one grab it from obj/local/armeabi.
A very common issue we face is to convert an integer into a char pointer or array. This can be achieved using sprintf. int count = 600; unsigned char size[3]; sprintf(size, "%03d", count); Thats it! Here '%03' means that a minimum of 3 characters will be printed and if the number is smaller than that it will be left-padded with 0's.
Comments
Post a Comment