Hello!
Please, can you show me a sample code of the simple DLL for PDA? I don't realy sure that I write function implementation in correct place...
Here is my code, can you tell me were is my mistake?
myHeader.h
Code:
#ifdef MYDLL_IMPLEMENTATION
#define DLLEXPORT _declspec(dllexport)
#else
#define DLLEXPORT _declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int _cdecl Get54();
#ifdef __cplusplus
}
#endif
cppDll.cpp
Code:
// CppDll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "CppDll.h"
#include "myHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MYDLL_IMPLEMENTATION
//
// Note!
// .......
//
/////////////////////////////////////////////////////////////////////////////
// CCppDllApp
BEGIN_MESSAGE_MAP(CCppDllApp, CWinApp)
//{{AFX_MSG_MAP(CCppDllApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCppDllApp construction
CCppDllApp::CCppDllApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCppDllApp object
CCppDllApp theApp;
int _cdecl Get54()
{
return 54;
}
I've been working on FFOS for Xperia SP for about 2 months now. Recently i swapped to using AOSP sources for Xperia SP , however this is the error that i get https://gist.github.com/smb237u/8bd6a180eaa464783cee
My sources are here : https://github.com/smb237u/repo-manifests/blob/dev/huashan.xml commit : 70eef1c5a647cc71e9e81a1ecba125c81e347ed5
Thanks!
I've solved that error already but stumbled upon another one :
host C: acp <= build/tools/acp/arch/x86/begin.c
build/tools/acp/arch/x86/begin.c:34:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/arch/x86/begin.o] Error 1
begin.c :
Code:
/*
* Copyright (C) 2012 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdint.h>
#include <sys/cdefs.h>
extern unsigned __linker_init(void* raw_args);
__LIBC_HIDDEN__ void _start() {
void (*start)(void);
void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
start = (void(*)(void))__linker_init(raw_args);
/* linker init returns (%eax) the _entry address in the main image */
/* entry point expects sp to point to raw_args */
__asm__ (
"mov %0, %%esp\n\t"
"jmp *%1\n\t"
: : "r"(raw_args), "r"(start) :
);
/* Unreachable */
}
/* Since linker has its own version of crtbegin (this file) it should have */
/* own version of __stack_chk_fail_local for the case when it's built with */
/* stack protector feature */
#include "arch-x86/bionic/__stack_chk_fail_local.h"
I have a Java Native Interface project that works. It is the helloJNI prototype. Now I want to use it to call the functions in the header file of a Device Driver. This DD is already in my image, and I see it in /dev folder. What I want to know if how do I call the device driver functions? Here is what I have in my JNI folder:
Code:
#include "com_example_sansari_usedevicedriver_MainActivity.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
/*
* Class: com_example_sansari_usedevicedriver_MainActivity
* Method: useqseecom
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_example_sansari_usedevicedriver_MainActivity_UseQUALCOM
(JNIEnv *env, jobject obj)
{
(*env)->NewStringUTF(env,"Hi From UseDeviceDriver");
}
Below is the executable I created to interface with the device driver from the user space. It works. I am trying to see how do I add the code below to the JNI handle I have above. Where does the main function of my executable below fit in the above file?
[/CODE]
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv)
{
/* Our file descriptor */
int fd;
int rc = 0;
char *rd_buf[16];
printf("<1>%s: entered\n", argv[0]);
/* Open the device */
fd = open("/dev/hello1", O_RDWR);
if ( fd == -1 ) {
perror("<1>open failed");
rc = fd;
exit(-1);
}
printf("<1>%s: open: successful\n", argv[0]);
/* Issue a read */
rc = read(fd, rd_buf, 0);
if ( rc == -1 ) {
perror("<1>read failed");
close(fd);
exit(-1);
}
printf("<1>%s: read: returning %d bytes!\n", argv[0], rc);
close(fd);
return 0;
}
[/CODE]
Updated with answer: (not sure how much of this is actually needed but it gets you playing with your own custom Android 6.01 Toolbox!)
Trying to compile toolbox.c for some odd reason? Or bionic? Or the libc libraries, all this section of code is super easy.
1. I downloaded the AOSP that matched the build number of the sources for my device
2. I download the sources for my device and merged them in as described in the text file. (basically replace don't merge)
3. I copied in my device specific hardware I found from the AP file of my firmware.
4. I follow instructions both on the AOSP site and on this forum to prepare my platform for building. (stole some settings from cyanogenmod real quick)
5. make modules <==== list of modules
6. make toolbox
words
https://android.googlesource.com/platform/system/core/+/master/toolbox
Here's the code that's stumping me (compiler can't find tools.h and neither can I) It seems to be created on the fly but how does it do it?
Code:
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define TOOL(name) int name##_main(int, char**);
#include "tools.h"
#undef TOOL
static struct {
const char* name;
int (*func)(int, char**);
} tools[] = {
#define TOOL(name) { #name, name##_main },
#include "tools.h"
#undef TOOL
{ 0, 0 },
};
Here's toolbox.c Google Source
https://android.googlesource.com/platform/system/core/+/master/toolbox/toolbox.c
My V20(US996) can't connect mobile cellular data. I use the V20 on CDMA EVDO Network.
The logcat is shown this log when connect mobile data network.
04-06 15:39:11.841 1552 1706 E RILQ : (0/1552): RIL[0][main] qcril_data_set_ril_profile_id: RIL provided [3] profile id. This is currently not supported
04-06 15:39:11.863 1552 1706 E RILQ : (0/1552): RIL[0][main] qcril_data_request_setup_data_call: unable to setup data call, index [0]
04-06 15:39:11.863 1552 1706 E RILQ : (0/1552): RIL[0][main] qcril_data_request_setup_data_call: qcril_data_request_setup_data_call: EXIT with FAILURE
What is mean?
How can I solve the problem?
Please give help everyone. Thanks. Have a nice day!
reference this for code ( 3)
Code:
ypedef enum {
RIL_E_SUCCESS = 0,
RIL_E_RADIO_NOT_AVAILABLE = 1, /* If radio did not start or is resetting */
RIL_E_GENERIC_FAILURE = 2,
RIL_E_PASSWORD_INCORRECT = 3, /* for PIN/PIN2 methods only! */
RIL_E_SIM_PIN2 = 4, /* Operation requires SIM PIN2 to be entered */
RIL_E_SIM_PUK2 = 5, /* Operation requires SIM PIN2 to be entered */
RIL_E_REQUEST_NOT_SUPPORTED = 6,
RIL_E_CANCELLED = 7,
RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice
call on a Class C GPRS device */
RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9, /* data ops are not allowed before device
registers in network */
RIL_E_SMS_SEND_FAIL_RETRY = 10, /* fail to send sms and need retry */
RIL_E_SIM_ABSENT = 11, /* fail to set the location where CDMA subscription
shall be retrieved because of SIM or RUIM
card absent */
RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12, /* fail to find CDMA subscription from specified
location */
RIL_E_MODE_NOT_SUPPORTED = 13, /* HW does not support preferred network type */
RIL_E_FDN_CHECK_FAILURE = 14, /* command failed because recipient is not on FDN list */
RIL_E_ILLEGAL_SIM_OR_ME = 15 /* network selection failed due to
illegal SIM or ME */
} RIL_Errno;
typedef enum {
RIL_CALL_ACTIVE = 0,
RIL_CALL_HOLDING = 1,
RIL_CALL_DIALING = 2, /* MO call only */
RIL_CALL_ALERTING = 3, /* MO call only */
RIL_CALL_INCOMING = 4, /* MT call only */
RIL_CALL_WAITING = 5 /* MT call only */
} RIL_CallState;
typedef enum {
RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */
RADIO_STATE_UNAVAILABLE = 1, /* Radio unavailable (eg, resetting or not booted) */
RADIO_STATE_SIM_NOT_READY = 2, /* Radio is on, but the SIM interface is not ready */
RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3, /* SIM PIN locked, PUK required, network
personalization locked, or SIM absent */
RADIO_STATE_SIM_READY = 4, /* Radio is on and SIM interface is available */
RADIO_STATE_RUIM_NOT_READY = 5, /* Radio is on, but the RUIM interface is not ready */
RADIO_STATE_RUIM_READY = 6, /* Radio is on and the RUIM interface is available */
RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7, /* RUIM PIN locked, PUK required, network
personalization locked, or RUIM absent */
RADIO_STATE_NV_NOT_READY = 8, /* Radio is on, but the NV interface is not available */
RADIO_STATE_NV_READY = 9 /* Radio is on and the NV interface is available */
} RIL_RadioState;
typedef enum {
RADIO_TECH_UNKNOWN = 0,
RADIO_TECH_GPRS = 1,
RADIO_TECH_EDGE = 2,
RADIO_TECH_UMTS = 3,
RADIO_TECH_IS95A = 4,
RADIO_TECH_IS95B = 5,
RADIO_TECH_1xRTT = 6,
RADIO_TECH_EVDO_0 = 7,
RADIO_TECH_EVDO_A = 8,
RADIO_TECH_HSDPA = 9,
RADIO_TECH_HSUPA = 10,
RADIO_TECH_HSPA = 11,
RADIO_TECH_EVDO_B = 12,
RADIO_TECH_EHRPD = 13,
RADIO_TECH_LTE = 14,
RADIO_TECH_HSPAP = 15 // HSPA+
} RIL_RadioTechnology;
// Do we want to split Data from Voice and the use
// RIL_RadioTechnology for get/setPreferredVoice/Data ?
typedef enum {
PREF_NET_TYPE_GSM_WCDMA = 0, /* GSM/WCDMA (WCDMA preferred) */
PREF_NET_TYPE_GSM_ONLY = 1, /* GSM only */
PREF_NET_TYPE_WCDMA = 2, /* WCDMA */
PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, /* GSM/WCDMA (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_EVDO_AUTO = 4, /* CDMA and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_ONLY = 5, /* CDMA only */
PREF_NET_TYPE_EVDO_ONLY = 6, /* EvDo only */
PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_LTE_CDMA_EVDO = 8, /* LTE, CDMA and EvDo */
PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */
PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */
PREF_NET_TYPE_LTE_ONLY = 11 /* LTE only */
} RIL_PreferredNetworkType;
/* Source for cdma subscription */
typedef enum {
CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0,
CDMA_SUBSCRIPTION_SOURCE_NV = 1
} RIL_CdmaSubscriptionSource;
/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */
typedef enum {
RIL_UUS_TYPE1_IMPLICIT = 0,
RIL_UUS_TYPE1_REQUIRED = 1,
RIL_UUS_TYPE1_NOT_REQUIRED = 2,
RIL_UUS_TYPE2_REQUIRED = 3,
RIL_UUS_TYPE2_NOT_REQUIRED = 4,
RIL_UUS_TYPE3_REQUIRED = 5,
RIL_UUS_TYPE3_NOT_REQUIRED = 6
} RIL_UUS_Type;
/* User-to-User Signaling Information data coding schemes. Possible values for
* Octet 3 (Protocol Discriminator field) in the UUIE. The values have been
* specified in section 10.5.4.25 of 3GPP TS 24.008 */
typedef enum {
RIL_UUS_DCS_USP = 0, /* User specified protocol */
RIL_UUS_DCS_OSIHLP = 1, /* OSI higher layer protocol */
RIL_UUS_DCS_X244 = 2, /* X.244 */
RIL_UUS_DCS_RMCF = 3, /* Reserved for system mangement
convergence function */
RIL_UUS_DCS_IA5c = 4 /* IA5 characters */
} RIL_UUS_DCS;
/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0
* This data is passed in RIL_ExtensionRecord and rec contains this
* structure when type is RIL_UUS_INFO_EXT_REC */
typedef struct {
RIL_UUS_Type uusType; /* UUS Type */
RIL_UUS_DCS uusDcs; /* UUS Data Coding Scheme */
int uusLength; /* Length of UUS Data */
char * uusData; /* UUS Data */
} RIL_UUS_Info;
/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */
typedef struct {
char isPresent; /* non-zero if signal information record is present */
char signalType; /* as defined 3.7.5.5-1 */
char alertPitch; /* as defined 3.7.5.5-2 */
char signal; /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */
} RIL_CDMA_SignalInfoRecord;