And is that declared as static, like I mentioned weeks ago?
Did you compare &Port[3] with pParam (again, mentioned ages ago) to see if both addresses are the same?
Guess not....
Printable View
And is that declared as static, like I mentioned weeks ago?
Did you compare &Port[3] with pParam (again, mentioned ages ago) to see if both addresses are the same?
Guess not....
Hey guys, thanks for all of your help and all, but one of my co-workers figured it out and it's all good now. The error resided in the code
Funnily enough, I posted that function but only included the header and the first declaration, where the problem appeared to be. However it should look like this:Code:UINT C_RS_422_Port::Send_Crypto_Key(int key)
{
DWORD aword = ::WaitForMultipleObjects(2,EventHandles,FALSE,INFINITE);
char Crypto_Key_1[17] = "123456789ABCDEFG";
char Crypto_Key_2[17] = "HIJKLMNOPQRSTUVW";
char Crypto_Key_Reversed[17];
char Crypto_Next_Byte_Confirm;
UINT Crypto_Key_Character = 0;
if(key==1)
for (int count=0; count<16; count++)
{
Crypto_Key_Character += (1 & (UINT) Crypto_Key_1[count]) << 7;
Crypto_Key_Character += (2 & (UINT) Crypto_Key_1[count]) << 5;
Crypto_Key_Character += (4 & (UINT) Crypto_Key_1[count]) << 3;
Crypto_Key_Character += (8 & (UINT) Crypto_Key_1[count]) << 1;
Crypto_Key_Character += (16 & (UINT) Crypto_Key_1[count]) >> 1;
Crypto_Key_Character += (32 & (UINT) Crypto_Key_1[count]) >> 3;
Crypto_Key_Character += (64 & (UINT) Crypto_Key_1[count]) >> 5;
Crypto_Key_Character += (128 & (UINT) Crypto_Key_1[count]) >> 7;
Crypto_Key_Reversed[count] = Crypto_Key_Character;
Crypto_Key_Character=0;
}
else
for (int count=0; count<16; count++)
{
Crypto_Key_Character += (1 & (UINT) Crypto_Key_2[count]) << 7;
Crypto_Key_Character += (2 & (UINT) Crypto_Key_2[count]) << 5;
Crypto_Key_Character += (4 & (UINT) Crypto_Key_2[count]) << 3;
Crypto_Key_Character += (8 & (UINT) Crypto_Key_2[count]) << 1;
Crypto_Key_Character += (16 & (UINT) Crypto_Key_2[count]) >> 1;
Crypto_Key_Character += (32 & (UINT) Crypto_Key_2[count]) >> 3;
Crypto_Key_Character += (64 & (UINT) Crypto_Key_2[count]) >> 5;
Crypto_Key_Character += (128 & (UINT) Crypto_Key_2[count]) >> 7;
Crypto_Key_Reversed[count] = Crypto_Key_Character;
Crypto_Key_Character=0;
}
for (int count=0; count<16; count++)
{
if(b_Crypto_ON)
{
Send_Bytes(&Crypto_Key_Reversed[count],1);
OutByteBufferCryptoReversed[count] = Crypto_Key_Reversed[count];
if(key==1)
{
OutByteBufferCrypto[count] = Crypto_Key_1[count];
fprintf(pFile, "%2d \t %6d ", (UINT) Crypto_Key_Reversed[count], (UINT) Crypto_Key_1[count]);
}
else
{
OutByteBufferCrypto[count] = Crypto_Key_2[count];
fprintf(pFile, "%2d \t %6d ", (UINT) Crypto_Key_Reversed[count], (UINT) Crypto_Key_2[count]);
}
fprintf(pFile, "\n");
}
else
count = 16;
}
if(Executive.GetLogCrypto())
{
WriteCryptoTextFile();
}
}
I guess there needs to be that do while true loop to keep the thread going infinitely. Without it, the thread breaks and trying to use it again fails. My bad.Code:UINT C_RS_422_Port::Send_Crypto_Key(int key)
{
DWORD aword = ::WaitForMultipleObjects(2,EventHandles,FALSE,INFINITE);
char Crypto_Key_1[17] = "123456789ABCDEFG";
char Crypto_Key_2[17] = "HIJKLMNOPQRSTUVW";
char Crypto_Key_Reversed[17];
char Crypto_Next_Byte_Confirm;
UINT Crypto_Key_Character = 0;
if(key==1)
for (int count=0; count<16; count++)
{
Crypto_Key_Character += (1 & (UINT) Crypto_Key_1[count]) << 7;
Crypto_Key_Character += (2 & (UINT) Crypto_Key_1[count]) << 5;
Crypto_Key_Character += (4 & (UINT) Crypto_Key_1[count]) << 3;
Crypto_Key_Character += (8 & (UINT) Crypto_Key_1[count]) << 1;
Crypto_Key_Character += (16 & (UINT) Crypto_Key_1[count]) >> 1;
Crypto_Key_Character += (32 & (UINT) Crypto_Key_1[count]) >> 3;
Crypto_Key_Character += (64 & (UINT) Crypto_Key_1[count]) >> 5;
Crypto_Key_Character += (128 & (UINT) Crypto_Key_1[count]) >> 7;
Crypto_Key_Reversed[count] = Crypto_Key_Character;
Crypto_Key_Character=0;
}
else
for (int count=0; count<16; count++)
{
Crypto_Key_Character += (1 & (UINT) Crypto_Key_2[count]) << 7;
Crypto_Key_Character += (2 & (UINT) Crypto_Key_2[count]) << 5;
Crypto_Key_Character += (4 & (UINT) Crypto_Key_2[count]) << 3;
Crypto_Key_Character += (8 & (UINT) Crypto_Key_2[count]) << 1;
Crypto_Key_Character += (16 & (UINT) Crypto_Key_2[count]) >> 1;
Crypto_Key_Character += (32 & (UINT) Crypto_Key_2[count]) >> 3;
Crypto_Key_Character += (64 & (UINT) Crypto_Key_2[count]) >> 5;
Crypto_Key_Character += (128 & (UINT) Crypto_Key_2[count]) >> 7;
Crypto_Key_Reversed[count] = Crypto_Key_Character;
Crypto_Key_Character=0;
}
switch (aword)
{
case 0:
{
do{
g_CritSec.Lock();
for (int count=0; count<16; count++)
{
// Read_Bytes(&Crypto_Next_Byte_Confirm,1);
// if((b_Crypto_ON) & (Crypto_Next_Byte_Confirm==1))
if(b_Crypto_ON)
{
Send_Bytes(&Crypto_Key_Reversed[count],1);
OutByteBufferCryptoReversed[count] = Crypto_Key_Reversed[count];
if(key==1)
{
OutByteBufferCrypto[count] = Crypto_Key_1[count];
fprintf(pFile, "%2d \t %6d ", (UINT) Crypto_Key_Reversed[count], (UINT) Crypto_Key_1[count]);
}
else
{
OutByteBufferCrypto[count] = Crypto_Key_2[count];
fprintf(pFile, "%2d \t %6d ", (UINT) Crypto_Key_Reversed[count], (UINT) Crypto_Key_2[count]);
}
fprintf(pFile, "\n");
}
else
count = 16;
}
if(Executive.GetLogCrypto())
{
WriteCryptoTextFile();
}
fprintf(pFile, "\n");
}
while(true);
break;
}
case 1:
{
return(0);
break;
}
default:
return(0);
}
}