cancel
Showing results for 
Search instead for 
Did you mean: 

Need a conditional modebus register entry to modebus enable set command

Md Mubdiul Hasan
Associate III

Hi there,

I have 2 modebus register 0x0010, 0x0011. These are enable encryption

key value. There square vaule should be less then 255 for some reason. This modebus register can be allowed for certain command functions as follows.

void ModebusSetCMD_ENE(void)
{
	ModebusSetCMD_Rectifier();
	
	// ENE encryption
	
	{
		if(g_ModebusRegister[ENE_RANDUM_NUMBER] && (g_ModebusRegister[ENE_ENCRYPTION_KEY] & 0xFF))
		{
			g_ModebusRegister[ENE_ENCRYPTION_RESULT] = (g_ModebusRegister[ENE_RANDUM_NUMBER] + (g_ModebusRegister[ENE_ENCRYPTION_KEY] >> 8)) / (g_ModebusRegister[ENE_ENCRYPTION_KEY] & 0xFF);
		}
		else
		{
			g_ModebusRegister[ENE_ENCRYPTION_RESULT] = 0xFFFF;
		}
	}
}

What should I do in the logic to make them less then 225?

0 REPLIES 0