void isColorPickerDlg::textHexUpdated(wxCommandEvent& event)
{
	//Parse it
	wxString str = textHex->GetValue();
	if (str.Left(1)!="#") str = "#" + str;
	int r = StringToHex( str.Mid(1,2) );
	int g = StringToHex( str.Mid(3,2) );
	int b = StringToHex( str.Mid(5,2) );
	rSlider->SetValue(r); gSlider->SetValue(g); bSlider->SetValue(b);

	RefreshColor();
}
Exemple #2
0
int Pass2_LinkingLoader_T(char *record){
	int TRecordLength,i,currentLocInt;
	char *currentByte,currentLocString[10];
	value tmp1,tmp2;

	currentLocInt = StringToHex(copy(1,6,record)) + csaddress; // Modification location
	TRecordLength = StringToHex(copy(7,8,record)); // Trecord length

	tmp1.exist = 1; tmp2.exist=1;
	/* Receive a Byte and load it to memory */
	for(i=0 ; i<(TRecordLength) ; i++){
		currentByte = copy(2*i+9,2*i+10,record); 
		sprintf(currentLocString,"%X",currentLocInt+(i));
		strcpy(tmp1.value,currentLocString); strcpy(tmp2.value,currentByte);
		edit(&tmp1,&tmp2);
	}
	return 0;
}
BOOL
ParseNdasDeviceId(
	__in LPCTSTR Argument, 
	__out PNDAS_DEVICE_IDENTIFIER NdasDeviceIdentifier)
{
	LPCTSTR p = Argument;

	for (DWORD i = 0; i < 5; ++i)
	{
		if (NULL == *p || NULL == *(p+1)) return FALSE;
		BOOL success = StringToHex(p, &NdasDeviceIdentifier->Identifier[i]);
		if (!success) return FALSE;
		p += 2;
		if (_T(':') == *p || _T('-') == *p) ++p;
	}

	if (NULL == *p || NULL == *(p+1)) return FALSE;
	BOOL success = StringToHex(p, &NdasDeviceIdentifier->Identifier[5]);
	if (!success) return FALSE;
	p += 2;

	if (_T(':') == *p || _T('-') == *p)
	{
		++p;
		success = CharToHex(*p, &NdasDeviceIdentifier->UnitNumber);
		if (!success)
		{
			return FALSE;
		}
		++p;
	}
	else
	{
		NdasDeviceIdentifier->UnitNumber = 0;
	}

	if (NULL != *p)
	{
		// redundant characters
		return FALSE;
	}

	return TRUE;
}
Exemple #4
0
int Pass2_LinkingLoader_M(char *record, Linkedlist *RSymbol){
	
	int ModifyLocation,q,r,ModifyValueInt,sum,carry=0;
	char *ModifyValueString;
	char *externalSymbol;
	Linkedlist ex;

	ModifyLocation = StringToHex(copy(1,6,record)) + csaddress; // Modification location
	q=ModifyLocation/16;
	r=ModifyLocation%16;
	if((externalSymbol = getAddr(copy(10,11,record),*RSymbol)) == NULL){ // Get Symbol that fit in refenrence Number
			printf("%s / Undefined Reference Symbol\n",copy(10,11,record));
			return -1;
	}
	ex = external_table[MneToOp(externalSymbol)];
	if((ModifyValueString = getAddr(externalSymbol,ex)) == NULL){ //Get ADdr of Symbol using ESTAB
			printf("%s / Undefined External Symbol\n",externalSymbol);
			return -1;
	}
	ModifyValueInt = StringToHex(ModifyValueString);
	
	/* carry out Add, Sub using Carry bit and Borrow bit */
	if(record[9] == '+'){
		
		if(r+2>0xf){ r=(r+2)%16; q++;} 
		else{r+=2;}


		carry = addAndCarryCheck((int)memory[r][q],(ModifyValueInt & 0x000000FF),carry,&sum); // 5,6 bit
		memory[r][q] = sum;
		RExcess16(&q,&r);

		carry = addAndCarryCheck((int)memory[r][q],((ModifyValueInt >> 8) & 0x000000FF),carry,&sum); // 3,4 bit
		memory[r][q] = sum;
		RExcess16(&q,&r);

		if(!strcmp(copy(7,8,record),"05")){ // 1,2 bit
			carry = addAndCarryCheck((int)memory[r][q],((ModifyValueInt >> 16) & 0x0000000F),carry,&sum);
			memory[r][q] = sum;
		}
		else if(!strcmp(copy(7,8,record),"06")){
Exemple #5
0
int Pass2_LinkingLoader_H(char* record, int* length,Linkedlist *RSymbol){

	char *tmplength;
	
	listinit(RSymbol); // RSymbol :(Reference Number , Symbol)

	listinsert(RSymbol,copy(1,6,record)); // Rsymbol Name
	listinsertmore(RSymbol,"01"); // reference number

	tmplength = copy(13,18,record);
	*length = StringToHex(tmplength);

	return 0;
}
/**
  * @file   DWORD WINAPI DebugComRecThread(LPVOID lpParam)
  * @brief  调试串口接收线程
  * @param  lpParam [in] 
  * @retval TRUE
  */
DWORD WINAPI DebugComRecThread(LPVOID lpParam)
{
    UCHAR byGetData[64];
    DWORD dwGetDataLenght = 32;
    DWORD dwReadNumber = 0;
    CString m_CStr = _T("");

    CVct6VsDlg *pDlg = (CVct6VsDlg *)lpParam;
    hDebugComRecThreadEnd = CreateEvent(NULL, FALSE, FALSE, NULL);
    bDebugComRecThreadFlag = TRUE;
    while(bDebugComRecThreadFlag)
    {
        if(cDebugCom.hCom != INVALID_HANDLE_VALUE)
        {
            /*! 读串口 */
            if(cDebugCom.ComReadDate(cDebugCom.hCom, byGetData, dwGetDataLenght, &dwReadNumber, 0))
            {
                ulDebugComRecCnt += dwReadNumber; /*!< 接收计数 */
                CString strcnt;
                strcnt.Format(_T("%ld"), ulDebugComRecCnt);
                pDlg->m_DebugComRecCnt.SetWindowText(strcnt);
                /*! 将接收到的数据写入缓冲区 */
#if 0
                for(UCHAR i=0; i<dwReadNumber; i++)
                {
                    WriteBuf(byGetData[i]);
                }
#endif
                /*! 串口16进制显示 */
                byGetData[dwReadNumber] = '\0';
#if 0
                UCHAR aucHexStr[256] = {'\0'};
                StringToHex(aucHexStr, byGetData, dwReadNumber);
                m_CStr = aucHexStr;
#endif
                m_CStr = byGetData;
                int len = pDlg->m_DisDebugComRec.GetWindowTextLength();
                pDlg->m_DisDebugComRec.SetSel(len, len); /*!< 将插入光标放在最后 */
                pDlg->m_DisDebugComRec.ReplaceSel(m_CStr);
                pDlg->m_DisDebugComRec.ScrollWindow(0, 0);/*!< 滚动到插入点 */
            }
        }
        Sleep(1);
    }
    /*! 接收进程结束 */
    SetEvent(hDebugComRecThreadEnd);
    return TRUE;
}
int main(int argc, char **argv)
{
    if (argc > 1) {
        char Message[MAXLEN];
        FILE *infile = fopen(argv[1], "r");
        Stopif(infile == 0, "Couldn't open file %s", argv[1]);
        uint32 MessageLength = fread(Message, sizeof(char),
                                     MAXLEN, infile);
        uint32 HexMessageLength = 2*MessageLength;
        char HexMessage[HexMessageLength + 1];
        StringToHex(HexMessage, Message, MessageLength);

        char ResultCipher[HexMessageLength + 1];
        EncryptMessage(ResultCipher, HexMessage, HexMessageLength);
        printf("%s\n", ResultCipher);
        fclose(infile);
    }
}
Exemple #8
0
BYTE StringHelper::StringToByte(string nHex)
{
	if (nHex.length() > 4)
		return -1;
	return (BYTE)StringToHex(nHex);
}