Ejemplo n.º 1
0
//**public command*****************************************
int ReadTermID(unsigned char *IDBuf,BOOL bLinked,char *ComStr,int BaudRate)
{
	int retCode,Len;

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe1;

	if(!bLinked)
	{
		if(Init_SetParam(ComStr,Dll_MacNo,BaudRate) < 0)
			return(-1);
	}

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe1;
	retCode = ExeCommand(IDBuf,0);
	if(retCode<0)
	{
		if(!bLinked)
			CloseComHandle();
		return retCode;
	}

	if(!bLinked)
		CloseComHandle();
	Len = Dll_RetData[3];
	memcpy(IDBuf,Dll_RetData+4,Len);
	Dll_MacNo = Dll_RetData[Len+3];
	return Dll_MacNo;
}
Ejemplo n.º 2
0
//**public command*****************************************
int QueryTermID(unsigned char LowIDNo,unsigned char *Buffer,BOOL bLinked,char *ComStr,int BaudRate)
{
	int retCode,Len;

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe2;

	if(!bLinked)
	{
		if(Init_SetParam(ComStr,Dll_MacNo,BaudRate) < 0)
			return(-1);
	}

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe2;
	Buffer[0] = LowIDNo;
	retCode = ExeCommand(Buffer,1);
	if(retCode<0)
	{
		if(!bLinked)
			CloseComHandle();
		return retCode;
	}

	if(!bLinked)
		CloseComHandle();
	Len = Dll_RetData[3];

	memcpy(Buffer,Dll_RetData+4,Len);

	Dll_MacNo = Dll_RetData[8];
	return Dll_MacNo;
}
Ejemplo n.º 3
0
//4、写卡片
int _stdcall SMT_WriteBlock(int Sector,int BlockNo,unsigned char *BlockBuf)
{
	unsigned char Buf[20];
	int retCode,i,Len;

	
	Dll_CommByte = 0x2D; 
	Len = 16;
	memset(Buf,0,20);
	Buf[0] = Sector;
	Buf[1] = BlockNo;

	for(i = 0;i < Len;i++)
		Buf[2+i] = BlockBuf[i];

	retCode = ExeCommand(Buf,Len+2);
	if(retCode<0)
		return retCode;

	Len = Dll_RetData[3];
	
	for(i = 0;i<Len;i++)
		BlockBuf[i] = Dll_RetData[i+4];
	return retCode;

}
Ejemplo n.º 4
0
//5、加钱
int _stdcall SMT_Philips_Packet_Proc(int flag,int Sector,int BlockNo,int Money,unsigned char *BlockBuf)
//flag:加减钱标志 0---加 1---减
{
	unsigned char Buf[20];
	int retCode,Len;

	if(flag == 0)
		Dll_CommByte = 0x2e; 
	else
		Dll_CommByte = 0x2f;
	Len = 6;
	memset(Buf,0,20);
	Buf[0] = Sector;
	Buf[1] = BlockNo;
	Buf[2] = Money%256;
	Buf[3] = Money/256;
	Buf[4] = Money/256/256;
	Buf[5] = Money/256/256/256;
	
	retCode = ExeCommand(Buf,Len);
	if(retCode<0)
		return retCode;

	Len = Dll_RetData[3];
	for(int i = 0;i<Len;i++)
		BlockBuf[i] = Dll_RetData[i+4];
	return retCode;
}
Ejemplo n.º 5
0
//2、登陆卡片 
int _stdcall SMT_Login_With_UserKey(int Sector,unsigned char *Buffer,int PaDSelect)
// Sector 扇区号
// PaDSelect == 0 KEYA 登陆
// PaDSelect == 1 KEYB 登陆
// Buffer -----KEYA或KEYB

