|
From: Logie U. <the...@us...> - 2005-11-25 18:10:38
|
Update of /cvsroot/nbftools/CellTrack/CellTrackPPC/NiceRIL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6997/CellTrackPPC/NiceRIL Added Files: NiceRIL.cpp NiceRIL.h NiceRIL.vcp NiceRIL.vcw ReadMe.txt StdAfx.cpp StdAfx.h Log Message: Adding structure for CellTrack for the PPC :D --- NEW FILE: NiceRIL.vcp --- # Microsoft eMbedded Visual Tools Project File - Name="NiceRIL" - Package Owner=<4> # Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02 # ** DO NOT EDIT ** # TARGTYPE "Win32 (WCE MIPSIV) Dynamic-Link Library" 0x9602 # TARGTYPE "Win32 (WCE ARMV4T) Dynamic-Link Library" 0xa402 # TARGTYPE "Win32 (WCE MIPSIV_FP) Dynamic-Link Library" 0x9202 # TARGTYPE "Win32 (WCE SH3) Dynamic-Link Library" 0x8102 # TARGTYPE "Win32 (WCE MIPSII_FP) Dynamic-Link Library" 0xa202 # TARGTYPE "Win32 (WCE x86) Dynamic-Link Library" 0x8302 # TARGTYPE "Win32 (WCE emulator) Dynamic-Link Library" 0xa602 # TARGTYPE "Win32 (WCE SH4) Dynamic-Link Library" 0x8602 # TARGTYPE "Win32 (WCE ARMV4) Dynamic-Link Library" 0xa302 # TARGTYPE "Win32 (WCE MIPS16) Dynamic-Link Library" 0x8902 # TARGTYPE "Win32 (WCE ARMV4I) Dynamic-Link Library" 0xa502 # TARGTYPE "Win32 (WCE MIPSII) Dynamic-Link Library" 0xa102 CFG=NiceRIL - Win32 (WCE MIPSII_FP) Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, [...1195 lines suppressed...] # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\NiceRIL.h # End Source File # Begin Source File SOURCE=.\StdAfx.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\ReadMe.txt # End Source File # End Target # End Project --- NEW FILE: NiceRIL.vcw --- Microsoft eMbedded Visual Tools Workspace File, Format Version 4.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "NiceRIL"=".\NiceRIL.vcp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### --- NEW FILE: NiceRIL.cpp --- // NiceRIL.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include "NiceRIL.h" #include <string.h> extern "C" NICERIL_API char* GetCREG( char * comPort ); extern "C" NICERIL_API char* GetCSQ( char * comPort ); extern "C" NICERIL_API char* fnNiceRIL(void); BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } // This is an example of an exported variable NICERIL_API int nNiceRIL=0; // This is an example of an exported function. NICERIL_API char* fnNiceRIL(void) { return "Helloworld"; } NICERIL_API char* GetCREG( char * comPort ) { HANDLE hCom; int bufpos; DCB dcb; COMMTIMEOUTS to; DWORD nWritten; DWORD event; DWORD nRead; static char outbuf[20], buf[256]; BYTE comdevcmd[2]= {0x84, 0x00}; hCom= CreateFile( L"COM2:" ,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0); if (hCom==NULL || hCom==INVALID_HANDLE_VALUE) { hCom= NULL; return ""; } if (!GetCommState(hCom, &dcb)) { return "ERROR:GetCommState Failed"; } dcb.BaudRate= CBR_115200; dcb.ByteSize= 8; dcb.fParity= false; dcb.StopBits= ONESTOPBIT; if (!SetCommState(hCom, &dcb)) { return "ERROR:SetCommState Failed"; } EscapeCommFunction(hCom, SETDTR); EscapeCommFunction(hCom, SETRTS); GetCommTimeouts(hCom, &to); //if (!EscapeCommFunction(hCom, SETDTR)) //{ // return "-4"; //} //if (!EscapeCommFunction(hCom, SETRTS)) //{ // return "-5"; //} //if (!GetCommTimeouts(hCom, &to)) //{ // return "-6"; //} to.ReadIntervalTimeout= 0; to.ReadTotalTimeoutConstant= 200; to.ReadTotalTimeoutMultiplier= 0; to.WriteTotalTimeoutConstant= 20000; to.WriteTotalTimeoutMultiplier= 0; SetCommTimeouts(hCom, &to); //if (!SetCommTimeouts(hCom, &to)) //{ // return "-7"; //} if (!SetCommMask(hCom, EV_RXCHAR)) { return "-8"; } DWORD rildevresult=0,nReturned=0; if (!DeviceIoControl (hCom,0xAAAA5679L, comdevcmd, sizeof(comdevcmd),0,0,0,0)) { return "-9"; } bufpos = 0; strcpy(outbuf,"AT+creg=2\r"); if (!WriteFile(hCom, outbuf, 10, &nWritten, NULL)) { return "-10"; } if (nWritten != 10) { return "-11"; } if (!WaitCommEvent(hCom, &event, NULL)) { return "-12"; } while(1) { if (!ReadFile(hCom, buf+bufpos, 256 - bufpos, &nRead, NULL)) { return "-13"; } if (nRead == 0) break; bufpos += nRead; if (bufpos >= 256) break; } strcpy(outbuf,"AT+creg?\r"); if (!WriteFile(hCom, outbuf, 9, &nWritten, NULL)) { return "-14"; } if (nWritten != 9) { return "-15"; } if (!WaitCommEvent(hCom, &event, NULL)) { return "-16"; } while(1) { if (!ReadFile(hCom, buf+bufpos, 256 - bufpos, &nRead, NULL)) { return "-17"; } if (nRead == 0) break; bufpos += nRead; if (bufpos >= 256) break; } puts(buf); rildevresult = 0; if (!EscapeCommFunction(hCom, CLRDTR)) { return "-4"; } if (hCom!=NULL) { CloseHandle(hCom); hCom= NULL; } char* cregResponse = strpbrk( buf, "CREG\0" ); return cregResponse; } NICERIL_API char* GetCSQ( char * comPort ) { HANDLE hCom; int bufpos; DCB dcb; COMMTIMEOUTS to; DWORD nWritten; DWORD event; DWORD nRead; static char outbuf[20], buf[256]; BYTE comdevcmd[2]= {0x84, 0x00}; hCom= CreateFile( L"COM2:" ,GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0); if (hCom==NULL || hCom==INVALID_HANDLE_VALUE) { hCom= NULL; return ""; } if (!GetCommState(hCom, &dcb)) { return "ERROR:GetCommState Failed"; } dcb.BaudRate= CBR_115200; dcb.ByteSize= 8; dcb.fParity= false; dcb.StopBits= ONESTOPBIT; if (!SetCommState(hCom, &dcb)) { return "ERROR:SetCommState Failed"; } EscapeCommFunction(hCom, SETDTR); EscapeCommFunction(hCom, SETRTS); GetCommTimeouts(hCom, &to); to.ReadIntervalTimeout= 0; to.ReadTotalTimeoutConstant= 200; to.ReadTotalTimeoutMultiplier= 0; to.WriteTotalTimeoutConstant= 20000; to.WriteTotalTimeoutMultiplier= 0; SetCommTimeouts(hCom, &to); if (!SetCommMask(hCom, EV_RXCHAR)) { return "-8"; } DWORD rildevresult=0,nReturned=0; if (!DeviceIoControl (hCom,0xAAAA5679L, comdevcmd, sizeof(comdevcmd),0,0,0,0)) { return "-9"; } bufpos = 0; strcpy(outbuf,"AT+CSQ\r"); if (!WriteFile(hCom, outbuf, 9, &nWritten, NULL)) { return "-14"; } if (nWritten != 9) { return "-15"; } if (!WaitCommEvent(hCom, &event, NULL)) { return "-16"; } while(1) { if (!ReadFile(hCom, buf+bufpos, 256 - bufpos, &nRead, NULL)) { return "-17"; } if (nRead == 0) break; bufpos += nRead; if (bufpos >= 256) break; } puts(buf); rildevresult = 0; if (!EscapeCommFunction(hCom, CLRDTR)) { return "-4"; } if (hCom!=NULL) { CloseHandle(hCom); hCom= NULL; } char* csqResponse = strpbrk( buf, "CSQ\0" ); return csqResponse; } // This is the constructor of a class that has been exported. // see NiceRIL.h for the class definition CNiceRIL::CNiceRIL() { return; } --- NEW FILE: StdAfx.h --- // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__D8D632BB_149C_4BDA_B20F_5843C2840DA4__INCLUDED_) #define AFX_STDAFX_H__D8D632BB_149C_4BDA_B20F_5843C2840DA4__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Insert your headers here #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <windows.h> // TODO: reference additional headers your program requires here //{{AFX_INSERT_LOCATION}} // Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__D8D632BB_149C_4BDA_B20F_5843C2840DA4__INCLUDED_) --- NEW FILE: StdAfx.cpp --- // stdafx.cpp : source file that includes just the standard includes // NiceRIL.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file --- NEW FILE: ReadMe.txt --- ======================================================================== DYNAMIC LINK LIBRARY for Windows CE: NiceRIL ======================================================================== AppWizard has created this NiceRIL DLL for you. This file contains a summary of what you will find in each of the files that make up your NiceRIL application. NiceRIL.vcp This file (the project file) contains information at the project level and is used to build a single project or subproject. Other users can share the project (.vcp) file, but they should export the makefiles locally. NiceRIL.cpp This is the main DLL source file. NiceRIL.h This file contains your DLL exports. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named NiceRIL.pch and a precompiled types file named StdAfx.obj. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" to indicate parts of the source code you should add to or customize. ///////////////////////////////////////////////////////////////////////////// --- NEW FILE: NiceRIL.h --- // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the NICERIL_EXPORTS // symbol defined on the command line. this symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see // NICERIL_API functions as being imported from a DLL, wheras this DLL sees symbols // defined with this macro as being exported. #ifdef NICERIL_EXPORTS #define NICERIL_API __declspec(dllexport) #else #define NICERIL_API __declspec(dllimport) #endif // This class is exported from the NiceRIL.dll class NICERIL_API CNiceRIL { public: CNiceRIL(void); // TODO: add your methods here. }; extern NICERIL_API int nNiceRIL; |