{
	int retCode,Len;
	
	unsigned char Buffer_temp[20];
	memset(Buffer_temp,0,20);

	Dll_CommByte = 16;  
	
	Buffer_temp[0] = Sector;
	if(PaDSelect == 0)
	{
		Buffer_temp[1] = 0x02;//AKEY登录
		memcpy(Buffer_temp+2,Buffer,6);
	}
	else
	{
		Buffer_temp[1] = 0x42;//BKEY登录
		memcpy(Buffer_temp+2+6,Buffer,6);
	}
	Len = 14;
	retCode = ExeCommand(Buffer_temp,Len);
	return retCode;
}
Ejemplo n.º 6
0
//**public command*****************************************
int ReadTermDate(unsigned char *Buffer,BOOL bLinked,char *ComStr,int BaudRate)
{
	int retCode,Len;

	if(!bLinked)
	{
	// 初始化串口
		Dll_MacNo = 0xff;
		if(Init_SetParam(ComStr,Dll_MacNo,BaudRate) < 0)
			return(-1);
	}

	Dll_CommByte = 0xe5;
	retCode = ExeCommand(Buffer,0);
	if(retCode<0)
	{
		if(!bLinked)
			CloseComHandle();
		return retCode;
	}

	if(!bLinked)
		CloseComHandle();
	Len = Dll_RetData[3];
	memcpy(Buffer,Dll_RetData+4,Len);
	return Len;
}
void CTestCreateProcessDlg::OnBnClickedButton3()
{
	TCHAR cCurrentDir[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, cCurrentDir);
	_tcscat(cCurrentDir, ADB_PROC_NAME);

	CString cmdline = CMD_ADB_DEVICES;//(cCurrentDir);// = _T("")
	DWORD dExit=0;
	CString strRet;
	ExeCommand(cmdline, dExit, strRet);
	CString tet;
}
Ejemplo n.º 8
0
//7 休眠卡片
int _stdcall SMT_SleepCard()
{
	unsigned char Buf[20];
	int retCode,Len;

	Dll_CommByte = 0x08; 
	Len = 0;
	memset(Buf,0,20);
	
	retCode = ExeCommand(Buf,Len);
	return retCode;
}
Ejemplo n.º 9
0
//3、读写器蜂鸣器控制
int _stdcall SMT_ControlBuzzer()
{
	int retCode;
	BYTE Buffer[1];

	Dll_CommByte = 59;

	Buffer[0]=NULL;
	retCode = ExeCommand(Buffer,0);
	if(retCode<0)
		return retCode;
	return 0;
}
Ejemplo n.º 10
0
//---------------------------------------------------------------------------
//执行命令,由服务自己选择是否执行脚本。
//---------------------------------------------------------------------------
void __fastcall ASEditSvr::DoCommand(PCCommand *aCommand,PCResult *aResult)
{
  try
  {
    fResult  = aResult;
    fCommand = aCommand;
    ExeCommand();
  }
  __finally
  {
    fResult  = NULL;
    fCommand = NULL;
  }
}
Ejemplo n.º 11
0
//3、读卡片
int _stdcall SMT_ReadBlock(int Sector,int BlockNo, unsigned char *BlockBuf)
{
	int retCode,i,Len;
	BlockBuf[0] = Sector;
	BlockBuf[1] = BlockNo;
	Len = 2;
	Dll_CommByte = 0x2C;  
	retCode = ExeCommand(BlockBuf,Len);
	if(retCode<0)
		return retCode;

	Len = Dll_RetData[3];
	for(i = 0;i<Len;i++)
		BlockBuf[i] = Dll_RetData[i+4];
	return retCode;
}
Ejemplo n.º 12
0
PDMBUILDER_API string checkout(string workspace)
{
	SourceCode *sourceCode = getSourceCode();

	char ExportCmd[500];
	memset(ExportCmd,0,sizeof(ExportCmd));

	string url  = sourceCode->GetUrl();
	string log("<---------------------------checkout--------------------------->\nCheckout: ");
	log.append(url).append("\n");
	//string fullpath(workspace+"\\"+sourceCode->GetLocalPath());
	string fullpath = sourceCode->GetLocalPath();
	fullpath = changeSeparator(fullpath);

	if(sourceCode->GetVersion() == "head"){
		sprintf(ExportCmd, "svn checkout --force --non-interactive --username %s --password %s %s \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetUrl().c_str(), fullpath.c_str());
	}else{
		sprintf(ExportCmd, "svn checkout -r %s --force  --non-interactive --username %s --password %s %s \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetVersion().c_str(),sourceCode->GetUrl().c_str(),fullpath.c_str());
	}

	int exitCode = 0;
	log += ExeCommand(ExportCmd,exitCode,(char *)workspace.c_str());
	if (exitCode>0&&exitCode!=STILL_ACTIVE)
	{
		return log +"\nerror";
	}
	int errorindex = log.find("svn: E");
	if (errorindex!=string::npos)
	{
		return log +"\nerror";
	}
	if ("head" == sourceCode->GetVersion())
	{
		//int length = log.length();
		int index = log.rfind("Checked out revision");
		if(index!=string::npos){
			int in = log.rfind(".");
			index += 21;
			sourceVersion = log.substr(index,in-index);
		}
	}else{
		sourceVersion = sourceCode->GetVersion();
	}
	delete sourceCode;
	
	return log;
}
Ejemplo n.º 13
0
//*******************************************
int _stdcall MF_ReadSeriesNo(unsigned char *Buffer)                    // 这里修改过_stdcall
{
	int retCode,Len;

	Dll_CommByte = 1;
	Len = 0;
	retCode = ExeCommand(Buffer,Len);
	if(retCode<0)
		return retCode;

	Len = Dll_RetData[3];
	memcpy(Buffer,Dll_RetData+4,Len);
//	Buffer[Len] = NULL;
	if (Len == 0)
	{
		return -1;
	}
	return Len;
}
Ejemplo n.º 14
0
//6 数据块COPY
int _stdcall SMT_Copy_DataBlock(int Sector,int souBlock,int desBlock,unsigned char *BlockBuf)
{
	unsigned char Buf[20];
	int i,retCode,Len;

	Dll_CommByte = 0x30; 
	Len = 3;
	memset(Buf,0,20);
	Buf[0] = Sector;
	Buf[1] = souBlock;
	Buf[2] = desBlock;
	
	retCode = ExeCommand(Buf,Len);
	if(retCode<0)
		return retCode;

	Len = Dll_RetData[3];
	for(i = 0;i<Len;i++)
		BlockBuf[i] = Dll_RetData[i+4];
	return retCode;
}
Ejemplo n.º 15
0
//**public command*****************************************
int SetTermMacNo(unsigned char *IDBuf,int MacNo,BOOL bLinked,char *ComStr,int BaudRate)
{
	int retCode,Len;
	BYTE Buffer[8];

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe3;

	if((MacNo>255)||(MacNo<1))
	{
		ErrorCode = 31;
		return (-1);
	}
	if(!bLinked)
	{
		if(Init_SetParam(ComStr,Dll_MacNo,BaudRate) < 0)
			return(-1);
	}

	Dll_MacNo = 0xff;
	Dll_CommByte = 0xe3;

	Len = 4;
	memcpy(Buffer,IDBuf,4);
	Buffer[4] = MacNo;

	retCode = ExeCommand(Buffer,5);
	if(retCode<0)
	{
		if(!bLinked)
			CloseComHandle();
		return retCode;
	}

	if(!bLinked)
		CloseComHandle();
	Dll_MacNo = MacNo;
	return Dll_MacNo;
}
Ejemplo n.º 16
0
string RunBuildStep(string name,string program,string options,int &exitCode)
{
	char BuildCmd[255];
	memset(BuildCmd,0,255);
	program = changeSeparator(program);
	//options = changeSeparator(options);
	/*
	int index = options.find_last_of(' ');
	if (index>0)
	{
		string solution = options.substr(index+1);
		string argument = options.substr(0,index);
		string fullpath(workspace+"\\"+solution);
		fullpath = changeSeparator(fullpath);
		sprintf(BuildCmd, "%s %s %s",program.c_str(),argument.c_str(),fullpath.c_str());
	}
	else
	{
		string fullpath = workspace + "\\" +options;
		fullpath = changeSeparator(fullpath);
		sprintf(BuildCmd, "%s %s",program.c_str(),fullpath.c_str());
	}
	*/
	
	sprintf(BuildCmd,"\"%s\" %s",program.c_str(),options.c_str());
	//writeLog(BuildCmd,workspace+"\\log");
	//string str = "str test";
	//writeLog(str,workspace+"\\log");
	string log="---------------------------";
	//writeLog(log,workspace+"\\log");
	log.append(name);
	log.append("--------------------------->\n");
	
	//writeLog(log,workspace+"\\log");
	log += ExeCommand(BuildCmd,exitCode,(char *)workspace.c_str());
	writeLog(log,workspace+"\\log");
	return log;
}
Ejemplo n.º 17
0
PDMBUILDER_API bool checkSourceCode()
{
	SourceCode *sourceCode = getSourceCode();

	//string url = sourceCode->GetUrl();
	
	string fullpath(workspace+"\\"+sourceCode->GetLocalPath());
	//string fullpath = sourceCode->GetLocalPath();
	string log ;
	fullpath = changeSeparator(fullpath);
	string svnPath(fullpath+"\\.svn");
	if (!PathFileExists(svnPath.c_str()))
	{
		//printf("to checkout");
		log += checkout(workspace);
		
		//printf("svn checkout\n");
		int accessInt = log.find("Access to");
		if (accessInt!=string::npos)
		{
			if (log.find("forbidden")!=string::npos)
			{
				string nextNumFile(fullpath+"\\nextBuildNumber");
				if (!PathFileExists(nextNumFile.c_str()))
				{
					writeLog(log,workspace+"\\log");
					delete sourceCode;
					return true;
				}
				if (forceFlag!="false")
				{
					writeLog(log,workspace+"\\log");
				}
				delete sourceCode;
				return false;
			}
		}
		int errorint = log.find("error");
		if (errorint!=string::npos&&errorint==log.length()-5)
		{
			writeLog(log,workspace+"\\log");
			delete sourceCode;
			return false;
		}
		writeLog(log,workspace+"\\log");
		//writeLog(log,workspace+"\\log");
		delete sourceCode;
		return true;
	}

	char updateCmd[500];
	memset(updateCmd,0,sizeof(updateCmd));

	sprintf(updateCmd,"svn update --force --non-interactive --username %s --password %s --accept tf \"%s\"",buildName.c_str(),buildPassword.c_str(),sourceCode->GetLocalPath().c_str());
	//printf("to update");
	int exitCode = 0;
	log.assign("<---------------------------checkout--------------------------->\n ");
	log += ExeCommand(updateCmd,exitCode,(char *)workspace.c_str());
	//printf("svn update\n");
	if (exitCode>0&&exitCode!=STILL_ACTIVE)
	{
		log += "update source code error";
		if (forceFlag!="false")
		{
			writeLog(log,workspace+"\\log");
		}
		delete sourceCode;
		return false;
	}else if (log.find("svn cleanup")!=string::npos)
	{
		char cleanupCmd[100];
		memset(cleanupCmd,0,sizeof(cleanupCmd));
		sprintf(cleanupCmd,"svn cleanup");
		ExeCommand(cleanupCmd,exitCode,(char *)workspace.c_str());

		log = ExeCommand(updateCmd,exitCode,(char *)workspace.c_str());
		if (exitCode>0&&exitCode!=STILL_ACTIVE)
		{
			log += "update source code error";
			if (forceFlag!="false")
			{
				writeLog(log,workspace+"\\log");
			}
			delete sourceCode;
			return false;
		}
	}
	int index = log.find("Updated to revision");
	
	if (index>0)
	{
		index += 20;
		int in = log.find_last_of(".");
		sourceVersion = log.substr(index,in-index);
		
		writeLog(log,workspace+"\\log");
		delete sourceCode;
		return true;
	}else
	{
		int rindex = log.rfind("At revision");
		if (rindex!=string::npos)
		{
			int lindex = log.rfind(".");
			rindex += 12;
			sourceVersion = log.substr(rindex,lindex-rindex);
		}
		if (forceFlag!="false")
		{
			writeLog(log,workspace+"\\log");
		}
		
		delete sourceCode;
		return false;
	}
}